skyhigh 1 Posted October 24, 2015 (edited) Hi,I am writing a script to open my browser and go to a random URL. The url must change randomly every X minutes between 12.00 Pm and 4.00 Pm. Starting from this last part I think I should use a condition If...then from the beginning, but I am not sure how to get the script to know what time it is.For the random change I think I should use a loop, but again I am not sure.Can you help me please?Here is a part of the script:(I have put the want-to-do lines between ";");If $Hour < 4 then #include <ff.au3> Global $var[4] $var[1] = "www.youtube.com" $var[2] = "www.vimeo.com" $var[3] = "www.twitch.tv" $x = Random(1, 5, 1) _FFStart($var[$x]) ;loop ;else stop the script Edited October 24, 2015 by skyhigh Share this post Link to post Share on other sites
kylomas 415 Posted October 25, 2015 skyhigh,How long should each URL be active?Define "x minutes"Most importantly, why would you want to do this?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 Share this post Link to post Share on other sites
skyhigh 1 Posted October 25, 2015 skyhigh,How long should each URL be active?Define "x minutes"Most importantly, why would you want to do this?kylomasEach URL should be active for less than 15 minutes.I would like to do this for a project I am thinking about for a while. Thanks to autoit I hope to make it! I'm a beginner, I just need help to know how to do it.Thank you very much if you can help me. Share this post Link to post Share on other sites
Chimp 700 Posted October 25, 2015 (edited) This should do#include <ff.au3> Global $var[4] $var[1] = "www.youtube.com" $var[2] = "www.vimeo.com" $var[3] = "www.twitch.tv" While @HOUR >= 12 And @HOUR <= 16 ; within 12 to 4PM $x = Random(1, 3, 1) _FFStart($var[$x]) ; use Sleep to pause ; 1 * 60000 = 1 minute ; 14 * 60000 = 14 minutes ; Random pause from 1 to 14 minutes Sleep(Random(1 * 60000, 14 * 60000, 1)) WEnd Edited October 25, 2015 by Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Share this post Link to post Share on other sites
kylomas 415 Posted October 25, 2015 skyhigh,Do you want to prevent starting an instance of the same URL in succession?How do you stop the URL's?If a URL is already active do you want to start another instance of it or switch to the active one? 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 Share this post Link to post Share on other sites
skyhigh 1 Posted October 26, 2015 (edited) This should do#include <ff.au3> Global $var[4] $var[1] = "www.youtube.com" $var[2] = "www.vimeo.com" $var[3] = "www.twitch.tv" While @HOUR >= 12 And @HOUR <= 16 ; within 12 to 4PM $x = Random(1, 3, 1) _FFStart($var[$x]) ; use Sleep to pause ; 1 * 60000 = 1 minute ; 14 * 60000 = 14 minutes ; Random pause from 1 to 14 minutes Sleep(Random(1 * 60000, 14 * 60000, 1)) WEnd Thank you Chimp :D. I understood and adapted it to my script skyhigh,Do you want to prevent starting an instance of the same URL in succession?The final URLs list will be longer, so it is not necessary to prevent that.How do you stop the URL's?Sorry, did not understand your question. If a URL is already active do you want to start another instance of it or switch to the active one?I found a way to work it out through tab manipulation It's late, I will tell more tomorrow (got a new problem too, yay!) Edited October 27, 2015 by skyhigh Share this post Link to post Share on other sites