Jump to content

Recommended Posts

Posted (edited)

Hello, I have this code :

#Region ### START Koda GUI section ### Form=
$mainwin = GUICreate("Custom MsgBox", 225, 80)
GUICtrlCreateLabel("SVP, Select one button.", 10, 10)
Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25)
Local $idNoo = GUICtrlCreateButton("NO", 80, 50, 65, 25)
Local $idExitt = GUICtrlCreateButton("Exit", 150, 50, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

WinMove ("[ACTIVE]", "", 1330, 0)

If Not @error Then
    $b =  0
    While 1
        
        Switch GUIGetMsg()

            Case $idExitt

            $iMenustate = GUICtrlRead($idNoo)
            $sMenutext = GUICtrlRead($idNoo, 1)

            If $iMenustate == "NO" Then

            MsgBox($MB_SYSTEMMODAL, "State and text of the menuitem", "state:" & $iMenustate & @CRLF & "text:" & $sMenutext)
            ;ExitLoop 
            EndIf 
        EndSwitch 
    WEnd
EndIf

Why when i try to click button NO but a button not working, i have try other but not working again.

Can PLZ help me.

TY

Edited by AutoDEV
Posted

here is an example

$choice = GUICreate("Custom MsgBox", 225, 80)
GUICtrlCreateLabel("Please select a button.", 10, 10)
Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25)
Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25)
Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25)
GUISetState(@SW_SHOW, $choice)

Local $iMsgBoxAnswer = 1, $bLoop = True

While $bLoop
    Switch GUIGetMsg()
        Case $idYess
            ConsoleWrite("$idYess=" & $idYess & @CRLF)

        Case $idNoo
            ConsoleWrite("$idNoo=" & $idNoo & @CRLF)

        Case $idExitt, -3 ;$GUI_EVENT_CLOSE
            ConsoleWrite("$idExitt=" & $idExitt & @CRLF)
            GUISetState(@SW_HIDE, $choice)
            $iMsgBoxAnswer = 0

    EndSwitch

    If $iMsgBoxAnswer = 1 Then ContinueLoop

    $iMsgBoxAnswer = MsgBox(4100, "MsgBox", "Are you sure you want to close the program?", 3)
    Select
        Case $iMsgBoxAnswer = 6 ;Yes
            ConsoleWrite("- bye bye" & @CRLF)
            $bLoop = False

        Case $iMsgBoxAnswer = 7 ;No
            ConsoleWrite("- Return to program" & @CRLF)
            $iMsgBoxAnswer = 1
            GUISetState(@SW_SHOW, $choice)

        Case $iMsgBoxAnswer = -1 ;Timeout
            ConsoleWrite("- Time is out, bye bye" & @CRLF)
            $bLoop = False

    EndSelect

WEnd

ConsoleWrite("End of program" & @CRLF)

 

I know that I know nothing

Posted (edited)

THX.

But i have one question.

How to read a input because with your code i show

$idExitt=50
- bye bye
End of program

What's 50 ?

And when i not click on button exit, a next code is blocked.

Please

Edited by AutoDEV
Posted (edited)

OK thank you.

I have one problem, youi have gui and uou close or not...

But i have one GUI and other code,

 

$choice = GUICreate("Custom MsgBox", 225, 80)
GUICtrlCreateLabel("Please select a button.", 10, 10)
Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25)
Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25)
Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25)
GUISetState(@SW_SHOW, $choice)

Local $iMsgBoxAnswer = 1, $bLoop = True

While $bLoop
    Switch GUIGetMsg()
        Case $idYess
            ConsoleWrite("$idYess=" & $idYess & @CRLF)

        Case $idNoo
            ConsoleWrite("$idNoo=" & $idNoo & @CRLF)

        Case $idExitt, -3 ;$GUI_EVENT_CLOSE
            ConsoleWrite("$idExitt=" & $idExitt & @CRLF)
            GUISetState(@SW_HIDE, $choice)
            $iMsgBoxAnswer = 0

    EndSwitch
    
    

    If $iMsgBoxAnswer = 1 Then ContinueLoop
        

    $iMsgBoxAnswer = MsgBox(4100, "MsgBox", "Are you sure you want to close the program?", 3)
    Select
        Case $iMsgBoxAnswer = 6 ;Yes
            ConsoleWrite("- bye bye" & @CRLF)
            $bLoop = False

        Case $iMsgBoxAnswer = 7 ;No
            ConsoleWrite("- Return to program" & @CRLF)
            $iMsgBoxAnswer = 1
            GUISetState(@SW_SHOW, $choice)

        Case $iMsgBoxAnswer = -1 ;Timeout
            ConsoleWrite("- Time is out, bye bye" & @CRLF)
            ExitLoop 
            GUIDelete($choice)
            $bLoop = False

    EndSelect
    
    If $test True Then
    $num = '1' 
    Else
        $num = '2'
    EndIf
    
    
While 1
                                            
  Switch $num

    Case "1"
    MsgBox(0, '', 'Number 1')
    
    Case "2"
    MsgBox(0, '', 'Number 2')
  EndSwitch
Wend

My 2nd While not working.

 

How to make please for show a $num value in MsgBox ?

Edited by AutoDEV
Posted

OK sorry.

My code is

#include <MsgBoxConstants.au3>

Global $test


$choice = GUICreate("Custom MsgBox", 225, 80)
GUICtrlCreateLabel("Please select a button.", 10, 10)
Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25)
Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25)
Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25)
GUISetState(@SW_SHOW, $choice)

Local $iMsgBoxAnswer = 1, $bLoop = True

While $bLoop
    Switch GUIGetMsg()
        Case $idYess
            ConsoleWrite("$idYess=" & $idYess & @CRLF)

        Case $idNoo
            ConsoleWrite("$idNoo=" & $idNoo & @CRLF)

        Case $idExitt, -3 ;$GUI_EVENT_CLOSE
            ConsoleWrite("$idExitt=" & $idExitt & @CRLF)
            GUISetState(@SW_HIDE, $choice)
            $iMsgBoxAnswer = 0

    EndSwitch
    
    

    If $iMsgBoxAnswer = 1 Then ContinueLoop
        

    $iMsgBoxAnswer = MsgBox(4100, "MsgBox", "Are you sure you want to close the program?", 3)
    Select
        Case $iMsgBoxAnswer = 6 ;Yes
            ConsoleWrite("- bye bye" & @CRLF)
            $bLoop = False

        Case $iMsgBoxAnswer = 7 ;No
            ConsoleWrite("- Return to program" & @CRLF)
            $iMsgBoxAnswer = 1
            GUISetState(@SW_SHOW, $choice)

        Case $iMsgBoxAnswer = -1 ;Timeout
            ConsoleWrite("- Time is out, bye bye" & @CRLF)
            ExitLoop 
            GUIDelete($choice)
            $bLoop = False

    EndSelect

WEnd 
    
    
    If $test == 1 Then
    $num = '1' 
    Else
        $num = '2'
    EndIf
    
    
While 1
                                            
  Switch $num

    Case "1"
    MsgBox(0, '', 'Number 1')
    ExitLoop 
    
    Case "2"
    MsgBox(0, '', 'Number 2')
    ExitLoop 
    
  EndSwitch
  
Wend

If you test code my 2nd while not working.

For make working  2nd while i need first exit a 1st loop.

Can you help me plz?

Posted
7 minutes ago, AutoDEV said:

If you test code my 2nd while not working.

For make working  2nd while i need first exit a 1st loop.

Really? As I said in a previous comment: take your time to learn basics. Your question is similar to this but seems you are not here to learn.

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
×
×
  • Create New...