Jump to content

Recommended Posts

Posted

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

Posted

By the way, the purpose of this thing I'm making is just to get a basic understanding of keypressed and send, and i thought of this. that way if i look at at in notepad, it will send both. PLEASE HELP!!!

Posted (edited)

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

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
×
×
  • Create New...