joeyeti Posted September 21, 2011 Share Posted September 21, 2011 Hi folks, I have used AutoIt sporadically for the past 10+ years and now I am creating a script, that should wait for a key combination from me (say Ctrl+Alt+D), then execute a block of commands (I have that already) and then wait again... I tried the below, but get an error (Unknown function name, for the line with the first IF): While 1 If _IsPressed('A0') = 1 Then While 1 If _IsPressed('A2') = 1 Then While 1 If _IsPressed('44') = 1 Then ...... block of commands ...... EndIf Wend EndIf Wend EndIf Wend Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 21, 2011 Moderators Share Posted September 21, 2011 joeyeti,Welcome to the AutoIt forum. Take a look at HotKeySet in the Help file - a much easier way to do what you want. ; This HotKey exits the script HotKeySet("{ESC}", "On_Exit") ; This one is your special HotKey HotKeySet("!^d", "_Do_It") While 1 Sleep(10) WEnd Func _Do_It() MsgBox(0, "HotKey", "What did you want me to do?") EndFunc Func On_Exit() Exit EndFuncPlease ask if anything is unclear. 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...
joeyeti Posted September 21, 2011 Author Share Posted September 21, 2011 Thx Melba23! Works now and yes, it is easier and "cleaner" code-wise... Link to comment Share on other sites More sharing options...
joeyeti Posted September 21, 2011 Author Share Posted September 21, 2011 One more follow-up: Is this correct in waiting for a mouse click? While 1 If _IsPressed("01") = 1 Then ExitLoop Sleep(10) WEnd Link to comment Share on other sites More sharing options...
Xandy Posted September 21, 2011 Share Posted September 21, 2011 (edited) yes, '01'= LEFT MOUSE BUTTON true = DOWN state false = UP state Edited September 21, 2011 by songersoft Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
joeyeti Posted September 21, 2011 Author Share Posted September 21, 2011 Thx songersoft! Link to comment Share on other sites More sharing options...
Xandy Posted September 21, 2011 Share Posted September 21, 2011 (edited) #include "misc.au3"; package includes/enables _ispressed() definition While 1 Sleep(10) If _IsPressed("01") Then; when left mouse button pressed while _ispressed('01'); wait for left mouse button to be released sleep(10) wend ExitLoop endif WEnd This code will wait for the mouse button to be released before moving on. A system which solves some logical errors in this type of event. Edited September 21, 2011 by songersoft Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) 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