ahklerner wrote:
Code:
SetBatchLines -1
#UseHook
Increment = 1 ; number of pixels to move mouse....gets multiplied depending on keypress length
MouseDelay = 0
w::
a::
s::
d::
xVal=
yVal=
If GetKeyState("CapsLock","T")
{
IncrementValue := Increment ; Set the Increment value (we change it)
; Infinite loop....breaks when key not pressed anymore
Loop,
{
If (A_Index > IncrementValue * 15) and (IncrementValue < Increment * 5) ; Increase the Increment value depending on how long we held down the key
IncrementValue := IncrementValue * 2
If GetKeyState("s", "P")
yVal := IncrementValue
Else If GetKeyState("w", "P")
yVal := -IncrementValue
If !yVal
yVal := 0
If GetKeyState("a", "P")
xVal := -IncrementValue
Else If GetKeyState("d", "P")
xVal := IncrementValue
If !xVal
xVal := 0
If GetKeyState(A_ThisHotKey, "P") ; Make sure we are still pressing the key
MouseMove, %xVal%, %yVal%,%MouseDelay%,R
Else ; we're not pressing the key...break the loop
Break
}
}
Else
Send % "{" . A_ThisHotKey . "}"
return
Esc::ExitApp
I have been able to adapt ahklerner's code to use WASD instead of arrow keys. When using the keyboard the WASD control of the mouse works as expected. But when I try to use a program called xpadder to relay keystrokes from a USB game controller the code fails to run as expected. I ran the code in SciTE using debug mode and found that when it tries to GetKeyState it does not perceive the keys as having been pressed. I presume xpadder keystrokes would be called logical, as opposed to physical keystrokes from the keyboard. I have tried running GetKeyState without the mode option which is supposed to allow it to discern logical keystrokes but it does not work. The previous poster "Rocket" seems to have the same problem with logical keystrokes coming from the program Girder, and the poster "mnahkusr" has the same problem with logical keystrokes coming from the program Input Director in
this post.
Can anyone please advise how to adapt this code to work with logical key strokes? Using KeyWait seems like it could almost work, but doesn't exactly parallel the act of retrieving a keys current state the way that GetKeyState does. Sorry if this matter has already been covered. Thank you for whatever assistance you can provide.