; Example Autohotkey script to demonstrate controlling eStopWatch via AHK. ; Version 1.0 ; Released 2009-05-07 ; For this example we will be using the following global hotkeys. ; Please ensure they are not already used by another application ; or another AHK script on your system (or change the hotkeys): ; Win+F2: start (eStopWatch must already be open, but timer must not be running) ; Win+F3: pause ; Win+F4: resume ; Win+F5: stop ; Win+F6: quit (exit eStopWatch) ; Win+F7: smart start/pause/resume ; Win+F8: start the timer from a specified value ; Win+F9: set the timer mode (count up or count down) ; Win+F10: check current state of eStopWatch (is it idle? running? paused?) ; Win+F11: check the current timer value, in seconds ; Win+F12: check the current timer mode (up or down) ; ################################# ; ### 1. Controlling eStopWatch ### ; ################################# ; The message number to send to eStopWatch is 1025. ; To control eStopWatch, use the following wParam values: ; 1 - start ; 2 - pause ; 3 - resume ; 4 - stop ; 5 - quit ; 6 - "smart" message: will start the timer if eStopWatch is idle, ; pause if it is running, or resume if it is paused. ; (It will not issue the Stop command). SetTitleMatchMode 2 ; match anywhere in window title text ; Win+F2: Start eStopWatch timer #F2:: IfWinExist Ethervane StopWatch PostMessage 1025, 1, 0,, Ethervane StopWatch return ; Win+F3: Pause eStopWatch timer #F3:: IfWinExist Ethervane StopWatch PostMessage 1025, 2, 0,, Ethervane StopWatch return ; Win+F4: Resume eStopWatch timer #F4:: IfWinExist Ethervane StopWatch PostMessage 1025, 3, 0,, Ethervane StopWatch return ; Win+F5: Stop eStopWatch timer #F5:: IfWinExist Ethervane StopWatch PostMessage 1025, 4, 0,, Ethervane StopWatch return ; Win+F6: Quit eStopWatch timer #F6:: IfWinExist Ethervane StopWatch PostMessage 1025, 5, 0,, Ethervane StopWatch return ; Win+F7: Smart eStopWatch control #F7:: IfWinExist Ethervane StopWatch PostMessage 1025, 6, 0,, Ethervane StopWatch return ; Win+F8: Start stopwatch from a specific value ; In this case, use lParam to send the initial timer value (in seconds). ; We'll use the initial value of 120 seconds in the example. #F8:: IfWinExist Ethervane StopWatch PostMessage 1025, 7, 120,, Ethervane StopWatch return ; Win+F9: Set stopwatch mode ( count up or count down) ; In this case, use lParam to send the mode value: ; 1 - count up ; 2 - count down ; The example below sets the mode to "Count down". ; (Note that the stopwatch must be idle for this to work). #F9:: IfWinExist Ethervane StopWatch PostMessage 1025, 8, 2,, Ethervane StopWatch return ; ############################## ; ### 2. Querying eStopWatch ### ; ############################## ; Another way to use messages is to check the current state ; of eStopWatch or the current timer value. ; To do this, use message number 1026 and the following wParam values: ; 1 - check current state (idle, running, paused, suspended) ; 2 - ask for current timer value (in seconds) ; Note that we must use SendMessage instead of PostMessage, ; in order to receive a reply. ; Win+F10: Check the current state of eStopWatch ; Note that the message number is 1026 here. ; Responses are as follows: ; 1 - idle ; 2 - running ; 3 - paused ; 4 - suspended ; 999 - unknown state or error #F10:: IfWinExist Ethervane StopWatch { SendMessage 1026, 1, 0,, Ethervane StopWatch swstate := "Unknown" if ErrorLevel <> FAIL { if ( ErrorLevel = 1 ) { swstate := "Idle" } else if ( ErrorLevel = 2 ) { swstate := "Running" } else if ( ErrorLevel = 3 ) { swstate := "Paused" } else if ( ErrorLevel = 4 ) { swstate := "Suspended" } MsgBox, eStopwatch state is: %swstate% (%ErrorLevel%) } } return ; Win+F11: Check the current VALUE of the timer. ; The value is returned in seconds. ; If eStopWatch is idle (has been stopped), the last ; recorded value will be returned. (I.e., the returned ; value is always the value eStopWatch itself displays). #F11:: IfWinExist Ethervane StopWatch { SendMessage 1026, 2, 0,, Ethervane StopWatch if ErrorLevel <> FAIL { MsgBox, eStopwatch timer value is: %ErrorLevel% seconds } } return ; Win+F12: Check the current MODE of the timer (up or down). ; The values returned are: ; 1 - mode is "up" (default) ; 2 - mode is "down" #F12:: IfWinExist Ethervane StopWatch { SendMessage 1026, 3, 0,, Ethervane StopWatch swmode = "Unknown" if ErrorLevel <> FAIL { if ( ErrorLevel = 1 ) { swmode = "Count Up" } else if ( ErrorLevel = 2 ) { swmode = "Count Down" } MsgBox, eStopwatch mode is: %swmode% } } return ; ########################################################## ; # That's all! You should probably unload this script now # ; # to release all the hotkeys we have registered here :) # ; ##########################################################