dexto Posted May 17, 2009 Share Posted May 17, 2009 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) Link to comment Share on other sites More sharing options...
smashly Posted May 17, 2009 Share Posted May 17, 2009 (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 May 18, 2009 by smashly Link to comment Share on other sites More sharing options...
dexto Posted May 18, 2009 Author Share Posted May 18, 2009 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. Link to comment Share on other sites More sharing options...
yucatan Posted June 3, 2009 Share Posted June 3, 2009 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 downcan u pleas explane me how u fixed that ? Link to comment Share on other sites More sharing options...
yucatan Posted June 4, 2009 Share Posted June 4, 2009 i'm trying to do the same thing try to detect if a button gows up and if a button gows downcan u pleas explane me how u fixed that ?daxto? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now