Jump to content

Help writing a simple script for a beginner


Recommended Posts

Hi everybody my name is Ryan. I am a bit new to scripts. I really don't plan on writing anything major at all. I have a program that keep shutting off every 15 minutes. I would like to create a script that opens it every 15 minutes by opening it through a link. What I am trying to say is that I don't want it to open it by clicking, but it needs to find the file by itself.

Is this even possible? I am sure it is simple for just about all of you but I really don't understand how to write a script for a timer.

Link to comment
Share on other sites

Hi everybody my name is Ryan. I am a bit new to scripts. I really don't plan on writing anything major at all. I have a program that keep shutting off every 15 minutes. I would like to create a script that opens it every 15 minutes by opening it through a link. What I am trying to say is that I don't want it to open it by clicking, but it needs to find the file by itself.

Is this even possible? I am sure it is simple for just about all of you but I really don't understand how to write a script for a timer.

Firstly welcome to the forum; you will find that everyone here is extremely helpful in helping you with your problems. We just ask that you post some sample code of your design, and we will help you from there.

Take a look in the helpfile for timerinit() and if the link you are wanting to click is in a webpage, try some of the _IE functions.

"The true measure of a man is how he treats someone who can do him absolutely no good."

Link to comment
Share on other sites

Firstly welcome to the forum; you will find that everyone here is extremely helpful in helping you with your problems. We just ask that you post some sample code of your design, and we will help you from there.

Take a look in the helpfile for timerinit() and if the link you are wanting to click is in a webpage, try some of the _IE functions.

This is where I am stuck. As you can see I am very new to this.(hoping to get better though) So the first command is run and I have the file name go after that. Then I want it to sleep for 15 min. How would I insert 15mins? Last command is to start the whole process over again until I shut down the program.

Where is this help file you are talking about?

Run(filename) 
Sleep(15 minutes)
Loop 
EndFunc
Link to comment
Share on other sites

Where is this help file you are talking about?

There is an online help file here, AutoIt. If you have installed AutoIt, there is one in the install directory, or hit F1 in the SciTE editor.<br>

Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

I am a bit confused on which loop to use.

The following loop statements are available in AutoIt:

* For...Next

* While...WEnd

* Do...Until

* With...Endwith

* For...In...Next

I am think it can only be the second and third one from the list. But have no idea how to input this into my script.

Link to comment
Share on other sites

In my experience, there isn't a whole lot of difference in the performance of a do...until loop and a while loop. Personally, I almost always use while loops. Here is how you would do it in an infinite while loop. To make this a finite loop, replace the 1 with a boolean expression.

While 1
     Run($filename)
     Sleep(1000 * 60 * 15)
WEnd

A With...EndWith loop is for objects, so that won't help at all.

A For...In...Next loop is to do a set of actions on every element in an array, so that isn't it.

A For...Next Loop repeats a set of actions a given number of times.

Edited by dantay9
Link to comment
Share on other sites

You would probably want a While...WEnd loop, with Sleep in it. See the function examples for more info. The local help file has examples also, and if AutoIt is installed, with the SciTE editor, the 'open this script' button is very helpful as the example can be opened and run in the editor.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

In my experience, there isn't a whole lot of difference in the performance of a do...until loop and a while loop. Personally, I almost always use while loops. Here is how you would do it in an infinite while loop. To make this a finite loop, replace the 1 with a boolean expression.

While 1
     Run($filename)
     Sleep(1000 * 60 * 15)
WEnd

A With...EndWith loop is for objects, so that won't help at all.

A For...In...Next loop is to do a set of actions on every element in an array, so that isn't it.

A For...Next Loop repeats a set of actions a given number of times.

Ok I think I am starting to understand a little more now. Assuming you put in the correct time than 1000 would be a millisecond and 60 would be 1 minute times 15, Giving me a total sleep of 15 mins.

Link to comment
Share on other sites

  • Developers

@ryan909,

Read this page and complete the tutorial. After that comeback when you still have questions.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks Jos. I have figured out my mistake. Will see if I can find a few good tutorial vids on youtube.

Thanks for all of the help folks.

The youtube tutorials are linked to from the page Jos gave you :) just scroll down to the video section
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...