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
}
}
}