Sign in to follow this  
Followers 0
Zane

loop inside loop

4 posts in this topic

is there a way to do a loop in second plane without affecting the buttons?

for example:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 172, 53, 313, 377)
$Start = GUICtrlCreateButton("Start", 8, 16, 75, 25, $WS_GROUP)
$Stop = GUICtrlCreateButton("Stop", 88, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            $A = "0"
            Do 
                RegWrite ("HKEY_CURRENT_USER\Software\MyApplication", "testkey", "REG_SZ", "im a value")
            Until $A = "1"          
        Case $Stop
            Exit
    EndSwitch
WEnd

why i cant use the stop button , please giveme a solution

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

because your start-case is an infinite loop... what do you want to do with the var "A"?

If its meant to be some kind of iterator do it like this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 172, 53, 313, 377)
$Start = GUICtrlCreateButton("Start", 8, 16, 75, 25, $WS_GROUP)
$Stop = GUICtrlCreateButton("Stop", 88, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            $A = 0
            Do
                $A += 1
                RegWrite ("HKEY_CURRENT_USER\Software\MyApplication", "testkey", "REG_SZ", "im a value")
            Until $A = 1        
        Case $Stop
            Exit
    EndSwitch
WEnd

ah and no you cant run 2 loops at the same time... but you can can manage them to run after each other with Adlib/_Adlib!

Edited by ChaosCookie

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ah and no you cant run 2 loops at the same time... but you can can manage them to run after each other with Adlib/_Adlib!

tank you , just was i needed

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 172, 53, 313, 377)
$Start = GUICtrlCreateButton("Start", 8, 16, 75, 25, $WS_GROUP)
$Stop = GUICtrlCreateButton("Stop", 88, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start   
            AdlibRegister ("Test1")
        Case $Stop
            AdlibUnRegister ("Test1")
            Exit
    EndSwitch
WEnd
 
Func Test1()
    RegWrite ("HKEY_CURRENT_USER\Software\MyApplication", "testkey", "REG_SZ", "im a value")
EndFunc
Edited by Zane

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