Jump to content

Case $msg = $CheckBox


Info
 Share

Recommended Posts

#include <GUIConstants.au3>

GUICreate("Just a GUI", 500, 321, 258, 181)
GUISetBkColor (0x000000)

$StartButton = GUICtrlCreateButton("Start", 27, 145, 89, 33, 0)

$CheckBox= GUICtrlCreateCheckbox ("BlaBla", 370, 10, 112, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($CheckBox), "wstr", "", "wstr", "")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $CheckBox
                If WinExists ( "C:\") = True Then
                Sleep ( 2000 )
                WinClose ( "C:\")
                EndIf
        Case $msg = $StartButton
                ShellExecute ("C:\")
    EndSelect
WEnd

If I put the EndIf in the end, the script just wont work.

So what do I do?

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("Just a GUI", 500, 321, 258, 181)
GUISetBkColor (0x000000)

$StartButton = GUICtrlCreateButton("Start", 27, 145, 89, 33, 0)

$CheckBox= GUICtrlCreateCheckbox ("BlaBla", 370, 10, 112, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($CheckBox), "wstr", "", "wstr", "")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $CheckBox
                If WinExists ( "C:\") = True Then
                Sleep ( 2000 )
                WinClose ( "C:\")
                EndIf
        Case $msg = $StartButton
                ShellExecute ("C:\")
    EndSelect
WEnd

If I put the EndIf in the end, the script just wont work.

So what do I do?

I'm not sure. This works for me. What exactly doens't work?

#include <GUIConstants.au3>

GUICreate("Just a GUI", 500, 321, 258, 181)
GUISetBkColor (0x000000)

$StartButton = GUICtrlCreateButton("Start", 27, 145, 89, 33, 0)

$CheckBox= GUICtrlCreateCheckbox ("BlaBla", 370, 10, 112, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($CheckBox), "wstr", "", "wstr", "")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $CheckBox
            If BitAnd(GUICtrlRead($CheckBox),$GUI_CHECKED) Then
                If WinExists ( "C:\") Then
                    WinClose ( "C:\")
                EndIf
            EndIf
        Case $msg = $StartButton
                ShellExecute ("C:\")
    EndSelect
WEnd
Link to comment
Share on other sites

I just want it to look for a window untill $GUI_EVENT_CLOSE, and if the window is found, exit it.

Then why do you have your WinExists() executed only when the checkbox is "used" and not when it is checked?? You need to move your WinExists() etc into the main-loop like this

#include <GUIConstants.au3>

GUICreate("Just a GUI", 500, 321, 258, 181)
GUISetBkColor (0x000000)

$StartButton = GUICtrlCreateButton("Start", 27, 145, 89, 33, 0)

$CheckBox= GUICtrlCreateCheckbox ("BlaBla", 370, 10, 112, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($CheckBox), "wstr", "", "wstr", "")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $StartButton
            ShellExecute ("C:\WINDOWS")
    EndSelect
    If BitAnd(GUICtrlRead($CheckBox),$GUI_CHECKED) Then
        If WinExists ( "WINDOWS") Then
            WinClose ( "WINDOWS")
        EndIf
    EndIf
WEnd
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...