First , that is much better solution , thanks
Second , let make the problem a bit harder..
I want to exit the lop - in the minute the hotkey was pressed - and not only in the beggining of the lop
the global flag is good and elegant when I have one simple command . but if the proccess is more complecated then I need to had "if ($flag == 1)" before each command or at list before each major command ( for example in command 3 )
When the program is become long and complicate the flag is not such nice solution
Global $flag
Func Function1()
HotKeySet("^p", "Function2")
$flag = 1
while ( $flag == 1)
;;set of commands 1
;;set of commands 2
if ( $flag == 1) then
;;set of commands 3 ;; that ugly
Endif
;;set of commands 4
Wend
HotKeySet("^p", "")
EndFunc
Func Function2()
$flag = 0
EndFunc