ryantollefson Posted August 25, 2007 Posted August 25, 2007 I have a directional pad in a gui that sends keypresses (up/down/left/right) - this works just fine. I also want to be able to detect when the user presses the actual up/down/left/right keys; however, when I am using "_IsPressed" it will detect both the actual keypresses, and the gui (simulated) keypresses. Is there a way to only detect (for example) the left arrow keypresses from the actual keyboard and not from: Send("{LEFT}") that the gui uses? Thanks for any advice.
ChrisL Posted August 25, 2007 Posted August 25, 2007 Use a hotkeyset function.That still detects send() [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
martin Posted August 25, 2007 Posted August 25, 2007 Unset hotkey, Send(), set hotkey back.What then would the point of the hot key be?@ryantollefsonI don't know how to distinguish between a send and an actual key. If no-one has a solution then maybe you could do something like;start of script$totalkeysent = 0$totalkeyin = 0...;when you send a keycountsend($key);when you detect a keyif _IsPressed($isk) then $totalkeyin += 1if $totalkeyin > $totalsent then $usertypekey = trueFunc countsend($kk)send($kk)$totalkeysent += 1endfunc 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.
Richard Robertson Posted August 25, 2007 Posted August 25, 2007 You would have to go to the hardware level to check for actual versus simulated keystrokes. I suppose you could try DirectInput. It reads hardware directly I think.
sylvanie Posted August 25, 2007 Posted August 25, 2007 effectively, like poisonkiller have suggested, this script is able to count only the number of "a" key which have been pressed with the keyboard : #Include <Misc.au3> HotKeySet("a","update_number_a") $number_a=0 While 1 send("a");to verify that these ones are not counted Sleep(1000) WEnd func update_number_a() If _IsPressed(41) Then HotKeySet("a") Send("a") $number_a+=1 ConsoleWrite($number_a&@CRLF) HotKeySet("a","update_number_a") EndIf EndFunc
martin Posted August 25, 2007 Posted August 25, 2007 effectively, like poisonkiller have suggested, this script is able to count only the number of "a" key which have been pressed with the keyboard : #Include <Misc.au3> HotKeySet("a","update_number_a") $number_a=0 While 1 send("a");to verify that these ones are not counted Sleep(1000) WEnd func update_number_a() If _IsPressed(41) Then HotKeySet("a") Send("a") $number_a+=1 ConsoleWrite($number_a&@CRLF) HotKeySet("a","update_number_a") EndIf EndFunc I think I'm beginning to catch up with everyone else in this thread I see what is being said, Misha meant use Hotkeyset and don't use _Ispressed, I read it as use HotkeySet to detect the keyboard and not detect the send. Now it all makes sense. I was trying to deal with the problem but still use _IsPressed. @Poisonkiller, apologies for my misunderstanding. 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.
martin Posted August 26, 2007 Posted August 26, 2007 I have a directional pad in a gui that sends keypresses (up/down/left/right) - this works just fine. I also want to be able to detect when the user presses the actual up/down/left/right keys; however, when I am using "_IsPressed" it will detect both the actual keypresses, and the gui (simulated) keypresses. Is there a way to only detect (for example) the left arrow keypresses from the actual keyboard and not from: Send("{LEFT}") that the gui uses?Thanks for any advice.There's something I am definitely missing somewhere.Are you talking about 2 different gui's running at the same time? If not then how did your script detect a send("{LEFT}") using _IsPressed? 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.
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