Не обратил внимания на то, что процессор сильно нагружался, но с паузой, кажется, такого нет. Вариант от teadrinker выглядит лаконичнее, разницы в работе, на первый взгляд, не замечаю. Разве что, нет отображения стечения времени в ToolTip. А это тоже, пожалуй, необходимый функционал. Но лучше не в ToolTip. Я попробовал взять визуальное оформление таймера из этого сценария (кнопка Start/Stop должна ставить на паузу ожидание активности блокнота), но опять же, не получается прикрутить должным образом:
#SingleInstance FORCE
#NoEnv
SetBatchLines, -1
; Some variables
ElapsedTime := A_YYYY ; initialize ElapsedTime, it will be treated as YYYY0101000000
BalanceTime := 0 ; initialize BalanceTime (time not counted yet)
; Tray menu
Menu, Tray, NoStandard ; clear the tray menu for customizing
Menu, Tray, Add, Quit, AppExit ; add item "Quit" to call AppExit
Menu, Tray, Default, Quit ; double-click on the tray icon will call "Quit"
Menu, Tray, Tip, % " AHK short-time Stopwatch " ; add a nice tool tip
; GUI
Gui, +LastFound ; Added
WinSet, TransColor, FFFFFF 100 ; Added
;
Gui, +ToolWindow -Caption +AlwaysOnTop ; made some changes for relative positioning and sizing
Gui, Margin, 0, 0 ; http://l.autohotkey....ui.htm#Position
Gui, Font, S32 CDefault Bold, Verdana
Gui, Add, Text, Center vDisplayTime, 00:00
Gui, Font, S12, Verdana
Gui, Add, Button, x+0 yp w60 hp vBtnStartStop gStartStop Default, Start`nStop
Gui, Add, Button, x+0 yp w60 hp vBtnReset gReset, Reset
Gui, Add, Button, x+0 yp w60 hp gAppExit, Quit
Gui, Show, , Stop Watch
Gosub, StartStop
Return
; Exit label
AppExit:
ExitApp
; BtnStartStop label
StartStop:
GuiControlGet, BtnStartStop ; get the caption of the button
If (BtnStartStop = "Start`nStop") { ; if it is "Start`nStop"
StartTickCount := A_TickCount - BalanceTime ; initialize StartTickCount
SetTimer, StopWatch, 10 ; start the timer called every 10 ms to be accurate
GuiControl, , BtnStartStop, Stop ; set the caption to Stop
} Else { ; it should be "Stop"
BalanceTime := A_TickCount - StartTickCount ; memorize the balance time not counted yet
SetTimer, StopWatch, Off ; stop the timer
GuiControl, , BtnStartStop, Start`nStop ; set the caption to "Start`nStop"
}
Return
; BtnReset label
Reset:
SetTimer, StopWatch, Off ; stop the timer
GuiControl, , BtnStartStop, Start`nStop ; set the caption of BtnStartStop to "Start`nStop"
GuiControl, , DisplayTime, 00:00 ; initialize DisplayTime
ElapsedTime := A_YYYY ; initialize ElapsedTime, it will be treated as YYYY0101000000
BalanceTime := 0 ; initialize BalanceTime
GuiControl, Focus, BtnStartStop ; set the focus on BtnStartStop
GuiControl, -Default, BtnReset ; remove the BS_DEFPUSHBUTTON (default) style
GuiControl, +Default, BtnStartStop ; set the BS_DEFPUSHBUTTON (default) style
Return
; Timer routine
StopWatch:
If ((A_TickCount - StartTickCount) >= 1000) { ; if current tickcount - StartTickCount >= 1000 (i.e. 1 second)
StartTickCount += 1000 ; add 1000 ms (1 second) to StartTickCount
ElapsedTime += 1, S ; add 1 second to ElapsedTime
FormatTime, DisplayTime, %ElapsedTime%, mm:ss ; format ElapsedTime to mm:ss
GuiControl, , DisplayTime, %DisplayTime% ; update DisplayTime
}
Return
Помогите это сделать, пожалуйста.