iXX Posted June 2, 2012 Share Posted June 2, 2012 I need script that will wait for any key from keyboard. "HotKeySet" seems not provide this function. Anyone knows? Thanks... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2012 Moderators Share Posted June 2, 2012 iXX,Many of us "know", but checking for "any key" gets us perilously close to keylogger territory. Why do you need to wait for "any key"? What exactly are you trying to do?M23 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...
Shaggi Posted June 2, 2012 Share Posted June 2, 2012 @melba maybe he means the infamous "press any key to continue" idiom. @op what kind of program are you creating? Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
iXX Posted June 2, 2012 Author Share Posted June 2, 2012 Keyloggers, hmm. I understand... Only I am trying is that "any key to continue" thing, nothing more. Link to comment Share on other sites More sharing options...
czardas Posted June 2, 2012 Share Posted June 2, 2012 If you can send any key then it is not necessary to determine anything as the topic title would suggest. The following code should suffice. Send("{ENTER}") operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2012 Moderators Share Posted June 2, 2012 iXX,I am trying is that "any key to continue" thing, nothing moreAnd I did not think you were looking for anything more - I was just pointing out the difficulty of doing what you want within the Forum Rules. As you can decide which keys will allow your script to continue, why not define a limited number and then use _IsPressed? That way you avoid all the problems. M23 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...
czardas Posted June 2, 2012 Share Posted June 2, 2012 Uh uh, I got confused with the request. Oops. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Shaggi Posted June 2, 2012 Share Posted June 2, 2012 You could do like this, but why not just use a msgbox or something? runwait(@comspec & " /c pause") Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
iXX Posted June 2, 2012 Author Share Posted June 2, 2012 Melba23: Only few? Not enought. But I just discovered maybe a better solution: Timer_GetIdleTime() This affects mouse too, thinking... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2012 Moderators Share Posted June 2, 2012 (edited) iXX, Only few? Not enoughtAnd why not? Why must it be "any key"? What is wrong with "Press Enter to continue"? maybe a better solution: Timer_GetIdleTime()I was looking into that function the other day as a possible solution to this often-asked question and I ran into the same problem of differentiating between mouse and keyboard. M23 Edit: If you are interested, this is what I came up with: #include <guiconstantsex.au3> #include <timers.au3> While 1 If _WaitForKey() Then MsgBox(0, "Hi", "User activity") EndIf WEnd Func _WaitForKey() Local $iStart Local $aMPos = MouseGetPos() While 1 $iCurrent = _Timer_GetIdleTime() $aMPos_Now = MouseGetPos() If $iCurrent < $iStart Then If $aMPos_Now[0] <> $aMPos[0] Or $aMPos_Now[1] <> $aMPos[1] Then $aMPos = $aMPos_Now Return 0 EndIf Return 1 Else $iStart = $iCurrent EndIf Sleep(10) WEnd EndFunc Of course there are more elegant ways to do it, but then you get close to forbidden waters again. M23 Edited June 2, 2012 by Melba23 Added code 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...
PhoenixXL Posted June 2, 2012 Share Posted June 2, 2012 (edited) Only I am trying is that "any key to continue" thing, nothing more. If this the only reason then u must have a GUIthen this code will sound helpful (hope so)<snip> Edited June 2, 2012 by Melba23 Code removed My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Exit Posted June 2, 2012 Share Posted June 2, 2012 (edited) <snip> Edited June 2, 2012 by Melba23 Code removed App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2012 Moderators Share Posted June 2, 2012 All,I am locking this thread because it seems those of you responding are incapable of understanding that the code you post is reading the entire keyboard and thus is able to distinguish which key has been pressed. As such it falls foul of the the keylogger ban to which I linked earlier - what is hard to understand in that post? This "any key pressed" question comes up regularly and nearly always ends up getting locked. Just accept that although AutoIt is quite capable of doing this, you cannot discuss how to it in these forums. Do not PM me to argue about it - the site owner has decreed this ban and Mods are all ready to enforce it. And furthermore my patience is getting really worn thin when the same people (you know who you are ) keep posting code which watches the whole keyboard - the next time it happens the poster is getting a holiday. M23 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...
Recommended Posts