I was told in the Disco help channel that discussing AHK is OK as long as it does not pertain to Freelancer.
So I just got Deus Ex: Human Revolution Director's Cut. It's a first person shooter where you can aim down weapon sights (ADS). However, the ADS is a toggle, instead of a hold. I want it to be a hold.
I had this same issue with Bioshock Infinite, and I was able to fix it with a simple AutoHotkey script that was basically
However, Deus Ex is being a jerk. I keep getting 'stuck' in ADS, and when that happens, my script is then fighting me, with the Rbutton Up call putting me back into ADS after I try to click out of it.
I figured, okay, there must be a time delay for ADS in this game, wherein after you click to go into ADS, any further clicks are ignored until the animation is completed.
And so I set about making my script more complicated, to handle this time-delay.
Code:
#Include Timer.ahk
#IfWinActive Deus Ex: Human Revolution
$RButton::Send {Rbutton}
What should happen, is that when the script sees Rbutton Up:: , it checks Timer("ADS"), which returns true or false depending on whether the timer's period is expired. If true, it should immediately Send {Rbutton}. If false, it should get the remaining time Timer("ADS","L") and sleep for that duration, and then Send Rbutton.
..And it works... sometimes. I can confirm that it does sometimes do what it's supposed to, because to test it, I set the duration to like 4 seconds, and sure enough, after I clicked into ADS and took my hand off the mouse, it would exit ADS 4 seconds later.
But it's like the game is sometimes ignoring my clicks, because I'm still sometimes getting stuck in ADS. Sometimes it enters when I click but doesn't leave, like the game ignored the second Rbutton from the script. Other times, it ignores the first click, and enters ADS when it sees the Rbutton Up. It's, like, 50/50 that it'll either work like it's supposed to, or get stuck.
Any suggestions?
At this point, I'm suspecting that it's a problem with the game.
I have no doubt, or I'd say I'm almost completely convinced its not the game 's issue. Alot of keyboards can't proccess multiple key-selections and alot of them also dont function well when a number of keys are being pressed at the same time.
Shouldn't you send Rbutton and Rbutton::up as well on Rbutton down?
[11:20:20] aerelm: its not fl dev work if you dont have to power through the whole thing on your own
[11:20:32] aerelm: help is for pussy devs like in dota
@Zen, like I said, I didn't have this problem using AHK to perform the same job with Bioshock Infinite. It would get stuck like this once in a while, yeah, but it was very playable. In Deus EX:HR, it's getting 'stuck' about 75% of the time.
@utrack I tried it that way and it didn't make any difference.
When I'm not running AHK, the issue with it 'ignoring clicks' goes away. I've been getting used to having my ADS be a toggle instead of a hold... I guess. But it's consistent, and therefore better than dealing with the derpiness that AHK brings to this game. -_-
(The * is to have it activate even when you hit a modifier, not 100% sure if necessary.)
It worked 95% of the time in BF4: only time's it didn't work when tested was when tapping the RButton only very shortly. It might be though that BF4 can't handle RDS on and off that quickly following each other, or the 50ms+10ms in the loop is a bit too long. You could try if it works with <50ms Sleep between down and up. I know that BF4 (and especially 3) are both horrible when it comes to registering very short button-taps...Before anyone complains: I only use it for spotting, which I could put on my mousewheel because I don't use it to scroll through weapons.
Why "Sleep" between the "Click" commands?
I noticed quite a few times that programs don't register mouseclicks/buttonpresses if you don't give them enough time between a "button down" and "button up" (or just use a "Send[Input]").
The sleep in the loop is just to have it do something in the loop, not sure how much processor it otherwise takes up, if it works I suggest keeping it at 10ms (or higher), if you have problems, try setting it lower (1ms). Haven't tried how it works if there's no sleep in there, but I could imagine it might cause problems.
(I never worked with timer's myself...and I have quite an old version of AHK anyway, as I just noticed. Should still work I think.)