Jump to content
Sign in to follow this  
ryan909

Help writing a simple script for a beginner

Recommended Posts

ryan909

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.

Share this post


Link to post
Share on other sites
sias

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

Share this post


Link to post
Share on other sites
ryan909

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

Share this post


Link to post
Share on other sites
somdcomputerguy

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.

Share this post


Link to post
Share on other sites
ryan909

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>

Thanks for the link. Looking into it now. Will be back for more questions in a few. :)

Share this post


Link to post
Share on other sites
ryan909

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.

Share this post


Link to post
Share on other sites
dantay9

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

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
somdcomputerguy

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.

Share this post


Link to post
Share on other sites
ryan909

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.

Share this post


Link to post
Share on other sites
ryan909

How would I put the file name in.

This is the file name: C:\Documents and Settings\Admin\Desktop\New Folder (2)\New Folder (2)\file name

The "and" is turned bold, like a command. And a few others as well...

Share this post


Link to post
Share on other sites
Jos

@ryan909,

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

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ryan909

@ryan909,

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

Jos

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.

Share this post


Link to post
Share on other sites
AdmiralAlkex

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.