Schoening Posted January 9, 2012 Share Posted January 9, 2012 Hey, so i just started yesterday with AutoIt and found that awesome beginner tutorial on the site I made a script: Send("{w}") MouseClick("left") Send("{tab}") Send("{w}") MouseClick("left") Send("{tab}") But the script did not work propperly.. So i changed it to this: Send("{w}") MouseClick("left") Send("{tab}") Sleep(1) Send("{w}") MouseClick("left") Send("{tab}") And it worked smooth.. Was this because the program i was running it in needed 1 Mil. Sec. to respond? Sorry that i can't be better to describe myself Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 9, 2012 Moderators Share Posted January 9, 2012 Schoening,Welcome to the AutoIt forum. As you discovered , apps often need a short pause between Send commands to give them time to react. But there is no point in using a Sleep of less than 10ms - AutoIt treats them all the same as the API function it uses to pause itself has a minimum level of about that value (there are special cases like Sleep(0), but we will leave them until later. 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...
Schoening Posted January 9, 2012 Author Share Posted January 9, 2012 But it works this way, and does not work without the Sleep(). So you are just saying that i should put sleep up to (10) ? I can't see the difference tbh but that's perhaps just because my eyes can't follow 1- 10 milliseconds Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 9, 2012 Moderators Share Posted January 9, 2012 Schoening,As I said above, apps receiving multiple Send commands often require an intermediate Sleep to allow them to react. What I explained was that it makes no difference if you use Sleep(1) or Sleep(10) - AutoIt will give you the minimum sleep possible in either case. 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...
Schoening Posted January 9, 2012 Author Share Posted January 9, 2012 ahh ! thx Link to comment Share on other sites More sharing options...
kylomas Posted January 9, 2012 Share Posted January 9, 2012 M23, Care to expand on the sleep(0) comment?? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 9, 2012 Moderators Share Posted January 9, 2012 kylomas,As far as I understand it, using Sleep(0) tells the OS that the app is ready to give up its next timeshare on the CPU. If the CPU is busy then this could be a significant delay (in computer terms) - if the CPU is pretty much idle then it could be an almost instantaneous pause. There is probably more to it - but you will have to wait for a real nerd to come along and explain further (which comment will probably prevent anyone else from doing so!). Of interest, Jon coded GUIGetMsg and TrayGetMsg in a similar manner - busy CPU means about 10ms delay; idling CPU means only just enough delay to give the CPU a break. 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...
kylomas Posted January 10, 2012 Share Posted January 10, 2012 M23, Thanks, sounds like you are describing preemptive VS. cooperative dispatching (no, not real nerd, trying to make transition from big iron to little iron OS's). kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Beege Posted January 10, 2012 Share Posted January 10, 2012 (edited) Schoening, If i need a delay in the range of 1 to 10 I use sleep function from kernel dll. Heres quick example:;Open handle to kernel making call to sleep as fast as possible $hKernel = DllOpen('kernel32.dll') ;register function that will close handle one exit OnAutoItExitRegister('_CloseHandles') $hTime = TimerInit() _Sleep(1) ConsoleWrite('Sleep(1) = ' & TimerDiff($hTime) & @LF) $hTime = TimerInit() _Sleep(2) ConsoleWrite('Sleep(2) = ' & TimerDiff($hTime) & @LF) $hTime = TimerInit() _Sleep(3) ConsoleWrite('Sleep(3) = ' & TimerDiff($hTime) & @LF) $hTime = TimerInit() _Sleep(0) ConsoleWrite('Sleep(0) = ' & TimerDiff($hTime) & @LF) Func _Sleep($iMs) DllCall($hKernel, 'none', 'Sleep', 'dword', $iMs) EndFunc Func _CloseHandles() DllClose($hKernel) EndFuncMy results wereSleep(1) = 1.05511285324879 Sleep(2) = 1.9529418029077 Sleep(3) = 2.99126132270029 Sleep(0) = 0.0307195124198989Also from the msdn:If you specify 0 milliseconds, the thread will relinquish the remainder of its time slice but remain ready. Note that a ready thread is not guaranteed to run immediately. Consequently, the thread may not run until some time after the sleep interval elapses. Edited January 10, 2012 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
kylomas Posted January 10, 2012 Share Posted January 10, 2012 Beege, Thanks, this was curiousity only. When I read something that I don't understand (as in M23's comment) then I ask a question, often to the annoyance of others! kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Beege Posted January 10, 2012 Share Posted January 10, 2012 Sorry thats my bad. When I replied, I looked at post #7 and thought you were the OP. Ill edit that. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator 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