Jump to content
Sign in to follow this  
Zane

loop inside loop

Recommended Posts

Zane

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
ChaosCookie

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
Zane

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.