I'm kinda new to this and have ran into a problem. As I'm new I don't know the correct terminology so sorry for that.
I'm probably not good enough at searching either as the answers I've found doesn't really fit my scenario so I can't make them work.
Essentially I have a pretty simple script that rebinds WASD to move the mouse to the edge of the screen while the specific key is held down and then back once released.
This script works well enough until I hold more than one of the specified keys down.
As an example lets just use A and W. If I hold down A and let go, everything works as intended. But if I hold down A and then hold down W while A is being held down the "W instance" will trigger and MouseGetPos will "record" the mouse at the position it is currently in (the position when A is being held down).
My solution to this would be to only allow either A or W to be held down but not both at the same time, so if I hold down A and then W it will ignore the W "command" until I let go of A.
I hope my explanation makes sense. Let me know if I should clarify anything.
Thank you for any input or tips on how to search for an answer.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
a::
BlockInput, MouseMove
MouseGetPos, MouseX, MouseY
MouseMove, 8, 540
KeyWait, a
MouseMove, MouseX, MouseY
BlockInput, MouseMoveOff
return
w::
BlockInput, MouseMove
MouseGetPos, MouseX, MouseY
MouseMove, 1000, 8
KeyWait, w
MouseMove, MouseX, MouseY
BlockInput, MouseMoveOff
return
s::
BlockInput, MouseMove
MouseGetPos, MouseX, MouseY
MouseMove, 1000, 1072
KeyWait, s
MouseMove, MouseX, MouseY
BlockInput, MouseMoveOff
return
d::
BlockInput, MouseMove
MouseGetPos, MouseX, MouseY
MouseMove, 1910, 540
KeyWait, d
MouseMove, MouseX, MouseY
BlockInput, MouseMoveOff
return
Esc::ExitApp