Jump to content

total newbie - checkboxes


Recommended Posts

What I'm looking to do is throw together a simple GUI with checkboxes (say 7 checkboxes) where if one was checked it would launch an application. I've figured out how to have buttons launch apps but not as of yet with checkboxes.

Link to comment
Share on other sites

I found one through a simple search ( at the topt right of this screen )

#include <GUIConstants.au3>


GUICreate("Program Runner")

GUICtrlCreateLabel("Select the program.", 10, 10)
$P1 = GUICtrlCreateRadio("Notepad", 10, 40, 80, 30)
$P2 = GUICtrlCreateRadio("Explorer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($P1, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($P1) Then Run("Notepad.exe")
            If _IsChecked($P2) Then Run("Explorer.exe")
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

NEWHeader1.png

Link to comment
Share on other sites

Post your code, just show us what you have so far

8)

Actually i think i just figured it out

#include <GUIConstants.au3>

GUICreate("")

$checkCN = GUICtrlCreateCheckbox("App1", 10, 10, 120, 20)

$checkCN1 = GUICtrlCreateCheckbox("App2", 10, 40, 120, 20)

GUISetState()

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $checkCN Then

$cstate = BitAND(GUICtrlRead($checkCN), $GUI_CHECKED)

If $cstate = $GUI_CHECKED Then ShellExecuteWait("notepad.exe")

EndIf

If $msg = $checkCN1 Then

$cstate = BitAND(GUICtrlRead($checkCN1), $GUI_CHECKED)

If $cstate = $GUI_CHECKED Then ShellExecuteWait("cmd.exe")

EndIf

WEnd

although is there a way to make app2 wait til app1 is finished before kicking off?

/cmd & notepad is just what i'm playing with for the moment to test, but in the end it will be used to kick off installs of apps

Link to comment
Share on other sites

I found one through a simple search ( at the topt right of this screen )

#include <GUIConstants.au3>


GUICreate("Program Runner")

GUICtrlCreateLabel("Select the program.", 10, 10)
$P1 = GUICtrlCreateRadio("Notepad", 10, 40, 80, 30)
$P2 = GUICtrlCreateRadio("Explorer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($P1, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($P1) Then Run("Notepad.exe")
            If _IsChecked($P2) Then Run("Explorer.exe")
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

That works wonders actually
Link to comment
Share on other sites

NP

Welcome to the Autoit Forums

8)

oh one other question.....

if i were to need to run a app and then have it patched, is that possible to do with just using one checkbox?

two run statements for one?

Link to comment
Share on other sites

#include <GUIConstants.au3>


GUICreate("Program Runner")

GUICtrlCreateLabel("Select the program.", 10, 10)
$P1 = GUICtrlCreateRadio("Notepad", 10, 40, 80, 30)
$P2 = GUICtrlCreateRadio("Explorer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($P1, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($P1) Then
                RunWait("Notepad.exe")
                RunWait("Explorer.exe")
                ; do what ever you want
            EndIf
            If _IsChecked($P2) Then RunWait("Explorer.exe")
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

NEWHeader1.png

Link to comment
Share on other sites

#include <GUIConstants.au3>


GUICreate("Program Runner")

GUICtrlCreateLabel("Select the program.", 10, 10)
$P1 = GUICtrlCreateRadio("Notepad", 10, 40, 80, 30)
$P2 = GUICtrlCreateRadio("Explorer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($P1, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($P1) Then
                RunWait("Notepad.exe")
                RunWait("Explorer.exe")
                ; do what ever you want
            EndIf
            If _IsChecked($P2) Then RunWait("Explorer.exe")
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

Thanks so much!
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...