Would it be possible to have a program that, at a customizable system time or in 'x' mintes/seconds, makes sure that program 'y' is focused and sends it user-definable keystrokes? And it'd be nice if this were "portable," not writing outside its own directory.

The situation prompting this request...I'm recording a professor's lectures, and sometimes have to ditch class and leave the computer recording when he goes over-time. After my next class, I come back and stop the recording--but this means that there's well over an hour of silence at the end of the recorded file! And, even compressed, that takes up HD space, sometimes more than I have. So I was thinking it would be nice to have a program do something like, in my case, "in 10 minutes, switch to Reaper (going off of window titles?) and send key combination Ctrl+R (or whatever it is) to stop recording." (I guess by default, space is stop, but the possibility for key combinations--even a few combos in succession, maybe with "sleep" pauses in between, would maximize flexibility for other possible uses)

If anyone can help with this without too much trouble (or knows of something similar and portable), it'd be much appreciated! Thanks!

This is the perfect scenario for a simple personal AutoHotkey script. http://www.autohotkey.com The commands you're going to want to look up are Sleep, Send, WinActivate, and WinWaitActive. If you're not able to write it yourself, let us know and we'll help out.

I so should have been sleeping... *chagrined*Okay, I first wrote a simple one like what you described, skwire--about 4 lines is all it takes, I didn't realize it'd be so simple! But then I couldn't leave well enough alone... I did a forum search, grabbing the countdown timer code from http://www.donationc...ex.php?topic=14895.0 and integrating the use of an .ini file (thanks to Skrommel's stuff), and the below is the (seemingly working) monstrosity that resulted :

IfNotExist,%applicationname%.ini{ ini=[Settings] ini=%ini%`n ini=%ini%`nctimer=20 ini=%ini%`n `; This sets the countdown, unless it is over-ridden by

launching the script with a numeric parameter. ini=%ini%`n `; It is measured in minutes (and decimals are valid). ini=%ini%`n ini=%ini%`ntargetprogram=ahk_class REAPERwnd ini=%ini%`n `; this is the Title or Class of the window of the target

program, the program that you wish to send the below keystrokes to. ini=%ini%`n `; By default, this line includes "ahk_class REAPERwnd",

summoning a window with the class matching the REAPER recording program. ini=%ini%`n ini=%ini%`nkeypresses={Space} ini=%ini%`n `;the keystrokes here will be sent to the program listed above.

Your options, and the various formatting restrictions, are viewable at

http://www.autohotkey.com/docs/commands/Send.htm ini=%ini%`n `; By default, this line simulates a press of the Spacebar

You were right about a "locked" computer--it seems to wait until the computer is unlocked before executing the after-timer stuff. One workaround, I guess, might be to use KidSafe Portable to "lock" the computer instead. "Windows + L can cut off some processes (e.g. it always pauses my virus scanner and media player, and turns off my Internet); KidSafe doesn’t do that" (according to a quote here).

; by Onesimus Prime; 2009; For now, right-click on the tray icon to exit...

; Countdown timer code (which is the majority of what's below) from http://www.donationcoder.com/forum/index.php?topic=14895.0; Some .ini-related code from Skrommel's templates

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.SendMode Input ; Recommended for new scripts due to its superior speed and reliability.SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.#persistent

IfNotExist,%applicationname%.ini{ ini=[Settings] ini=%ini%`n ini=%ini%`nfloatingtimer=0 ini=%ini%`n `; 0 is false (no), 1 is true (yes). ini=%ini%`n `; Even without a floating timer, you can mouse over the tray icon to get the current countdown. ini=%ini%`n ini=%ini%`nctimer=20 ini=%ini%`n `; This sets the countdown, unless it is over-ridden by launching the script with a numeric parameter. ini=%ini%`n `; It is measured in minutes (and decimals are valid). ini=%ini%`n ini=%ini%`ntargetprogram=ahk_class REAPERwnd ini=%ini%`n `; this is the Title or Class of the window of the target program, the program that you wish to send the below keystrokes to. ini=%ini%`n `; By default, this line includes "ahk_class REAPERwnd", summoning a window with the class matching the REAPER recording program. ini=%ini%`n ini=%ini%`nkeypresses={Space} ini=%ini%`n `;the keystrokes here will be sent to the program listed above. Your options, and the various formatting restrictions, are viewable at http://www.autohotkey.com/docs/commands/Send.htm ini=%ini%`n `; By default, this line simulates a press of the Spacebar(using {Space}), which (by Reaper's defaults) toggles "play" and "stop" (and thus can be used to stop recording!) ini=%ini%`n `; You could also use {CTRLDOWN}r{CTRLUP} to send Ctrl+R, Reaper's default key combo to START recording. ini=%ini%`n ini=%ini%`nendmsg=0 ini=%ini%`n `; This determines whether to show a message box after sending the keypresses, or simply to exit quietly. ini=%ini%`n `; 0 is false (no MsgBox), 1 is true (yes). FileAppend,%ini%,%applicationname%.ini ini=}

You define which keypresses to send to which program in the .ini file (generated on first run). You can copy & rename the .exe or script, have a matching-named .ini file (also automagically generated), and therefore run multiple unique instances at the same time.

There are 3 ways to set the countdown timer 'til when the above-mentioned keypresses are sent. In order of precedence:1) command-line parameter (I use this script through Executor); 2) user input via initial input box; 3) the 'ctimer' field in the .ini file.

Enjoy!*edit* I hope to have an actual icon for this, maybe by sometime next week...

; by Onesimus Prime; 2010; For now, right-click on the tray icon to exit...

; Countdown timer code (which is the majority of what's below) from http://www.donationcoder.com/forum/index.php?topic=14895.0; Some .ini-related code from Skrommel's templates

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.SendMode Input ; Recommended for new scripts due to its superior speed and reliability.SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.#persistent

; gets current script name and 'ditches' the file extension so that each script instance can have its own .ini file...CurrentScriptNm=%A_ScriptName%stringGetPos, WhereExtension, CurrentScriptNm, ., RstringLeft, CurrentScriptNm, CurrentScriptNm, WhereExtension; Msgbox %CurrentScriptNm% ;error-checking

IfNotExist,%CurrentScriptNm%.ini{ ini=[Settings] ini=%ini%`n ini=%ini%`nfloatingtimer=1 ini=%ini%`n `; 0 is false (no), 1 is true (yes). ini=%ini%`n `; Even without a floating timer, you can mouse over the tray icon to get the current countdown. ini=%ini%`n ini=%ini%`nctimer=20 ini=%ini%`n `; This sets the countdown timer (in minutes), unless it is over-ridden by launching the script with a numeric parameter or by entering a number into the program's initial input box. ini=%ini%`n `; Therefore the order of precedence is 1) command-line parameter; 2) user input via initial input box; 3) the above 'ctimer' field in this .ini file. ini=%ini%`n `; It is measured in minutes (and decimals are valid). ini=%ini%`n ini=%ini%`ntargetprogram=ahk_class mp3DCWndClass ini=%ini%`n `; This is the Title or Class of the window of the target program, the program that you wish to send the below keystrokes to. ini=%ini%`n `; By default, this line includes "ahk_class mp3DCWndClass", summoning a window with the class matching mp3DirectCut (mp3DC). ini=%ini%`n `; Another option would be "ahk_class REAPERwnd", summoning a window with the class matching the REAPER recording program. ini=%ini%`n ini=%ini%`nkeypresses={Space} ini=%ini%`n `; The keystrokes here will be sent to the program listed above. Your options, and the various formatting restrictions, are viewable at http://www.autohotkey.com/docs/commands/Send.htm ini=%ini%`n `; By default, this line simulates a press of the Spacebar(using {Space}), which (by mp3DC's and Reaper's defaults) toggles "play" and "stop" (and thus can be used to stop recording!) ini=%ini%`n `; You could also use r{Space} to send r, then Space, which should (hopefully) start recording in mp3DC; ini=%ini%`n `; or {CTRLDOWN}r{CTRLUP} to send Ctrl+R, Reaper's default key combo to START recording. ini=%ini%`n ini=%ini%`nendmsg=0 ini=%ini%`n `; This determines whether to show a message box after sending the keypresses, or simply to exit quietly. ini=%ini%`n `; 0 is false (no MsgBox), 1 is true (yes). FileAppend,%ini%,%CurrentScriptNm%.ini ini=}

if not tt{ InputBox, InputMin, Enter timer length, `nPlease enter below how many minutes the timer `nshould be set for. (Decimals are okay.) `nIf this is left blank`, the value set via the .ini file `n(currently %ctimer% minutes) will be used.,,,185 if InputMin is number { tt = %InputMin% } }