Jump to content

Selecting Programs with Checkbox


Recommended Posts

Hey all,

So here is what I'm trying to accomplish: I'm working on a program to automate my PC repair business. I have the individual scripts finished, and am working on the GUI portion now. I am still testing how exactly I want it, but one idea I had was I would like to have several checkboxes along with a "Run" button (or similar) that will run the programs pertaining to the boxes that are checked.

Here is my current program (GUI portion):

#include <GUIConstantsEx.au3>
$ConnectionTest = "ConnectionTest.exe"
$InstallOnline = "Install (Online).exe"
$DefragglerCheckBox = GUICtrlCreateCheckbox("Defraggler", 300, 300, 100, 30)
$Defraggler = "Defraggler.exe"

_Main()
Func _Main()
Local $filemenu, $fileitem, $recentfilesmenu, $separator1
Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton
Local $msg, $file
#forceref $separator1
GUICreate("GUI menu", 400, 500)
$filemenu = GUICtrlCreateMenu("File")
$fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
$separator1 = GUICtrlCreateMenuItem("", $filemenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
$aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
$ConnectionTestButton = GUICtrlCreateButton("Connection Tests", 50, 250, 150, 20)
$InstallOnlineButton = GUICtrlCreateButton("Install (Online)", 200, 250, 150, 20)
$DefragglerCheckBox = GUICtrlCreateCheckbox("Defraggler", 300, 300, 100, 30)

If GUICtrlRead($DefragglerCheckBox) = 1 Then
$STATE = "CHECK"
Else
$STATE = "UNCHECK"
EndIf
If GUICtrlRead($DefragglerCheckBox) = 1 Then
Run($Defraggler)
EndIf


$cancelbutton = GUICtrlCreateButton("Cancel", 150, 350, 70, 20)
GUISetState()
GUICtrlCreatePic("logo.jpg", 0, 0, 400, 200)
While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
ExitLoop
Case $msg = $fileitem
$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)
Case $msg = $exititem
ExitLoop
Case $msg = $InstallOnlineButton
Run($InstallOnline)
Case $msg = $ConnectionTestButton
     Run($ConnectionTest)

Case $msg = $aboutitem
MsgBox(0, "About", "Matthew's AutoWork v1.0")
EndSelect
WEnd
GUIDelete()
Exit
EndFunc ;==>_Main

I was trying to accomplish this with the "Defraggler" portion. As mentioned, I'm not even close. I might get this eventually, but I would much rather prefer some assistance and figure this out sooner than I would on my own.

Thanks in advance!

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $n, $msg

    GUICreate("My GUI (GetControlState)")
    $n = GUICtrlCreateCheckbox("checkbox", 10, 10)
    GUICtrlSetState(-1, 1) ; checked

    GUISetState() ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    If GUICtrlRead($n) = $GUI_CHECKED Then
        MsgBox(0,0,"Checked")
    Else
        MsgBox(0,0,"Unchecked")
    EndIf
EndFunc   ;==>Example

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...