I want to be able to run a script that will ask the user for a time and date and then wait for that time to launch a video recording program.
I am doing this now by simply using the Run When function which then launches the macro and thus the video recording program at the appropriate time. But I want to incorporate all of this in a script so the user can specify the run time, duration of the recording, title etc. Is there an elegant way of handling the time? So basically the macro is starting off, getting some inputted info from the user, then waiting until the time/date equal the specified value before resuming.
Any ideas appreciated.
Bob
Triggering an action at a specified time
Moderators: JRL, Dorian (MJT support)
In this script the macro compares the current time with the input time when to start recording. When both times are the same the macro goes to the Record part of the script. It's impossible to help with this step without knowing anything about the recording program you are using. It's probably a matter of a few mouse moves and or keystrokes clicks to start recording. After the recording program is started the script compares the input time (in minutes) with the time elapsed, when the time is reached it will jump to the stop recording part of the script. Again, it's impossible to help with this next step without knowing anything about the recording program you are using. It's probably a matter of a few mouse moves and clicks or keystrokes to stop recording.
Check out the help file to help you with mousemove, pressing keyboard keys, mouse clicks etc.
This script should at least get you started
I hope this was helpful
Check out the help file to help you with mousemove, pressing keyboard keys, mouse clicks etc.
This script should at least get you started

Code: Select all
Dialog>Dialog1
Caption=My Dialog
Width=261
Height=175
Top=CENTER
Left=CENTER
Max=1
Min=1
Close=1
Resize=1
Label=Enter Hour Enter Min,8,64,true
Label=Recording Duration in Min,8,104,true
Label=Current Time:,8,8,true
Label=Enter Start Time in H && M,8,24,true
Label=Status: Waiting,152,88,true
Label= ,8,120,true
RadioGroup=msRadioGroup1,Select AM or PM,144,8,97,65,AM%CRLF%PM,0
Edit=msEdit1,8,40,57,9
Edit=msEdit2,72,40,57,01
Edit=msEdit3,48,80,41,5
EndDialog>Dialog1
Show>Dialog1
Label>ActionLoop
WAIT>0.05
//This puts the user input time into one variable
LET>InputTime=%Dialog1.msEdit1%:%Dialog1.msEdit2%:00 %Dialog1.msRadioGroup1%
GetTime>CurrentTime
LET>Dialog1.msLabel2=Current Time: %CurrentTime%
/*
Compare current time with the time the users input time
Start recording when the time is the same
*/
IF>%CurrentTime%=%InputTime%,Record
GetDialogAction>Dialog1,Result
IF>Result=2,ExitProgram
goto>ActionLoop
Label>Record
/*
Now run the recording program using ExecuteFile> or Run Program>
Example: Run Program>c:\Program Files\Program Folder\Program Name.exe
You will probably need to click a few options to start recording after the program launches.
It's impossible to help you with that without knowing anything about the program.
*/
LET>Dialog1.msLabel4=Status: Recording
ResetDialogAction>Dialog1
LET>SecRecordTimer=0
LET>MinRecordTimer=0
Label>RecordActionLoop
WAIT>0.5
GetTime>CurrentTime
LET>Dialog1.msLabel2=Current Time: %CurrentTime%
ResetDialogAction>Dialog1
GetDialogAction>Dialog1,Result
IF>Result=2,ExitProgram
WAIT>0.5
GetTime>CurrentTime
LET>Dialog1.msLabel2=Current Time: %CurrentTime%
ResetDialogAction>Dialog1
//Add Seconds
ADD>SecRecordTimer,1
LET>Dialog1.msLabel5=Time Elapsed %MinRecordTimer% Min:%SecRecordTimer% Sec
ResetDialogAction>Dialog1
IF>SecRecordTimer=60
//When 60 sec reached add 1 to min
ADD>MinRecordTimer,1
LET>SecRecordTimer=0
LET>Dialog1.msLabel5=Time Elapsed %MinRecordTimer% Min:%SecRecordTimer% Sec
ResetDialogAction>Dialog1
//Stop recording if min added equals users input
IF>MinRecordTimer=%Dialog1.msEdit3%,StopRecording
ENDIF
GetDialogAction>Dialog1,Result
IF>Result=2,ExitProgram
goto>RecordActionLoop
Label>StopRecording
/*
Recording Session Completed
It's impossible to help you with this step without knowing anything about the recording program.
*/
label>ExitProgram
Triggering at specified time
Thanks for the very comprehensive reply! I wasn't expecting a whole script. I hope others might find it useful too.
My only concern is the processing involved in continuously checking time.
The other method I was considering is establishing Current Time at the moment the input is received and comparing that to the future time entered, calculating the difference and then having it Wait for that period of time.
I have a script for operating the program, naming the file etc. So no problem there.
Again thanks. I'll be giving this a try.
Bob
My only concern is the processing involved in continuously checking time.
The other method I was considering is establishing Current Time at the moment the input is received and comparing that to the future time entered, calculating the difference and then having it Wait for that period of time.
I have a script for operating the program, naming the file etc. So no problem there.
Again thanks. I'll be giving this a try.
Bob
R Bishop