Sign in to follow this  
Followers 0
MikelSevrel

Automate Commands into AT(scheduler)

13 posts in this topic

#1 ·  Posted (edited)

Hello, I am trying to create a scheduler for a program(VirtualDub).

I want to dump options from a AuotIt gui into a bat file and schedule the bat file with the same gui. So i'm trying to figure out how I would go about doing that. Pardon me for the mess, i've never done anything like this before.

I'm thinking I can use checkboxes to check mondays, tuesdays, etc. and then use the return from the checkboxes to create a schedule. But, I've been looking all through the guides, and I just can't figure it out. Here's what I have, I'm sure it will be of no help, but to give an idea.

#Include <date.au3>
#include <GUIConstants.au3>
#include <Date.au3>

; GUI
GUICreate("VDub Capture Scheduler", 400, 400)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Channel Number", 10, 5, 250)
GUICtrlCreateLabel("Program Title", 10, 40, 250)
GUICtrlCreateLabel("Folder", 10, 75, 250)
GUICtrlCreateLabel("Device Name", 10, 110, 250)
GUICtrlCreateLabel("VDUB Location", 10, 145, 250)
GUICtrlCreateLabel("Start Time (Format 00:00 AM)", 10, 180, 250)
GUICtrlCreateLabel("Length in Minutes", 10, 215, 250)

; INPUT
$channel = GUICtrlCreateInput("31", 10, 20, 180, 20)
$title = GUICtrlCreateInput("Capture", 10, 55, 180, 20)
$folder = GUICtrlCreateInput("D:\My Videos", 10, 90, 180, 20)
$device = GUICtrlCreateInput("bt878", 10, 125, 180, 20)
$vdub = GUICtrlCreateInput("C:\Program Files\VirtualDub\vdub.exe", 10, 160, 180, 20)
$startime = GUICtrlCreateInput("3:00AM", 10, 195, 180, 20)
$endtime = GUICtrlCreateInput("60", 10, 230, 180, 20)
$once = GUICtrlCreateRadio("Once", 200, 10, 120, 20)
GUICtrlSetState ($once,$GUI_CHECKED)
$weekly = GUICtrlCreateRadio("Weekly", 200, 40, 120, 20)
$tree = GuiCtrlCreateTreeView(200, 70, 200, 140, $TVS_CHECKBOXES)
$sunday = GuiCtrlCreateTreeViewItem("Sunday", $tree)
$monday = GuiCtrlCreateTreeViewItem("Monday", $tree)
$tuesday = GuiCtrlCreateTreeViewItem("Tuesday", $tree)
GuiCtrlSetState(-1, $GUI_CHECKED)
$wednesday = GuiCtrlCreateTreeViewItem("Wednesday", $tree)
$thursday = GuiCtrlCreateTreeViewItem("Thursday", $tree)
$friday = GuiCtrlCreateTreeViewItem("Friday", $tree)
$saturday = GuiCtrlCreateTreeViewItem("Saturday", $tree)
$schedule = GUICtrlCreateButton("Schedule", 10, 280, 180, 20)
$cancel = GUICtrlCreateButton("Cancel", 200, 280, 180, 20)

; Script
While 1
    $msg = GUIGetMsg()
Select
Case $msg = $sunday
    $sunday = "sunday"
Case $msg = $monday
    $monday = "monday"
Case $msg = $tuesday
    $tuesday = "tuesday"
Case $msg = $wednesday
    $wednesday = "wednesday"
Case $msg = $thursday
    $thursday = "thursday"
Case $msg = $friday
    $friday = "friday"
Case $msg = $saturday
    $saturday = "saturday"
case $msg = $schedule
$variablefile = FileOpen ( "C:\tmp\schedule.bat", 1 )
If $once = 1 Then
$opts = "time " & $startime & " /next:" & $sunday & "," & $monday & "," & $tuesday & "," & $wednesday & "," & $thursday & "," & $friday & "," & $saturday & " /interactive"
Else
    $opts = "time " & $startime & " /every:" & $sunday & "," & $monday & "," & $tuesday & "," & $wednesday & "," & $thursday & "," & $friday & "," & $saturday & " /interactive"
EndIf
FileWrite($variablefile, "at " & $opts)
FileClose($variablefile)
Case $msg = $cancel
    ExitLoop

EndSelect


    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

If anyone can help me figure this out that'd be great.

Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I haven't worked enough with treeviews yet to get this real quick so i threw together a listview version of it

#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>

; GUI
GUICreate("VDub Capture Scheduler", 400, 400)
GUICtrlCreateLabel("Channel Number", 10, 5, 150)
GUICtrlCreateLabel("Program Title", 10, 40, 150)
GUICtrlCreateLabel("Folder", 10, 75, 150)
GUICtrlCreateLabel("Device Name", 10, 110, 150)
GUICtrlCreateLabel("VDUB Location", 10, 145, 150)
GUICtrlCreateLabel("Start Time (Format 00:00 AM)", 10, 180, 150)
GUICtrlCreateLabel("Length in Minutes", 10, 215, 150)

; INPUT
$channel = GUICtrlCreateInput("31", 10, 20, 180, 20)
$title = GUICtrlCreateInput("Capture", 10, 55, 180, 20)
$folder = GUICtrlCreateInput("D:\My Videos", 10, 90, 180, 20)
$device = GUICtrlCreateInput("bt878", 10, 125, 180, 20)
$vdub = GUICtrlCreateInput("C:\Program Files\VirtualDub\vdub.exe", 10, 160, 180, 20)
$startime = GUICtrlCreateInput("3:00AM", 10, 195, 180, 20)
$endtime = GUICtrlCreateInput("60", 10, 230, 180, 20)
$once = GUICtrlCreateRadio("Once", 200, 10, 120, 20)
GUICtrlSetState($once, $GUI_CHECKED)
$weekly = GUICtrlCreateRadio("Weekly", 200, 40, 120, 20)
$ListView = GUICtrlCreateListView("Day", 200, 70, 200, 140, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 195)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
$sunday = GUICtrlCreateListViewItem("Sunday", $ListView)
$monday = GUICtrlCreateListViewItem("Monday", $ListView)
$tuesday = GUICtrlCreateListViewItem("Tuesday", $ListView)
_GUICtrlListViewSetCheckState ($ListView, 2, 1)
$wednesday = GUICtrlCreateListViewItem("Wednesday", $ListView)
$thursday = GUICtrlCreateListViewItem("Thursday", $ListView)
$friday = GUICtrlCreateListViewItem("Friday", $ListView)
$saturday = GUICtrlCreateListViewItem("Saturday", $ListView)
$schedule = GUICtrlCreateButton("Schedule", 10, 280, 180, 20)
$cancel = GUICtrlCreateButton("Cancel", 200, 280, 180, 20)

GUISetState()

; Script
While 1
    $msg = GUIGetMsg()
    Select
        
        Case $msg = $schedule
            Local $days, $is_Checked
            For $x = 0 To _GUICtrlListViewGetItemCount ($ListView) - 1
                $is_Checked = _GUICtrlListViewGetCheckedState ($ListView, $x)
                If ($is_Checked <> $LV_ERR) Then
                    If ($is_Checked) Then
                        $days = $days & _GUICtrlListViewGetItemText ($ListView, $x) & ","
                    EndIf
                EndIf
            Next
            $days = StringTrimRight($days, 1); trim off the extra comma
            $variablefile = FileOpen("C:\tmp\schedule.bat", 1)
            If $once = 1 Then
                $opts = "time " & $startime & " /next:" & $days & " /interactive"
            Else
                $opts = "time " & $startime & " /every:" & $days & " /interactive"
            EndIf
            FileWrite($variablefile, "at " & $opts)
            FileClose($variablefile)
        Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    
WEnd
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Oh my God! Thank YOU! One thing, when it comes out, $starttime always comes out to 15. The other inputs come out to other numbers as well.

Me being an idiot again.. Never mind

Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

Oh my God! Thank YOU! One thing, when it comes out, $starttime always comes out to 15. The other inputs come out to other numbers as well.

i'll fix it in a minute, got so busy trying to figure out why the checkboxes and radios were not working i forgot to change the others (your labels were way to long, overlapped other controls)


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

this should get you going

#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>

; GUI
GUICreate("VDub Capture Scheduler", 400, 400)
GUICtrlCreateLabel("Channel Number", 10, 5, 150)
GUICtrlCreateLabel("Program Title", 10, 40, 150)
GUICtrlCreateLabel("Folder", 10, 75, 150)
GUICtrlCreateLabel("Device Name", 10, 110, 150)
GUICtrlCreateLabel("VDUB Location", 10, 145, 150)
GUICtrlCreateLabel("Start Time (Format 00:00 AM)", 10, 180, 150)
GUICtrlCreateLabel("Length in Minutes", 10, 215, 150)

; INPUT
$channel = GUICtrlCreateInput("31", 10, 20, 180, 20)
$title = GUICtrlCreateInput("Capture", 10, 55, 180, 20)
$folder = GUICtrlCreateInput("D:\My Videos", 10, 90, 180, 20)
$device = GUICtrlCreateInput("bt878", 10, 125, 180, 20)
$vdub = GUICtrlCreateInput("C:\Program Files\VirtualDub\vdub.exe", 10, 160, 180, 20)
$startime = GUICtrlCreateInput("3:00AM", 10, 195, 180, 20)
$endtime = GUICtrlCreateInput("60", 10, 230, 180, 20)
$once = GUICtrlCreateRadio("Once", 200, 10, 120, 20)
GUICtrlSetState($once, $GUI_CHECKED)
$weekly = GUICtrlCreateRadio("Weekly", 200, 40, 120, 20)
$ListView = GUICtrlCreateListView("Day", 200, 70, 200, 140, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 195)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
$sunday = GUICtrlCreateListViewItem("Sunday", $ListView)
$monday = GUICtrlCreateListViewItem("Monday", $ListView)
$tuesday = GUICtrlCreateListViewItem("Tuesday", $ListView)
_GUICtrlListViewSetCheckState ($ListView, 2, 1)
$wednesday = GUICtrlCreateListViewItem("Wednesday", $ListView)
$thursday = GUICtrlCreateListViewItem("Thursday", $ListView)
$friday = GUICtrlCreateListViewItem("Friday", $ListView)
$saturday = GUICtrlCreateListViewItem("Saturday", $ListView)
$schedule = GUICtrlCreateButton("Schedule", 10, 280, 180, 20)
$cancel = GUICtrlCreateButton("Cancel", 200, 280, 180, 20)

GUISetState()

; Script
While 1
    $msg = GUIGetMsg()
    Select
        
        Case $msg = $schedule
            Local $days, $is_Checked
            For $x = 0 To _GUICtrlListViewGetItemCount ($ListView) - 1
                $is_Checked = _GUICtrlListViewGetCheckedState ($ListView, $x)
                If ($is_Checked <> $LV_ERR) Then
                    If ($is_Checked) Then
                        $days = $days & _GUICtrlListViewGetItemText ($ListView, $x) & ","
                    EndIf
                EndIf
            Next
            $days = StringTrimRight($days, 1); trim off the extra comma
            $variablefile = FileOpen("C:\tmp\schedule.bat", 1)
            If BitAND(GUICtrlRead($once,$GUI_CHECKED) = $GUI_CHECKED Then
                $opts = "time " & GUICtrlRead($startime) & " /next:" & $days & " /interactive"
            Else
                $opts = "time " & GUICtrlRead($startime) & " /every:" & $days & " /interactive"
            EndIf
            FileWrite($variablefile, "at " & $opts)
            FileClose($variablefile)
        Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Again, thank you.

One more question, if I might. How might I convert 8:00PM into 20:00?

Sorry, I just started today.


Coming soon....

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

something like:

MsgBox(0,"Time",_ConvertToMilTime("8:00AM"))
MsgBox(0,"Time",_ConvertToMilTime("8:00PM"))

Func _ConvertToMilTime($s_date)
    If StringUpper(StringMid($s_date,StringLen($s_date) - 1, 2)) = "PM" Then
        $s_date = StringSplit(StringTrimRight($s_date,2),":")
        If Number($s_date[1]) < 12 Then $s_date[1] = Number($s_date[1]) + 12
    Else
        $s_date = StringSplit(StringTrimRight($s_date,2),":")
        If Number($s_date[1]) == 12 Then $s_date[1] = "0"
    EndIf
    Return StringFormat("%02d:%02d",$s_date[1],$s_date[2])
EndFunc
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Here she is

; Created by Mikel Sevrel 
; mikelsevrel <AT> gmail.com
; gafrost did most of it though
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>

; GUI
GUICreate("VDub Capture Scheduler", 400, 340)
GUICtrlCreateLabel("Channel Number", 10, 5, 150)
GUICtrlCreateLabel("Program Title", 10, 40, 150)
GUICtrlCreateLabel("Folder", 10, 75, 150)
GUICtrlCreateLabel("Device Name", 10, 110, 150)
GUICtrlCreateLabel("VDUB Location", 10, 145, 150)
GUICtrlCreateLabel("Start Time (Format 00:00AM)", 10, 180, 150)
GUICtrlCreateLabel("Length in Minutes", 10, 215, 150)


; DEFAULTS
$folderpath = @WorkingDir
$defaultchannel = IniRead($folderpath & "\default.ini", "Capture", "channel", "31")
$defaulttitle = IniRead($folderpath & "\default.ini", "Capture", "title", "Sci-Fi")
$defaultfolder = IniRead($folderpath & "\default.ini", "Capture", "folder", "D:\My Videos")
$defaultdevice = IniRead($folderpath & "\default.ini", "Capture", "device", "bt878")
$defaultvdub = IniRead($folderpath & "\default.ini", "Capture", "vdub", "C:\Program Files\VirtualDub\vdub.exe")
$defaultstartime = IniRead($folderpath & "\default.ini", "Capture", "startime", "7:00PM")
$defaultduration = IniRead($folderpath & "\default.ini", "Capture", "duration", "180")

; INPUT

$channel = GUICtrlCreateInput($defaultchannel, 10, 20, 180, 20)
$title = GUICtrlCreateInput($defaulttitle, 10, 55, 180, 20)
$folder = GUICtrlCreateInput($defaultfolder, 10, 90, 180, 20)
$device = GUICtrlCreateInput($defaultdevice, 10, 125, 180, 20)
$vdub = GUICtrlCreateInput($defaultvdub, 10, 160, 180, 20)
$startime = GUICtrlCreateInput($defaultstartime, 10, 195, 180, 20)
$duration = GUICtrlCreateInput($defaultduration, 10, 230, 180, 20)
$once = GUICtrlCreateRadio("Once", 200, 10, 120, 20)
GUICtrlSetState($once, $GUI_CHECKED)
$weekly = GUICtrlCreateRadio("Weekly", 200, 40, 120, 20)
$ListView = GUICtrlCreateListView("Day", 200, 70, 195, 140, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 190)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
GUICtrlCreateListViewItem("Sunday", $ListView)
GUICtrlCreateListViewItem("Monday", $ListView)
GUICtrlCreateListViewItem("Tuesday", $ListView)
_GUICtrlListViewSetCheckState ($ListView, 2, 1)
GUICtrlCreateListViewItem("Wednesday", $ListView)
GUICtrlCreateListViewItem("Thursday", $ListView)
GUICtrlCreateListViewItem("Friday", $ListView)
GUICtrlCreateListViewItem("Saturday", $ListView)


$schedule = GUICtrlCreateButton("Schedule", 3, 290, 180, 20)
$cancel = GUICtrlCreateButton("Close", 200, 290, 180, 20)

GUISetState()

Func _ConvertToMilTime($s_date)
    If StringUpper(StringMid($s_date,StringLen($s_date) - 1, 2)) = "PM" Then
        $s_date = StringSplit(StringTrimRight($s_date,2),":")
        If Number($s_date[1]) < 12 Then $s_date[1] = Number($s_date[1]) + 12
    Else
        $s_date = StringSplit(StringTrimRight($s_date,2),":")
        If Number($s_date[1]) == 12 Then $s_date[1] = "0"
    EndIf
    Return StringFormat("%02d:%02d",$s_date[1],$s_date[2])
EndFunc

; Script
While 1
    $msg = GUIGetMsg()
    $cap = " /capture /capchannel " & GUICtrlRead($channel) 
    $capdev = " /capdevice " & GUICtrlRead($device)
    $cmdlines = " /capfile """ & GUICtrlRead($folder) & "\" & GUICtrlRead($title) & ".avi"" /capstart " & GUICtrlRead($duration)
    Select
        
        Case $msg = $schedule
            Local $days, $is_Checked
            For $x = 0 To _GUICtrlListViewGetItemCount ($ListView) - 1
                $is_Checked = _GUICtrlListViewGetCheckedState ($ListView, $x)
                If ($is_Checked <> $LV_ERR) Then
                    If ($is_Checked) Then
                        $days = $days & _GUICtrlListViewGetItemText ($ListView, $x) & ","
                    EndIf
                EndIf
            Next
            $days = StringTrimRight($days, 1); trim off the extra comma
            $file = FileOpen(@WorkingDir & "\capture" & @SEC & @MIN & ".bat",2)
            FileWrite ($file, GUICtrlRead($vdub) & $cap & $capdev & $cmdlines)
            If $once = 1 Then
                $opts = "at " & _ConvertToMilTime(GUICtrlRead($startime)) & " /next:" & $days & " """ & @WorkingDir & "\capture"  & @SEC & @MIN & ".bat"
            Else
                $opts = "at " & _ConvertToMilTime(GUICtrlRead($startime)) & " /every:" & $days & " """ & @WorkingDir & "\capture" & @SEC & @MIN & ".bat"
            EndIf
            RunWait(@ComSpec & " /c " & $opts)
            MsgBox(0, "Schedule Saved", "Your Program Has Been Scheduled")
        Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
AT won't execute it..

Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

ALright, I figured out my latest problem, but alas I have another. AT launches the process in the system account, is there any way to launch it in the current account(so as to preserve the settings of the program I want to run)? Or is there a way to launch a program in the system account through AutoIt?

Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ALright, I figured out my latest problem, but alas I have another. AT launches the process in the system account, is there any way to launch it in the current account(so as to preserve the settings of the program I want to run)? Or is there a way to launch a program in the system account through AutoIt?

you could use schtask which has to option to define the userid/password to process the task.

schtasks /create /tn TaskName /tr TaskRun /sc schedule [/mo modifier] [/d day] [/m month[,month...] [/i IdleTime] [/st StartTime] [/sd StartDate] [/ed EndDate] [/s computer [/u [domain\]user /p password]] [/ru {[Domain\]User | "System"} [/rp Password]] /?

Edited by JdeB

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

Share this post


Link to post
Share on other sites

Unfortunately, schtasks.exe seems to be confined to XP Pro.


Coming soon....

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I've given up on AT, I'm just tryint to use AUtoit now.

Please help me get this work, i'm not sure what's wrong with it:

; Created by Mikel Sevrel
; mikelsevrel <AT> gmail.com
; gafrost did most of it though
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>
; GUI
GUICreate("VDub Capture Scheduler", 400, 340)
GUICtrlCreateLabel("Channel Number", 10, 5, 150)
GUICtrlCreateLabel("Program Title", 10, 40, 150)
GUICtrlCreateLabel("Folder", 10, 75, 150)
GUICtrlCreateLabel("Device Name", 10, 110, 150)
GUICtrlCreateLabel("VDUB Location", 10, 145, 150)
GUICtrlCreateLabel("Start Time (Format 00:00AM)", 10, 180, 150)
GUICtrlCreateLabel("Length in Minutes", 10, 215, 150)

; DEFAULTS
If FileExists("default.ini") = 1 Then
    $inivar = IniReadSection("default.ini", "Capture")
    
Else
    MsgBox(0, "", "Default Configuration File Created")
    IniWrite("default.ini", "Capture", "channel", "31")
    IniWrite("default.ini", "Capture", "title", "Capture")
    IniWrite("default.ini", "Capture", "folder", "C:\My Videos")
    IniWrite("default.ini", "Capture", "device", "bt878")
    IniWrite("default.ini", "Capture", "vdub", "C:\Program Files\VirtualDub\virtualdub.exe")
    IniWrite("default.ini", "Capture", "startime", "7:00PM")
    IniWrite("default.ini", "Capture", "duration", "60")
    IniWrite("default.ini", "Capture", "days", "Monday")
    $inivar = IniReadSection("default.ini", "Capture")
    
EndIf

; INPUT

$channel = GUICtrlCreateInput($inivar[1][1], 10, 20, 180, 20)
$title = GUICtrlCreateInput($inivar[2][1], 10, 55, 180, 20)
$folder = GUICtrlCreateInput($inivar[3][1], 10, 90, 180, 20)
$device = GUICtrlCreateInput($inivar[4][1], 10, 125, 180, 20)
$vdub = GUICtrlCreateInput($inivar[5][1], 10, 160, 180, 20)
$startime = GUICtrlCreateInput($inivar[6][1], 10, 195, 180, 20)
$duration = GUICtrlCreateInput($inivar[7][1], 10, 230, 180, 20)

$every = GUICtrlCreateListView("radio", 200, 20, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_LIST, $LVS_LIST)
GUICtrlCreateListViewItem("Weekly", $every)
$ListView = GUICtrlCreateListView("Day", 200, 70, 180, 140, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 175)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
GUICtrlCreateListViewItem("Sunday", $ListView)
GUICtrlCreateListViewItem("Monday", $ListView)
GUICtrlCreateListViewItem("Tuesday", $ListView)
GUICtrlCreateListViewItem("Wednesday", $ListView)
GUICtrlCreateListViewItem("Thursday", $ListView)
GUICtrlCreateListViewItem("Friday", $ListView)
GUICtrlCreateListViewItem("Saturday", $ListView)




$schedule = GUICtrlCreateButton("Schedule", 3, 270, 180, 20)
$cancel = GUICtrlCreateButton("Close", 200, 270, 180, 20)
$ini = GUICtrlCreateButton("Save Settings", 3, 298, 380, 20)

GUISetState()


Func _ConvertToMilTime($s_date)
    If StringUpper(StringMid($s_date, StringLen($s_date) - 1, 2)) = "PM" Then
        $s_date = StringSplit(StringTrimRight($s_date, 2), ":")
        If Number($s_date[1]) < 12 Then $s_date[1] = Number($s_date[1]) + 12
    Else
        $s_date = StringSplit(StringTrimRight($s_date, 2), ":")
        If Number($s_date[1]) == 12 Then $s_date[1] = "0"
    EndIf
    Return StringFormat("%02d-%02d", $s_date[1], $s_date[2])
EndFunc ;==>_ConvertToMilTime

; Script
While 1
    $msg = GUIGetMsg()
    $cap = " /capture /capchannel " & GUICtrlRead($channel)
    $capdev = " /capdevice " & GUICtrlRead($device)
    $cmdlines = " /capfile """ & GUICtrlRead($folder) & "\" & GUICtrlRead($title) & ".avi"" /capstart " & GUICtrlRead($duration)
    Select
        Case $msg = $ini
            MsgBox(0, "Saved", "Defaults Saved")
            
            IniWrite("default.ini", "Capture", "channel", GUICtrlRead($channel))
            IniWrite("default.ini", "Capture", "title", GUICtrlRead($title))
            IniWrite("default.ini", "Capture", "folder", GUICtrlRead($folder))
            IniWrite("default.ini", "Capture", "device", GUICtrlRead($device))
            IniWrite("default.ini", "Capture", "vdub", GUICtrlRead($vdub))
            IniWrite("default.ini", "Capture", "startime", GUICtrlRead($startime))
            IniWrite("default.ini", "Capture", "duration", GUICtrlRead($duration))
        Case $msg = $schedule
            Local $days, $is_Checked
            For $x = 0 To _GUICtrlListViewGetItemCount ($ListView) - 1
                $is_Checked = _GUICtrlListViewGetCheckedState ($ListView, $x)
                If ($is_Checked <> $LV_ERR) Then
                    If ($is_Checked) Then
                        $days = $days & _GUICtrlListViewGetItemText ($ListView, $x) & ","
                    EndIf
                EndIf
            Next
            $days = StringTrimRight($days, 1); trim off the extra comma
            $command = GUICtrlRead($vdub) & $cap & $capdev & $cmdlines
            FileWriteLine(@WorkingDir & "\command--" & _ConvertToMilTime(GUICtrlRead($startime)) & "," & $days & ",.bat", "rem Created by Mikel Sevrel")
            FileWriteLine(@WorkingDir & "\command--" & _ConvertToMilTime(GUICtrlRead($startime)) & "," & $days & ",.bat", "rem mikelsevrel <AT> gmail.com")
            FileWriteLine(@WorkingDir & "\command--" & _ConvertToMilTime(GUICtrlRead($startime)) & "," & $days & ",.bat", $command)
            IniWrite("schedule" & @HOUR & @MIN & ".ini", "Capture", "vdub", $command)
            IniWrite("schedule" & @HOUR & @MIN & ".ini", "Capture", "startime", _ConvertToMilTime(GUICtrlRead($startime)))
            IniWrite("schedule" & @HOUR & @MIN & ".ini", "Capture", "days", $days)
            IniWrite("schedule" & @HOUR & @MIN & ".ini", "Capture", "every", GUICtrlRead($every))
            MsgBox(0, "Schedule Saved", "Your Program Has Been Scheduled")
            Run(@WorkingDir & "\scheduler.exe")
        Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

And

; Created by Mikel Sevrel
; mikelsevrel <AT> gmail.com
#include <Date.au3>
#include <File.au3>
#include <Array.au3>
Dim $day, $days, $time, $now, $1, $2, $3, $4, $5, $6, $7, $schedule, $schedulelistfile, $inivar, $startime, $line1
$schedulelist = _FileListToArray(@WorkingDir, "command*.bat", 1)
$file = FileOpen(@WorkingDir & "\schedulelist.txt",2)
$schedule = _FileWriteFromArray(@WorkingDir & "\schedulelist.txt", $schedulelist)

$line = FileReadLine (@WorkingDir & "\schedulelist.txt", 1)

Func _ReadFileLines ($num)
$line1 = FileReadLine (@WorkingDir & "\schedulelist.txt", $num)
    $startime = StringSplit ($line1, "--")
    $days = StringSplit ($line1, ",")
    Return $days
    Return $startime
EndFunc

While 1
    
$rightnow = @hour & ":" & @MIN

WEnd
Select
Case $line = 0
    Exit
Case $line = 1
    _Time(1, 2)
    Case $line = 2
    _Time(2, 3)
    Case $line = 3
    _Time(3, 4)
    Case $line = 4
    _Time(4, 5)
    Case $line = 5
    _Time(5, 6)
    Case $line = 6
    _Time(6, 7)
    Case $line = 7
    _Time(7, 8)
Case $line = 8
        _Time(8, 9)
    Case $line = 9
    _Time(9, 10)
    Case $line = 10
    _Time(10, 11)
    Case $line = 11
    _Time(12, 13)
    Case $line = 12
    _Time(13, 14)
EndSelect


Func _DayMatch($daymatch)
Select
Case $1 = $day 
    $now = 1
Case $2 = $day 
    $now = 1
Case $3 = $day 
    $now = 1
Case $4 = $day 
    $now = 1
Case $5 = $day 
    $now = 1
Case $6 = $day 
    $now = 1
Case $7 = $day 
    $now = 1
EndSelect
EndFunc

Select
Case StringRegExp($line1, "Sunday") = 1 
    $1 = 1
Case StringRegExp($line1, "Monday") = 1 
    $2 = 2
Case StringRegExp($line1, "Tuesday") = 1 
    $3 = 3
Case StringRegExp($line1, "Wednesday") = 1 
    $4 = 4
Case StringRegExp($line1, "Thursday") = 1 
    $5 = 5
Case StringRegExp($line1, "Friday") = 1 
    $6 = 6
Case StringRegExp($line1, "Saturday") = 1 
    $7 = 7
EndSelect

    
Func _Time ($1, $2)
$4 = _ReadFileLines($2)
$number = $startime[2]
$delim = StringSplit($number, "-")
$quators = $delim[0] & ":" & $delim[1]
If _DayMatch($now) = 1 Then
If $quators = $rightnow Then
Run($line1)
MsgBox(0,"title",$rightnow & $quators)
EndIf
EndIf
$vdub = IniRead("default.ini", "Capture", "vdub", "C:\Program Files\VirtualDub\vdub.exe")
WinWaitNotActive ($vdub)
EndFunc
Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

Alright, I did it. And a whole lot simpler.

; Created by Mikel Sevrel
; mikelsevrel <AT> gmail.com
; gafrost did most of it though
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>
; GUI
GUICreate("VDub Capture Scheduler", 400, 340)
GUICtrlCreateLabel("Channel Number", 10, 5, 150)
GUICtrlCreateLabel("Program Title", 10, 40, 150)
GUICtrlCreateLabel("Folder", 10, 75, 150)
GUICtrlCreateLabel("Device Name", 10, 110, 150)
GUICtrlCreateLabel("VDUB Location", 10, 145, 150)
GUICtrlCreateLabel("Start Time (Format 00:00AM)", 10, 180, 150)
GUICtrlCreateLabel("Length in Minutes", 10, 215, 150)

; DEFAULTS
If FileExists("default.ini") = 1 Then
    $inivar = IniReadSection("default.ini", "Capture")
    
Else
    MsgBox(0, "", "Default Configuration File Created")
    IniWrite("default.ini", "Capture", "channel", "31")
    IniWrite("default.ini", "Capture", "title", "Capture")
    IniWrite("default.ini", "Capture", "folder", "C:\My Videos")
    IniWrite("default.ini", "Capture", "device", "bt878")
    IniWrite("default.ini", "Capture", "vdub", "C:\Program Files\VirtualDub\virtualdub.exe")
    IniWrite("default.ini", "Capture", "startime", "7:00PM")
    IniWrite("default.ini", "Capture", "duration", "60")
    IniWrite("default.ini", "Capture", "days", "Monday")
    $inivar = IniReadSection("default.ini", "Capture")
    
EndIf

; INPUT

$channel = GUICtrlCreateInput($inivar[1][1], 10, 20, 180, 20)
$title = GUICtrlCreateInput($inivar[2][1], 10, 55, 180, 20)
$folder = GUICtrlCreateInput($inivar[3][1], 10, 90, 180, 20)
$device = GUICtrlCreateInput($inivar[4][1], 10, 125, 180, 20)
$vdub = GUICtrlCreateInput($inivar[5][1], 10, 160, 180, 20)
$startime = GUICtrlCreateInput($inivar[6][1], 10, 195, 180, 20)
$duration = GUICtrlCreateInput($inivar[7][1], 10, 230, 180, 20)

$every = GUICtrlCreateListView("radio", 200, 20, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_LIST, $LVS_LIST)
GUICtrlCreateListViewItem("Weekly", $every)
$ListView = GUICtrlCreateListView("Day", 200, 70, 180, 140, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 175)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
GUICtrlCreateListViewItem("Sunday", $ListView)
GUICtrlCreateListViewItem("Monday", $ListView)
GUICtrlCreateListViewItem("Tuesday", $ListView)
GUICtrlCreateListViewItem("Wednesday", $ListView)
GUICtrlCreateListViewItem("Thursday", $ListView)
GUICtrlCreateListViewItem("Friday", $ListView)
GUICtrlCreateListViewItem("Saturday", $ListView)




$schedule = GUICtrlCreateButton("Schedule", 3, 270, 180, 20)
$cancel = GUICtrlCreateButton("Close", 200, 270, 180, 20)
$ini = GUICtrlCreateButton("Save Settings", 3, 298, 380, 20)

GUISetState()


Func _ConvertToMilTime($s_date)
    If StringUpper(StringMid($s_date, StringLen($s_date) - 1, 2)) = "PM" Then
        $s_date = StringSplit(StringTrimRight($s_date, 2), ":")
        If Number($s_date[1]) < 12 Then $s_date[1] = Number($s_date[1]) + 12
    Else
        $s_date = StringSplit(StringTrimRight($s_date, 2), ":")
        If Number($s_date[1]) == 12 Then $s_date[1] = "0"
    EndIf
    Return StringFormat("%02d:%02d", $s_date[1], $s_date[2])
EndFunc  ;==>_ConvertToMilTime

; Script
While 1
    $msg = GUIGetMsg()
    $cap = " /capture /capchannel " & GUICtrlRead($channel)
    $capdev = " /capdevice " & GUICtrlRead($device)
    $cmdlines = " /capfile """ & GUICtrlRead($folder) & "\" & GUICtrlRead($title) & ".avi"" /capstart " & GUICtrlRead($duration)
    Select
        Case $msg = $ini
            MsgBox(0, "Saved", "Defaults Saved")
            
            IniWrite("default.ini", "Capture", "channel", GUICtrlRead($channel))
            IniWrite("default.ini", "Capture", "title", GUICtrlRead($title))
            IniWrite("default.ini", "Capture", "folder", GUICtrlRead($folder))
            IniWrite("default.ini", "Capture", "device", GUICtrlRead($device))
            IniWrite("default.ini", "Capture", "vdub", GUICtrlRead($vdub))
            IniWrite("default.ini", "Capture", "startime", GUICtrlRead($startime))
            IniWrite("default.ini", "Capture", "duration", GUICtrlRead($duration))
        Case $msg = $schedule
            Local $days, $is_Checked
            For $x = 0 To _GUICtrlListViewGetItemCount ($ListView) - 1
                $is_Checked = _GUICtrlListViewGetCheckedState ($ListView, $x)
                If ($is_Checked <> $LV_ERR) Then
                    If ($is_Checked) Then
                        $days = $days & _GUICtrlListViewGetItemText ($ListView, $x) & ","
                    EndIf
                EndIf
            Next
            $days = StringTrimRight($days, 1); trim off the extra comma
            $command = GUICtrlRead($vdub) & $cap & $capdev & $cmdlines
            FileWriteLine(@WorkingDir & "\command.txt", $command & ":::" & _ConvertToMilTime(GUICtrlRead($startime)) & ":::" & $days)
            MsgBox(0, "Schedule Saved", "Your Program Has Been Scheduled")
            Run(@WorkingDir & "\scheduler.exe")
        Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

And the scheduler

; Created by Mikel Sevrel
; mikelsevrel <AT> gmail.com
#include <Date.au3>
#include <File.au3>
#include <Array.au3>
$file = FileRead(@WorkingDir & "\src\command.txt")


$split = StringSplit($file, ":::", 1)
$vdub = $split[1]
$startime = $split[2]
$line = $split[3]
Select
    Case StringRegExp($line, "Sunday") = 1
        _Capture()
    Case StringRegExp($line, "Monday") = 1
        _Capture()
    Case StringRegExp($line, "Tuesday") = 1
        _Capture()
    Case StringRegExp($line, "Wednesday") = 1
        _Capture()
    Case StringRegExp($line, "Thursday") = 1
        _Capture()
    Case StringRegExp($line, "Friday") = 1
        _Capture()
    Case StringRegExp($line, "Saturday") = 1
        _Capture()
EndSelect

Func _Capture()
While 1
$rightnow = @HOUR & ":" & @MIN & ":" & @SEC
$string = FileRead ($rightnow)
    If $startime & ":00" = $rightnow Then
        RunWait($vdub)
        WinWaitNotActive($vdub)
    EndIf
    WEnd
EndFunc  ;==>_Capture

Coming soon....

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