karthikraju Posted February 15, 2013 Share Posted February 15, 2013 Hello,Background1) AutoIt : 3.3.8.12) OS : Windows XP SP3IssueI am attempting to create a set of keyboard shortcuts, as shown in the code below:#include <misc.au3> Local $hDLL = DllOpen("user32.dll") while 1 HotKeySet ("a" , "_keyA") wend Func _keyA () ; DOES work ; Wake + Left = Left If _ispressed ("FF") Then Send("{LEFT}") Endif ; DOES NOT work ; Alt + Wake + a = Home ; If _ispressed ("FF") and _ispressed ("12") Then ; Send("{HOME}") ; Endif EndFunc DllClose($hDLL)One of them, as indicated in the comment, works and sends a Left when pressing "Wake + a". The other one when sending "Alt + Wake + a" does not work. Could someone please let me know what is that I am doing wrong?Thank you for your time. Link to comment Share on other sites More sharing options...
JohnOne Posted February 15, 2013 Share Posted February 15, 2013 (edited) for a start. #include <misc.au3> Local $hDLL = DllOpen("user32.dll") HotKeySet ("a" , "_keyA") while 1 sleep(10) wend Func _keyA () ; DOES work ; Wake + Left = Left If _ispressed ("FF") Then Send("{LEFT}") Endif ; DOES NOT work ; Alt + Wake + a = Home ; If _ispressed ("FF") and _ispressed ("12") Then ; Send("{HOME}") ; Endif EndFunc DllClose($hDLL) You do notset hotkey in a loop. Edited February 15, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
karthikraju Posted February 15, 2013 Author Share Posted February 15, 2013 Sorry, I made a mistake with my first post. This code block ; DOES NOT work ; Alt + Wake + a = Home ; If _ispressed ("FF") and _ispressed ("12") Then ; Send("{HOME}") ; Endif should have been as follows: ; DOES NOT work ; Alt + Wake + a = Home If _ispressed ("FF") and _ispressed ("12") Then Send("{HOME}") Endif Link to comment Share on other sites More sharing options...
JohnOne Posted February 15, 2013 Share Posted February 15, 2013 (edited) I never knew you could add keys together (FF) is that really wake And left? Have you tried individual keys _Ispressed(wake) And _Ispressed(left) And _Ispressed(a)? Edited February 15, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted February 15, 2013 Share Posted February 15, 2013 And since you have opened the dll should it not be _Ispressed(key,$hDLL)? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
karthikraju Posted February 15, 2013 Author Share Posted February 15, 2013 I never knew you could add keys together (FF) is that really wake And left? Have you tried individual keys _Ispressed(wake) And _Ispressed(left) And _Ispressed(a)? FF is for one key, and is the key code for a key on the keyboard I've. Sorry, I am only tentative that the modifier name is Wake. Besides, the help file with the documentation for _isPressed [1] shows that it takes the key code as the argument and not the modifier name. Isn't it so? So, I tested the individual keys like you recommended as follows: #include <misc.au3> Local $hDLL = DllOpen("user32.dll") while 1 If _ispressed ("FF", $hDLL) and _ispressed (41, $hDLL) Then Send("{LEFT}") Endif wend DllClose($hDLL) which produced the intended result, but with side effects. The outcome results in multiple Left key presses and when the key combination is released it leaves an "a". And since you have opened the dll should it not be _Ispressed(key,$hDLL)? Yes, indeed. Thanks. [1] http://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm Link to comment Share on other sites More sharing options...
FireFox Posted February 15, 2013 Share Posted February 15, 2013 #include "HotKey.au3" ;http://www.autoitscript.com/forum/topic/90492-hotkey-udf/ _HotKeyAssign(BitOR(0xFF, 0x12), "_toto", BitOR($HK_FLAG_NOOVERLAPCALL, $HK_FLAG_NOREPEAT)) While 1 Sleep(1000) WEnd Func _toto() Send("{LEFT}") EndFunc Add $HK_FLAG_NOBLOCKHOTKEY in the BitOR if you want the hotkey to be non blocking. Br, FireFox. Link to comment Share on other sites More sharing options...
karthikraju Posted February 17, 2013 Author Share Posted February 17, 2013 Thank you Firefox. I took your code and modified it as follows: #include <Misc.au3> #include <HotKey.au3> #include <vkConstants.au3> Local $hDLL = DLLOpen("user32.dll") _HotKey_Assign($VK_LAUNCH_APP1, '_funcApp', $HK_FLAG_WAIT) _HotKey_Assign(BitOR($CK_CONTROL, $VK_ESCAPE), 'funcQuit') While 1 Sleep(1000) WEnd Func _funcApp() ; Send("{LEFT}"); DOES NOT work(!), when not commented ; Send("^{LEFT}"); DOES work, when not commented ; Send("^+{LEFT}"); DOES work, when not commented If _isPressed("41", $hDLL) Then ; Send("{LEFT}"); IS NOT when "Hotkey & A" Send("^{LEFT}") ; IS NOT invoked when "Hotkey & A" Endif EndFunc Func funcQuit() Exit ; DOES work EndFunc DllClose($hDLL) As the inline comments show, the send "Left" does not work, but "Control + Left" and "Control + Shift + A" does. Also, I wanted to use the Hotkey and A to send "Left", but this doesn't work either. Any input is appreciated. Link to comment Share on other sites More sharing options...
FireFox Posted February 17, 2013 Share Posted February 17, 2013 (edited) As the inline comments show, the send "Left" does not work, but "Control + Left" and "Control + Shift + A" does. Also, I wanted to use the Hotkey and A to send "Left", but this doesn't work either. Any input is appreciated. You can not use key combinations with combinations having in first key something else than Ctrl, Alt or Win. I did not think to it when I gave you my example. Let's go back to your example : #include <Misc.au3> ;block the key HotKeySet("{a}", "_toto") Local $hDLL = DllOpen("user32.dll") While 1 Sleep(10) If _IsPressed("FF", $hDLL) And _IsPressed("41", $hDLL) Then ;keys are pressed While _IsPressed("FF", $hDLL) Or _IsPressed("41", $hDLL) ;wait for them to be released Sleep(10) WEnd Send("{LEFT}") EndIf WEnd Func _toto() ; EndFunc DllClose($hDLL) Br, FireFox. Edited February 17, 2013 by FireFox 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