You mean something like this? #include <Misc.au3> Global $bSTOP = False HotKeySet('{Esc}', '_FNC_EXIT') HotKeySet('{Enter}', '_FNC_STOP') While 1 If _IsPressed('02') Then _FNC_TIME() Sleep(50) WEnd Func _FNC_STOP() If $bSTOP = False Then $bSTOP = True Else $bSTOP = False EndIf EndFunc Func _FNC_TIME() $bSTOP = False Local $hTIME = TimerInit(), $hDIFF = 0