Sign in to follow this  
Followers 0
fi3l2

Run Program Scheduler

6 posts in this topic

hey all, i am a definate noob to scripting here. I found this after I was messing with an Andy bot for diablo II and wanted to try my own tweaks.

Below is my attempt to run any file (another .au3 script, or anything else) at a certain time that is specifed. the reason I did it this way is because from what I was seeing, the Run() command doesn't work with other scripts.... which is why I got into autoit in the first place

basically to do things when I am not here :-D

lemme know what you guys thing and post some major improvements to it if you wish (plz!)

Thanks :-D

;Runs Anything at a certain time

#include <Date.au3>

$program = FileOpenDialog("Choose file...","My Computer","All")

$time = InputBox("Time", "What time would you like it to run?" & @CRLF & "hh:mm:ss AM/PM", _NowTime(), "")

$count = 0

while $time > 0 
  if $time = _NowTime() Then
    Send("#r")
    WinWaitActive("Run")
    Send($program & "{Enter}")
    $count = $count + 1
    Sleep(1000)
  EndIf
Wend

One problem I have seen, the script does not end after the program runs, the autoit is still in a tray icon for the script, anyone shed some light as to what is keeping this script alive after the while loop is done?

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

nice first script =), to make it end simply add an "exit" in the if statement

while $time > 0
  if $time = _NowTime() Then
    Send("#r")
    WinWaitActive("Run")
    Send($program & "{Enter}")
    $count = $count + 1
    Sleep(1000)
    Exitloop
  EndIf
Wend

btw

$program = FileOpenDialog("Choose file...","My Computer","All")

didnt work for me, i changed it to

$program = FileOpenDialog("Choose file...","My Computer","All(*.*)")
Edited by burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Plus put the Sleep() statement outside the if\endif condition, it will make your CPU happier :)

while $time > 0
  if $time = _NowTime() Then
    Send("#r")
    WinWaitActive("Run")
    Send($program & "{Enter}")
    $count = $count + 1
    Exitloop
  EndIf
Sleep(1000)
Wend
Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

ty ty

runs great now

awesome

thanks again

gotta get back to learning even more off the forums

latez

Share this post


Link to post
Share on other sites

What about having it sleep the time difference of now and when it needs to go off.

ie:

1) Get the time you want it to go off

2) sleep(1000*(difference in seconds between then and now))

3) execute your code

this will save you some cpu


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

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  
Followers 0