Good morning, everyone!
I'm trying to implement in a game that the character walks with the mouse on the keyboard.
The system would practically emulate 8 mouse clicks depending on the combination I press the A S D and W keys on the keyboard.
As shown in the following image:
However, I can't use While (GetKeyState("D", "P")) to detect when two keys are pressed simultaneously to emulate the movement when the A and W keys are pressed together.
Does anyone have any idea how to do this?
Implement in a game that the character walks (GetKeyState two keys)
Implement in a game that the character walks (GetKeyState two keys)
- Attachments
-
- movmouse.jpg
- (8.79 KiB) Downloaded 48 times
Re: Implement in a game that the character walks (GetKeyState two keys)
Welcome to this AutoHotkey forum!
WASD to MouseMove
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.
WASD to MouseMove
Code: Select all
#Requires AutoHotkey v1.1.33.11
mult := 10 ; Pixels per move
SLOW := 0 ; Mouse speed (0-100, 0=fastest)
period := 10 ; Timer period (ms)
w::
a::
s::
d::
If (timer = period)
Return
SetTimer Go, % timer := period
Go:
SetBatchLines -1
pressed := x := y := 0
For key, coord in {w: [0, -1], d: [1, 0], s: [0, 1], a: [-1, 0]}
pressed |= state := GetKeyState(key, "P"), x += state * coord[1], y += state * coord[2]
If pressed
MouseMove mult * x, mult * y, SLOW, R
Else SetTimer,, % timer := "Off"
Return