Jump to content

Help with keypress


Recommended Posts

Hello. Thanks in advance to whoever can help me.

I need to know how a keypress IF statement would work.

This is the code I have right now.

Send("{j down}")
Sleep(5000)
Send("{j up}")

I want to make it into an if statement, like:

IF "I press 'w'" THEN hold down j then wait 5 seconds, and release j.

I just don't know how do put the keypress in an if statement.

Please help whoever can.

thanks...

Link to comment
Share on other sites

If _IsPressed(57) Then  ;If 'w' is pressed 
    Send("{j down}")
    Sleep(5000)
    Send("{j up}")
EndIf

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

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...