Dxnny Posted April 21, 2021 Share Posted April 21, 2021 Say I want a script to run only 1 in 100 times or 1 in 10 times, how would I do that? So it only has a certain chance of running. Link to comment Share on other sites More sharing options...
Nine Posted April 21, 2021 Share Posted April 21, 2021 After looking at your previous posts, I am wondering what is the application you are trying to automate ? “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
JockoDundee Posted April 21, 2021 Share Posted April 21, 2021 3 hours ago, Dxnny said: Say I want a script to run only 1 in 100 times or 1 in 10 times, how would I do that? So it only has a certain chance of running. Most of my scripts naturally have about that chance of running Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted April 22, 2021 Share Posted April 22, 2021 28 minutes ago, JockoDundee said: Most of my scripts naturally have about that chance of running I hope your odds are better . @Dxnny : Example : This script starts after the tenth call (see $iStartCount = 10) : Local $sFilePath = @ScriptDir & "\StartCounter.ini", $iStartCount = 10, $iCounter If Not FileExists($sFilePath) Then IniWrite($sFilePath, "Counter", "Attempt", 1) $iCounter = Int(IniRead($sFilePath, "Counter", "Attempt","")) If $iCounter < $iStartCount Then MsgBox(BitOR(4096, 64), "Message", "Attempt = " & String($iCounter)) ; *** just for test $iCounter += 1 Exit IniWrite($sFilePath, "Counter", "Attempt", $iCounter) EndIf FileDelete($sFilePath) MsgBox(BitOR(4096, 64), "Message", "Script starts at attempt = " & String($iCounter)) ; *** just for test ; Your script : ; [...] "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...
jchd Posted April 22, 2021 Share Posted April 22, 2021 (edited) If Random(1, 10, 1) <> Random(1, 10, 1) Then Exit ; program (statistically 1 time over 10). You get the surprise as a bonus. Edited April 22, 2021 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JockoDundee Posted April 22, 2021 Share Posted April 22, 2021 (edited) 1 hour ago, jchd said: (statistically 1 time over 10). To save CPU, maybe: If Random(0,9,1) Then Exit ; program Edited April 22, 2021 by JockoDundee wolflake 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Dxnny Posted April 22, 2021 Author Share Posted April 22, 2021 8 hours ago, Nine said: After looking at your previous posts, I am wondering what is the application you are trying to automate ? I’m trying to automate a Discord messaging system, and have some fun with it, only really to learn AutoIt and mess around. Link to comment Share on other sites More sharing options...
Dxnny Posted April 22, 2021 Author Share Posted April 22, 2021 4 hours ago, jchd said: If Random(1, 10, 1) <> Random(1, 10, 1) Then Exit ; program (statistically 1 time over 10). You get the surprise as a bonus. How would I make it run the script 9 times out of 10 then? Link to comment Share on other sites More sharing options...
jchd Posted April 22, 2021 Share Posted April 22, 2021 If Random(1, 10, 1) = Random(1, 10, 1) Then Exit ; program This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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