Sign in to follow this  
Followers 0
dexto

keydown keyup

5 posts in this topic

Looked up values for DLL call and all seemed to be fine.. but its not working :S

$user32 = DllOpen("user32")

Func keydown($bvkCode, $user32dll = 'user32.dll')
    DllCall($user32dll, 'int', 'keybd_event', 'byte', $bvkCode, 'byte', 0, 'uint', 0, 'ptr', 0)
EndFunc  ;==>keydown

Func keyup($bvkCode, $user32dll = 'user32.dll')
    DllCall($user32dll, 'int', 'keybd_event', 'byte', $bvkCode, 'byte', 0, 'uint', 2, 'ptr', 0)
EndFunc  ;==>keyup

send('"')
keydown(hex(Asc('o')),$user32)
Sleep(100)
keyup(hex(Asc('o')),$user32)
send('"')

DllClose($user32)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The 'keybd_event' function wants a virtual key starting with 0x

In virtual key code: hex(Asc('o')) = 00000006F = Divide key (Forward slash)

If your trying to send the letter o then try:

'0x' & hex(Asc('O'), 2)

If your trying to send the / then try:

'0x' & hex(Asc('o'), 2)

Edit:

To be truthfull I can't see why you'd use the outdated 'keybd_event' function..

AutoIt's own native send() function works well and is more then capable to do the same thing as 3 lines of code while only using 2 lines of code. It also offers some easy to use timing options instead of sleep()

opt("SendKeyDownDelay", 100)
Send('o')

If your going to use an api call you may as well use the newer call 'SendInput' function.

Edited by smashly

Share this post


Link to post
Share on other sites

Thank you, that fixed it!

The reason I need keydown/up is because my script has heavy user interaction, together with InputDisable() _isPressed(). I have to restore the keys pressed before user input was disabled.

Share this post


Link to post
Share on other sites

Thank you, that fixed it!

The reason I need keydown/up is because my script has heavy user interaction, together with InputDisable() _isPressed(). I have to restore the keys pressed before user input was disabled.

i'm trying to do the same thing try to detect if a button gows up and if a button gows down

can u pleas explane me how u fixed that ?

Share this post


Link to post
Share on other sites

i'm trying to do the same thing try to detect if a button gows up and if a button gows down

can u pleas explane me how u fixed that ?

daxto?

Share this post


Link to post
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
Sign in to follow this  
Followers 0