charvi Posted December 7, 2008 Share Posted December 7, 2008 Hello, I searched the forum but couldn't find the solution about a key combination with _IsPressed(). I understand the _IsPressed function for getting 1 character from the keyboard/mouse buffer, but how to use it for a character combination like Ctrl+K ? I tried with HotKeySet("^k","_Bkk") and this works fine, but the problem is that the hotkey is still active in the _Bkk function. My non-working code so far: $i_VK_CONTROL = 0x11 ; Ctrl $i_VK_K = 0x4B ; K $t_User32 = DllOpen("user32.dll") If _IsPressed($i_VK_CONTROL & $i_VK_K,$t_User32) Then _Bkk_() Link to comment Share on other sites More sharing options...
martin Posted December 7, 2008 Share Posted December 7, 2008 Hello, I searched the forum but couldn't find the solution about a key combination with _IsPressed(). I understand the _IsPressed function for getting 1 character from the keyboard/mouse buffer, but how to use it for a character combination like Ctrl+K ? I tried with HotKeySet("^k","_Bkk") and this works fine, but the problem is that the hotkey is still active in the _Bkk function. My non-working code so far: $i_VK_CONTROL = 0x11 ; Ctrl $i_VK_K = 0x4B ; K $t_User32 = DllOpen("user32.dll") If _IsPressed($i_VK_CONTROL & $i_VK_K,$t_User32) Then _Bkk_() You can't add the keys together like that. Also, the parameter should be the hex string. #include <misc.au3> $i_VK_CONTROL = "11" ; Ctrl $i_VK_K = "4B"; K - need caps lock on or shift down on my keyboard. $t_User32 = DllOpen("user32.dll") while 1 If _IsPressed($i_VK_CONTROL) and _IsPressed($i_VK_K) Then ConsoleWrite("combination detected" & @CRLF) sleep(30) WEnd You can stop a hot key working inside a function by having the line HotKeySet("^K","") at the start of the function, then set the hotkey again when you leave the function. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
charvi Posted December 7, 2008 Author Share Posted December 7, 2008 Thanks martin. Using _IsPressed twice with the 'And' operator worked fine. But, disactivating the hotkey with HotKeySet("^k","") is invalid, the program is stopping working. I tried that too Yes, I had to use ^k in my example instead of ^K as it is case sensitive. It was a typo. 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