Global $fWork, $iCount, $iStart, $fExit
HotKeySet('{F10}', '_Work_or_No')
HotKeySet('{F11}', '_Exit')
$iStart = TimerInit()
;While Not $fExit
Do
If TimerDiff($iStart) > 1000 Then
_My_Func()
$iStart = TimerInit()
EndIf
Sleep(100)
Until $fExit
;WEnd
ConsoleWrite('exit' & @LF)
Func _Work_or_No()
$fWork = Not $fWork
If Not $fWork Then $iCount = 0
EndFunc ;==>_Work_or_No
Func _Exit()
$fExit = True
EndFunc ;==>_Exit
Func _My_Func()
If Not $fWork Then Return
$iCount += 1
ConsoleWrite($iCount & ' --> что-то делаем.' & @LF)
EndFunc ;==>_My_Func