mr-es335 Posted Friday at 02:12 PM Posted Friday at 02:12 PM (edited) Good day, I have been unable to obtain an answer to my query regarding the MouseClick() function. Two examples may be beneficial here: #cs The following example WILL produce an error wherein the inital command IS NEVER completed successfully! #ce ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example1() ; ----------------------------------------------- Func Example1() MouseClick($MOUSE_CLICK_LEFT, 684, 112, 1, 0) Sleep($iTimeOut) Send("{ALTDOWN}") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 486, 112, 1, 0) Sleep($iTimeOut) Send("{ALTUP}") Sleep($iTimeOut) Send("I") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 160, 1, 1) EndFunc ;==>Example1 ; ----------------------------------------------- ============================================ #cs The following example will NOT produce an error wherein the inital command IS completed successfully! #ce ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example2() ; ----------------------------------------------- Func Example2() Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 684, 112, 1, 0) Sleep($iTimeOut) Send("{ALTDOWN}") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 486, 112, 1, 0) Sleep($iTimeOut) Send("{ALTUP}") Sleep($iTimeOut) Send("I") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 160, 1, 1) EndFunc ;==>Example2 ; ----------------------------------------------- My question is, "Is a pause generally required prior to the execution of a MouseClick() function?" What is even "odder" to me is that I often have to execute scripts more-than-once in order to obtain the results that are required!?! "Why?" As always...any assistance in this matter would be greatly appreciated! Thank you all for your time! Edited Friday at 02:21 PM by mr-es335 mr-es335 Sentinel Music Studios
Nine Posted Friday at 05:32 PM Posted Friday at 05:32 PM 3 hours ago, mr-es335 said: Is a pause generally required prior to the execution of a MouseClick() function? No, but... Your last MouseClick is not followed by a Sleep. Probably the reason. mr-es335 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mr-es335 Posted Friday at 05:55 PM Author Posted Friday at 05:55 PM Nine, May I ask why the last MouseClick should be succeeded by a Sleep? mr-es335 Sentinel Music Studios
Nine Posted Friday at 08:53 PM Posted Friday at 08:53 PM If you're running this script in a loop, then you are not leaving enough time to the last click to complete. mr-es335 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mr-es335 Posted Saturday at 05:19 PM Author Posted Saturday at 05:19 PM Nine, Thanks for the "heads-up",,,very, very much appreciated!! The only down-side, is that I have quite a number of scripts to "fix"!! mr-es335 Sentinel Music Studios
mr-es335 Posted 15 hours ago Author Posted 15 hours ago Nine, You stated, "If you're running this script in a loop, then you are not leaving enough time to the last click to complete." I do NOT believe that I am running this script in a loop - just within a single function call. If I am not running this script in a loop, would the following be appropriate?... ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example3a() ; ----------------------------------------------- Func Example3a() Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 684, 112, 1, 0) Sleep($iTimeOut) Send("{ALTDOWN}") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 486, 112, 1, 0) Sleep($iTimeOut) Send("{ALTUP}") Sleep($iTimeOut) Send("I") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 160, 1, 1) EndFunc ;==>Example3a ; ----------------------------------------------- ...or... ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example3b() ; ----------------------------------------------- Func Example3b() Sleep($iTimeOut) ; <<<=== Here!... MouseClick($MOUSE_CLICK_LEFT, 684, 112, 1, 0) Sleep($iTimeOut) Send("{ALTDOWN}") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 486, 112, 1, 0) Sleep($iTimeOut) Send("{ALTUP}") Sleep($iTimeOut) Send("I") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 160, 1, 1) Sleep($iTimeOut) ; <<<=== and Here!... EndFunc ;==>Example3b ; ----------------------------------------------- Finally, what of this?... ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example4() ; ----------------------------------------------- Func Example4() Local $hSAC_SCENES = "[CLASS:SAC_SCENES]" ; ----------------------------------------------- WinActivate($hSAC_SCENES) ; ----------------------------------------------- Send("{End}") ; Select: [End Of List] ; ----------------------------------------------- Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 0) ; Select: [New] ; ----------------------------------------------- Sleep($iTimeOut) ClipPut("====Fades====") ; Copy text ; ----------------- Send("{CTRLDOWN}") Send("v") ; Paste text Send("{CTRLUP}") ; ---------------------- Send("{ENTER}") ; Select: [Ok] EndFunc ;==>Example4 ; ----------------------------------------------- Any assistance here would be greatly appreciated! mr-es335 Sentinel Music Studios
Nine Posted 8 hours ago Posted 8 hours ago 1- you can put sleep anywhere / everywhere. It doesn't hurt except can slow down the script. You need to test and decide. 2- having a single delay ($iTimeOut) is a very bad idea. Sometimes, it requires more time, sometimes it requires less. You need to test and decide. 3- it is not because you paste something that it will be pasted instantly in the field. It may take some time. You need to test and decide. mr-es335 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mr-es335 Posted 6 hours ago Author Posted 6 hours ago Hello, Okay! May I ask "Why!" Sleep()...is required at all? All that I am attempting to do is to automate a series of steps and I am finds the ENTIRE process very, very , in a word, "Flaky!!" mr-es335 Sentinel Music Studios
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