Jump to content

checkboxes


Recommended Posts

what do I do to make it so when A + b are checked... $Checkbox1 runs then after $Checkbox1 is complete $Checkbox2 runs.

#include <GUIConstants.au3>
#include <File.au3>

$GUI = GUICreate("My GUI radio"); will create a dialog box that when displayed is centered
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 250, 120, 40)


$Checkbox1 = GUICtrlCreateCheckbox ("A", 20, 50)
$Checkbox2 = GUICtrlCreateCheckbox ("B", 20, 100)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $button_1
        $Read = GUICtrlRead($Checkbox1)
        If ($Read = 1) Then
            run("notepad")
            sleep(1000)
            
            EndIf
        EndSelect
            $nMsg = GUIGetMsg()
             Select
             Case $nMsg = $button_1
        $Read = GUICtrlRead($Checkbox2)
        If ($Read = 1) Then
            run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
            
            
        EndIf
    EndSelect
WEnd
Link to comment
Share on other sites

Use RunWait() so that the script wait for notepad to finish before moving on to the next line.

#include <GUIConstants.au3>
#include <File.au3>

$GUI = GUICreate("My GUI radio"); will create a dialog box that when displayed is centered
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 250, 120, 40)
$Checkbox1 = GUICtrlCreateCheckbox("A", 20, 50)
$Checkbox2 = GUICtrlCreateCheckbox("B", 20, 100)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $button_1
            ; read state of checkbox
            $Read = GUICtrlRead($Checkbox1)
            ; test if checkbox is checked
            If $Read = $GUI_CHECKED Then
                RunWait("notepad")
                ; this line will not be executed until notepad above closes
                Sleep(1000)
            EndIf
            ; read state of checkbox
            $Read = GUICtrlRead($Checkbox2)
            ; test if checkbox is checked
            If $Read = $GUI_CHECKED Then
                ; run with double quotes as the path contains whitespace
                Run('"' & @ProgramFilesDir & '\Internet Explorer\IEXPLORE.EXE"')
                ; script will continue while IE is running as RunWait is not used
            EndIf
    EndSelect
WEnd

:)

Link to comment
Share on other sites

Use RunWait() so that the script wait for notepad to finish before moving on to the next line.

#include <GUIConstants.au3>
#include <File.au3>

$GUI = GUICreate("My GUI radio"); will create a dialog box that when displayed is centered
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 250, 120, 40)
$Checkbox1 = GUICtrlCreateCheckbox("A", 20, 50)
$Checkbox2 = GUICtrlCreateCheckbox("B", 20, 100)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $button_1
            ; read state of checkbox
            $Read = GUICtrlRead($Checkbox1)
            ; test if checkbox is checked
            If $Read = $GUI_CHECKED Then
                RunWait("notepad")
                ; this line will not be executed until notepad above closes
                Sleep(1000)
            EndIf
            ; read state of checkbox
            $Read = GUICtrlRead($Checkbox2)
            ; test if checkbox is checked
            If $Read = $GUI_CHECKED Then
                ; run with double quotes as the path contains whitespace
                Run('"' & @ProgramFilesDir & '\Internet Explorer\IEXPLORE.EXE"')
                ; script will continue while IE is running as RunWait is not used
            EndIf
    EndSelect
WEnd

:)

Thanks

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...