Jump to content

hold down a key


Recommended Posts

HotKeySet("l", "HoldLeftKey") ;Can't use {LEFT} for some reason?
HotKeySet("{ESC}", "_Exit")

While 1
    Sleep(100)
WEnd

Func HoldLeftKey()
    While 1
        Send("{LEFT}")
        Sleep(100)
        If _IsPressed(27) Then ExitLoop
    WEnd
EndFunc

Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
    Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey)
    If @error Then Return SetError(@error, @extended, False)
    Return BitAND($a_R[0], 0x8000) <> 0
EndFunc

Func _Exit()
    Exit
EndFunc

Edited by rogue5099
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...