Steven Froast
Steven Froast

Reputation: 61

AHK simulate holding key while physical holding key down

I am having trouble with an autohotkey script. What I want it to do is by physically holding down A on my keyboard I would like the script to tap mouse button4 and then hold down 1 for as long as I am holding down A for. When I release A I would like the script to release 1 as well. My bad attempt at the script is

a::
send {Xbutton1}
sleep 10
Send {1 down}
While GetKeyState(a, "p")
    Sleep 10
Send {1 up}
Return

The problem I am having is that the script is not holding down 1 as I am holding down A. Does anyone talented in ahk know how I can fix this?

Upvotes: 1

Views: 4710

Answers (1)

Roman
Roman

Reputation: 221

a::
send {Xbutton1}
sleep 10
While GetKeyState("a", "p")
 {
 Send {1 down}
 Sleep 10
 }
Send {1 up}
Return

Upvotes: 1

Related Questions