lugosi Posted September 25, 2014 Share Posted September 25, 2014 Within the program that I am writing, I want to check to see if certain keys are pressed, very much like a hotkey. Is it best to use the HotKeySet command, or should I use some different method for waiting for the keypress? The thing that I dont like about HotKeySet (it isn't an intense dislike, just a nagging niggle) is that it 'hijacks' that key for the entire run of the program (just like a good hotkey should!) even if my program is not the program in focus at the time. Thanks in advance for any help you can give. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 25, 2014 Moderators Share Posted September 25, 2014 Take a look at _IsPressed in the help file Xandy 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Solution MikahS Posted September 25, 2014 Solution Share Posted September 25, 2014 (edited) I don't like _IsPressed. I just used this in my app, and I did not like it as it will not work once a key has already been pressed. Very crude, but using Accelerators is they way to go: Local $aAccelKeys[1][1] = [["{TAB}", $exTab]] GUISetAccelerators($aAccelKeys, $hwnd) ; example While 1 $msg = GUIGetMsg() Switch $msg Case $exTab ; run whatever you want here EndSwitch WEnd Edited September 25, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2014 Moderators Share Posted September 25, 2014 (edited) Lugosi,Or GUISetAccelerators - they are like HotKeys but are only active when you GUI has focus so they should not "niggle". Could I also point you at this announcement - not suggesting your intent is to create a keylogger, but just to make our stance on such matters quite clear. M23Edit: I see I am getting slower as I age. Edited September 25, 2014 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MikahS Posted September 25, 2014 Share Posted September 25, 2014 Melba, your knowledge is much greater though Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
lugosi Posted September 25, 2014 Author Share Posted September 25, 2014 I can assure you that this is not for a keylogger of any kind. I am creating a program to update/change the OEM configuration information on a PC for my company. We want to be able to brand our computers with our logo and information. I have created quite a nice program if I might say so This is my first real foray into AutoIT programming (and the first programming that I have done in MANY years, not that I was ever a great programmer to begin with.....it is a hobby to me). Thank you for all of the advice.....esp. that about the keylogger stuff! I gotta be careful how I phrase things so as not to be banished Link to comment Share on other sites More sharing options...
lugosi Posted September 25, 2014 Author Share Posted September 25, 2014 BTW....I really like that last post, Melba.....that looks like a very elegant way to handle this. Link to comment Share on other sites More sharing options...
lugosi Posted September 25, 2014 Author Share Posted September 25, 2014 I just replaced hotkeys with accelerators, and it worked like a charm Link to comment Share on other sites More sharing options...
MikahS Posted September 25, 2014 Share Posted September 25, 2014 I just replaced hotkeys with accelerators, and it worked like a charm Glad to help Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ 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