Jump to content

Script involving time and loops


skyhigh
 Share

Recommended Posts

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 by skyhigh
Link to comment
Share on other sites

skyhigh,

How long should each URL be active?

Define "x minutes"

Most importantly, why would you want to do this?

kylomas

Each 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.

 

Link to comment
Share on other sites

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 by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 

 

 

 

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 by skyhigh
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...