mr-es335 Posted November 14 Posted November 14 (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 November 14 by mr-es335 mr-es335 Sentinel Music Studios
Nine Posted November 14 Posted November 14 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 November 14 Author Posted November 14 Nine, May I ask why the last MouseClick should be succeeded by a Sleep? mr-es335 Sentinel Music Studios
Nine Posted November 14 Posted November 14 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 November 15 Author Posted November 15 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 Sunday at 08:50 PM Author Posted Sunday at 08:50 PM 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 Monday at 03:50 AM Posted Monday at 03:50 AM 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 Monday at 05:37 AM Author Posted Monday at 05:37 AM (edited) 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 finding this ENTIRE process very, very , in a word, "Flaky!!" Edited Monday at 02:09 PM by mr-es335 mr-es335 Sentinel Music Studios
Trong Posted Thursday at 08:56 AM Posted Thursday at 08:56 AM Because you are working on another software, you are operating that software to receive events that need time to process so you need to rest (although it is not correct, it should be confirmed by checking whether a window or some text appears before performing the action instead of just stopping for a moment) mr-es335 1 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
mr-es335 Posted Thursday at 02:41 PM Author Posted Thursday at 02:41 PM Trong, You stated, "... it should be confirmed by checking whether a window or some text appears before performing the action instead of just stopping for a moment) ". ...via, some form of error checking is what is required then? Correct? Query, "Is there a means of a "global error check" routine, wherein the outpuot is sent to the console - rather than being output in the actual script?" mr-es335 Sentinel Music Studios
Trong Posted Thursday at 03:21 PM Posted Thursday at 03:21 PM Some software can't get text or buttons I usually use image search to confirm actions.! Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
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