Jump to content

Recommended Posts

Posted

I do indeed know about AT but hoped there was a nice function within AutoIT to add scheduled tasks with nice names and icons, instead of the AT command adding ID1 ID2 etc...

However, I have thought this over, and this piece of code works pretty well actually, only problem is you cannot "name" the scheduled task so if you run it several times you get several instances of the task.

I'll think on that one today. For anyone else in my situation maybe this will be of some help.

#include <GUIConstants.au3>

#Include <GuiCombo.au3>

;#NoTrayIcon

Dim $hours

Dim $minutes

$tasks=GUICreate("Q-Backup" & " Scheduling your backup.",320,200)

$filemenu = GuiCtrlCreateMenu ("File")

$saveitem = GuiCtrlCreateMenuitem ("Set Schedule",$filemenu)

$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)

GUICtrlCreateLabel ("Please select the time for Q-Backup to begin (24 hr format)", 5,10)

GUICtrlCreateLabel (":", 153,30)

$hours = GuiCtrlCreateCombo("", 100, 30, 50, 10)

$minutes = GuiCtrlCreateCombo("", 160, 30, 50, 10)

GUICtrlCreateLabel ("Please select the days of the week to run Q-Backup", 5,70)

$m = GUICtrlCreateCheckBox ("Monday", 5, 90)

$tu = GUICtrlCreateCheckBox ("Tuesday", 70, 90)

$w = GUICtrlCreateCheckBox ("Wednesday", 140, 90)

$t = GUICtrlCreateCheckBox ("Thursday", 225, 90)

$f = GUICtrlCreateCheckBox ("Friday", 5, 110)

$s = GUICtrlCreateCheckBox ("Saturday", 70, 110)

$su = GUICtrlCreateCheckBox ("Sunday", 140, 110)

$set = GuiCtrlCreateButton ("Set schedule",105,150,100,20)

GuiSetState()

For $i = 0 to 23

$len = StringLen($i)

if $len = 1 Then $i = 0&$i

GUICtrlSetData($hours,$i)

Next

For $i = 0 to 59

$len = StringLen($i)

if $len = 1 Then $i = 0&$i

GUICtrlSetData($minutes,$i)

Next

_GUICtrlComboSetCurSel($hours,0)

_GUICtrlComboSetCurSel($minutes,30)

GUICtrlSetState($m, $GUI_CHECKED)

GUICtrlSetState($tu, $GUI_CHECKED)

GUICtrlSetState($w, $GUI_CHECKED)

GUICtrlSetState($t, $GUI_CHECKED)

GUICtrlSetState($f, $GUI_CHECKED)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $set

Call ("save")

Case $msg = $saveitem

Call ("save")

Case $msg = $exititem

Exit

Endselect

WEnd

GUIDelete($tasks)

Exit

Func save()

$monday=""

$tuesday=""

$wednesday=""

$thursday=""

$friday=""

$saturday=""

$sunday=""

If BitAND(GUICtrlRead($m), $GUI_CHECKED) = $GUI_CHECKED Then $monday = "m,"

If BitAND(GUICtrlRead($tu), $GUI_CHECKED) = $GUI_CHECKED Then $tuesday = "t,"

If BitAND(GUICtrlRead($w), $GUI_CHECKED) = $GUI_CHECKED Then $wednesday = "w,"

If BitAND(GUICtrlRead($t), $GUI_CHECKED) = $GUI_CHECKED Then $thursday = "t,"

If BitAND(GUICtrlRead($f), $GUI_CHECKED) = $GUI_CHECKED Then $friday = "f,"

If BitAND(GUICtrlRead($s), $GUI_CHECKED) = $GUI_CHECKED Then $saturday = "s,"

If BitAND(GUICtrlRead($su), $GUI_CHECKED) = $GUI_CHECKED Then $sunday = "su,"

$choicehours = GUICtrlRead ( $hours )

$choiceminutes = GUICtrlRead ( $minutes )

$atdays = $monday&$tuesday&$wednesday&$thursday&$friday&$saturday&$sunday

msgbox(0,"Run","at " & $choicehours & ":" & $choiceminutes & " /interactive" & " /every:" & $atdays & " " & chr(34) & "yourjob.exe" & chr(34) )

EndFunc

Posted

Could you not check for job files before creating the task..

Find all files in Task folder. Create the new task then find all the files in the task folder again, at this point you can find out what your new task is called which is going to be At???? then just rename it with AutoIT to QSchedTask or whatever you want to call it that way you'll know if you've already set the task up.

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
×
×
  • Create New...