Bekaarfaltu Posted September 20, 2021 Share Posted September 20, 2021 WinActivate ("LMS — Mozilla Firefox") Global $j = 0, $k = 0 Do MouseClick("left", 415, 205, 1) Sleep(2000) Do MouseClick("left", 1271, 858, 1) Sleep(10000) $j = $j + 1 Until $j = 2 ; Increase the value of $j until it equals the value of 2. $k = $k + 1 Until $k = 2 ; Increase the value of $k until it equals the value of 2. Exit The problem is that the second loop keeps on running. I'm obviously missing something simple. I'm new to this. Please help. Link to comment Share on other sites More sharing options...
Solution water Posted September 20, 2021 Solution Share Posted September 20, 2021 (edited) Welcome to AutoIt and the forum! You have to reset $j when you start the inner loop again: WinActivate ("LMS — Mozilla Firefox") Global $j = 0, $k = 0 Do MouseClick("left", 415, 205, 1) Sleep(2000) $j = 0 Do MouseClick("left", 1271, 858, 1) Sleep(10000) $j = $j + 1 Until $j = 2 ; Increase the value of $j until it equals the value of 2. $k = $k + 1 Until $k = 2 ; Increase the value of $k until it equals the value of 2. Exit Edited September 20, 2021 by water JockoDundee and Bekaarfaltu 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
JockoDundee Posted September 20, 2021 Share Posted September 20, 2021 (edited) @wateris correct. Why not just: WinActivate ("LMS — Mozilla Firefox") For $k = 0 To 1 MouseClick("left", 415, 205, 1) Sleep(2000) For $j = 0 To 1 MouseClick("left", 1271, 858, 1) Sleep(10000) Next Next Exit Edited September 20, 2021 by JockoDundee Bekaarfaltu 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Bekaarfaltu Posted September 20, 2021 Author Share Posted September 20, 2021 Thank you @water. Just the value of $j needed to be reset to 0. Such a simple solution! @JockoDundee Your solution is much cleaner and simpler. For...Next loops seem better. Thanks! Link to comment Share on other sites More sharing options...
Musashi Posted September 20, 2021 Share Posted September 20, 2021 32 minutes ago, Bekaarfaltu said: @JockoDundee Your solution is much cleaner and simpler. For...Next loops seem better. Thanks! Unfortunately, it seems not possible to mark more than one post as "Solution" . JockoDundee 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
JockoDundee Posted September 20, 2021 Share Posted September 20, 2021 3 hours ago, Musashi said: Unfortunately, it seems not possible to mark more than one post as "Solution" @waterquickly dissolved the problem, leaving only a solution Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
water Posted September 20, 2021 Share Posted September 20, 2021 I would vote for multiple solutions. There is more than one way to skin a cat As a user I would like to select the most elegant/efficient code from a bunch of "solutions". Just my 2 cents worth Musashi 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
JockoDundee Posted September 20, 2021 Share Posted September 20, 2021 2 hours ago, water said: I would vote for multiple solutions. I would agree. In this case though, I’m not worthy, since at the very moment that water posted $j = 0, my draft response showed something like: Quote The program should exit in 44 seconds… Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
water Posted September 20, 2021 Share Posted September 20, 2021 Your updated version not only fixed the problem but is much cleaner and elegant. So the OP can learn how good code looks like in addition. Every post that solves the OPs problem should be a candidate to be marked by the OP as "Solution". JockoDundee 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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