T O P

  • By -

Prozak06

So what have you tried


_TheNoobPolice_

The issue you will have when converting “toggle” or “goto” logic in a game to switch on a press / release “hold” instead is covering all possible break states. If you’re expecting a two line script to work well you’re probably going to be disappointed. For example, it may be if you “jump” that the game brings you out of the crouch without toggling it, but the script doesn’t know that unless you write some code from the jump key also to flip a variable. This might occur in other things even out of the game like pressing esc for menus or alt-tabbing etc. It’s doable but requires some thought and understanding of how the game handles all such situations


Mrivanov1

Yeah, I realized that. I am not good with coding i'm just starting to learn it at school but it doesn't really captivate me so I used chatGPT but as you mentioned it gives me a two line script: `#Persistent` `#IfWinActive, ahk_exe Far Cry4.exe` `$LShift::` `SetKeyDelay, -1` `Send {Blind}{Shift Down}` `KeyWait, LShift` `Send {Blind}{Shift Up}` `return` `$LCtrl::` `SetKeyDelay, -1` `Send {Blind}{LCtrl Down}` `KeyWait, LCtrl` `Send {Blind}{LCtrl Up}` `return`


_TheNoobPolice_

That script is totally pointless.. all it does is send shift down when you press shift down, and then send shift up when you release it (and the same for control) which is obviously just normal keyboard behaviour. ChatGPT knows next to nothing about AHK and its output is usually nonsense.


CrashKZ

As TheNoobPolice said, there are often actions in games that can cancel the state of something so this makes it difficult to work around because now you have to consider all or at least most edge-cases to have something "reliable".   I took a light whack at it (requires AHK v2). The sprint portion seems to work pretty well. The crouch part however only works, well, when it works. A common scenario where it would "fail" is sliding. Sliding always results in your character being crouched at the end. Maybe this won't be a problem for you; maybe in those scenarios you always press sprint again to stand instead of crouch. Apart from that, it seems to work pretty well. But it's up to you if want to deal with any drawbacks or just play the game as-is (or maybe take it upon yourself to figure out a better solution).   Notes: 1. If you use `Ctrl` to crouch then change the hotkey to `~LCtrl`. The only issue I noticed with using `LCtrl` was that if you were physically holding the key, it would take several attempts for the game to recognize `Escape` being pushed. And this happens even when AHK isn't involved. This could be potentially bothersome if you pause while crouched a lot. 2. If there are any other keys I missed that could cancel a crouch, you can add them to the other keys in this line:   static ih := Setup('{LShift}{Esc}{Space}')   The code: #Requires AutoHotkey v2.0 #HotIf WinActive('ahk_exe FarCry4.exe') ~*LShift up::SendEvent('s') ~c:: { static ih := Setup('{LShift}{Esc}{Space}') key := '{' SubStr(ThisHotkey, 2) '}' ih.Start() ih.Wait() if ih.EndReason != 'EndKey' { Sleep(30) SendEvent(key) } Setup(keys) { ih := InputHook('L0 V I') ih.KeyOpt(keys, 'E') ih.KeyOpt('{' SubStr(ThisHotkey, 2) '}', 'N') ih.OnKeyUp := (*) => ih.Stop() return ih } } #HotIf


Mrivanov1

Thank you!