DonationCoder.com Software > Post New Requests Here
IDEA: "WaitAndSend" - timer/keyboard macro combo program...
Onesimus Prime:
Okay, in the last section I'm trying to make the floating tooltip that continuously counts down optional.
--- ---countdown(p_count="") {
countdown_time:=p_count
countdown_date=16010101
countdown_date+=%countdown_time%, s
Loop {
If (countdown_date >= 16010101010000){
FormatTime, mmss, %countdown_date%, hh:mm:ss
}else{
FormatTime, mmss, %countdown_date%, mm:ss
}
;msgbox %countdown_date%`n%hhmmss%
;//SB_SetText(mmss, 2)
global floatingtimer
ifequal, %floatingtimer%, 1, Tooltip, %mmss%, 2000,14
Menu,Tray,Tip,Time Remaining: %mmss%
Sleep, 1000
countdown_date+=-1, s
;//IfLess, countdown_date, 16010101, break
if (A_Index>countdown_time) {
break
}
}
}
If I read the variable with
IniRead, floatingtimer, %applicationname%.ini, Settings, floatingtimer
then why doesn't
global floatingtimer
ifequal, %floatingtimer%, 1, Tooltip, %mmss%, 2000,14
seem to have any effect? The variable has the right value, but the timer tooltip still isn't showing up...
*yet another edit*
Okay, I think I got it - not because I necessarily understand what's going on, but because I looked at the .chm a bit more and kept on trying things until something worked!
--- ---applicationname=WaitAndSend
versionnumber=0.6
; 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 https://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=
}
IniRead, floatingtimer, %applicationname%.ini, Settings, floatingtimer
IniRead, ctimer, %applicationname%.ini, Settings, ctimer
IniRead, targetprogram, %applicationname%.ini, Settings, targetprogram
IniRead, keypresses, %applicationname%.ini, Settings, keypresses
IniRead, endmsg, %applicationname%.ini, Settings, endmsg
CoordMode, ToolTip, Screen
tt = %1%
if not tt
tt = %ctimer%
;tt = 120
time := Convert_Milliseconds(tt)
Sec := (tt * 60)
SetTimer, nMessage, %time%
countdown(Sec)
return
nMessage:
SetTimer, nMessage, Off
WinActivate %targetprogram%
WinWaitActive %targetprogram%
send %keypresses%
sleep 1000
ifequal, endmsg, 1, MsgBox Your keypresses have been sent to the requested program.
;Gui, +MinimizeBox
;GUi, -sysmenu
;gui, +toolwindow
;Gui, Add, Button, w130, DONE - hit 'O' for OK
;Gui, Show, x1 y1, %applicationname% %versionnumber%
;KeyWait, o, D
;Tooltip ,, 2, 980
;Gui Destroy
exitapp
Convert_MilliSeconds(time,MS = 1000,M = 60)
{
return MS*M*time
}
countdown(p_count="") {
countdown_time:=p_count
countdown_date=16010101
countdown_date+=%countdown_time%, s
Loop {
If (countdown_date >= 16010101010000){
FormatTime, mmss, %countdown_date%, hh:mm:ss
}else{
FormatTime, mmss, %countdown_date%, mm:ss
}
;msgbox %countdown_date%`n%hhmmss%
;//SB_SetText(mmss, 2)
global floatingtimer
ifequal, floatingtimer, 1, Tooltip, %mmss%, 2000,14
Menu,Tray,Tip,Time Remaining: %mmss%
Sleep, 1000
countdown_date+=-1, s
;//IfLess, countdown_date, 16010101, break
if (A_Index>countdown_time) {
break
}
}
}
Onesimus Prime:
Heh - I'm making my own snax! :lol:
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...
--- ---applicationname=WaitAndSend
versionnumber=0.5.4
; 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 https://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, ., R
stringLeft, 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=
}
IniRead, floatingtimer, %CurrentScriptNm%.ini, Settings, floatingtimer
IniRead, ctimer, %CurrentScriptNm%.ini, Settings, ctimer
IniRead, targetprogram, %CurrentScriptNm%.ini, Settings, targetprogram
IniRead, keypresses, %CurrentScriptNm%.ini, Settings, keypresses
IniRead, endmsg, %CurrentScriptNm%.ini, Settings, endmsg
CoordMode, ToolTip, Screen
tt = %1%
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%
}
}
if not tt
tt = %ctimer%
;tt = 120
time := Convert_Milliseconds(tt)
Sec := (tt * 60)
SetTimer, nMessage, %time%
countdown(Sec)
return
nMessage:
SetTimer, nMessage, Off
WinActivate %targetprogram%
WinWaitActive %targetprogram%
send %keypresses%
sleep 1000
ifequal, endmsg, 1, MsgBox Your keypresses have been sent to the requested program.
;Gui, +MinimizeBox
;GUi, -sysmenu
;gui, +toolwindow
;Gui, Add, Button, w130, DONE - hit 'O' for OK
;Gui, Show, x1 y1, %CurrentScriptNm% %versionnumber%
;KeyWait, o, D
;Tooltip ,, 2, 980
;Gui Destroy
exitapp
Convert_MilliSeconds(time,MS = 1000,M = 60)
{
return MS*M*time
}
countdown(p_count="") {
countdown_time:=p_count
countdown_date=16010101
countdown_date+=%countdown_time%, s
Loop {
If (countdown_date >= 16010101010000){
FormatTime, mmss, %countdown_date%, hh:mm:ss
}else{
FormatTime, mmss, %countdown_date%, mm:ss
}
;msgbox %countdown_date%`n%hhmmss%
;//SB_SetText(mmss, 2)
global floatingtimer
ifequal, floatingtimer, 1, Tooltip, %mmss%, 2000,14
Menu,Tray,Tip,Time Remaining: %mmss%
Sleep, 1000
countdown_date+=-1, s
;//IfLess, countdown_date, 16010101, break
if (A_Index>countdown_time) {
break
}
}
}
Navigation
[0] Message Index
[*] Previous page
Go to full version