Sign in to follow this  
Followers 0
acer20006

hotkey stoped the while

5 posts in this topic

i have question about hotkeyset and how to combine it with while at script that had already a while _ >> make it simply :D

look at the code

HotKeySet("{end}", "msg2")
HotKeySet("{ESC}", "Terminate")
;;;; Body of program would go here ;;;;
While 1
        MsgBox (0,"msg box","1st while")
WEnd
;;;;;;;;

Func msg2()
    While 2
        MsgBox (0,"msg box","2nd while")
    WEnd
EndFunc
Func Terminate()
    Exit
EndFunc

my script already have a while 1

but when i push end (hotkey) while 2 start working and while 1 stoped

>>>>>> so how to make script run the both whiles

Share this post


Link to post
Share on other sites



You can't have two loops running at the same time, you could look into AdlibRegister() though.


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

AutoIt is not multithreaded, so you can't do it like that, it would be more like:

HotKeySet("{end}", "msg2")
HotKeySet("{ESC}", "Terminate")

Local $iFlag = False

While 1
    MsgBox (0,"msg box","1st while")
    If $iFlag Then MsgBox (0,"msg box","2nd while")
WEnd

Func msg2()
    $iFlag = Not $iFlag
EndFunc

Func Terminate()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

All you need to do is make your one loop a bit smarter, and have a condition for if the first has been pressed.

Like this...

HotKeySet("{end}", "msg2")
HotKeySet("{ESC}", "Terminate")
;;;; Body of program would go here ;;;;
Global $seccondPressed=False
While 1
    ConsoleWrite("First Loop"&@CRLF)
    If $seccondPressed Then
        ConsoleWrite("Seccond Loop"&@CRLF)
    EndIf
    Sleep(15)
WEnd
;;;;;;;;

Func msg2()
    $seccondPressed = Not($seccondPressed)
EndFunc
Func Terminate()
    Exit
EndFunc

Edit: Oops, AdmiralAlkex beat me to it :D

Edited by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites

thx all _ i will find another way :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0