Bunny_Ding

GUI checkbox and button

4 posts in this topic

Hi All, Sorry I may ask this silly question. I am doing some project now, here is a GUI just created. Simply saying is I wish to do once the certain checkbox has been checked and click the Run Test botton. It should run the respective function test. The individual functions I have created already.

Please help~~~ Thanks a lot! 

Run Test.jpg

Share this post


Link to post
Share on other sites



Use GUICtrlRead to get the state of the checkbox and execute the respective function is they are checked

#include <GUIConstants.au3>

Global $frmMain = GUICreate("Test", 300, 200)
Global $inpInput = GUICtrlCreateInput("", 10, 10, 280, 20)
Global $chkMsgBox = GUICtrlCreateCheckbox("MsgBox('', '', 'Inputbox')", 10, 35, 280)
Global $chkShellExecute = GUICtrlCreateCheckbox("ShellExecute('Inputbox')", 10, 55, 280)
Global $btnRun = GUICtrlCreateButton("Run Test", 10, 80, 280, 20)
Global $bExecuteMsgBox = False
Global $bExecuteShell = False

GUISetState(@SW_SHOW, $frmMain)

; Option 1
While (1)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btnRun
            Local $sData = GUICtrlRead($inpInput)

            If ($bExecuteShell) Then ShellExecute($sData)
            If ($bExecuteMsgBox) Then MsgBox("", "", $sData)

        Case $chkMsgBox
            $bExecuteMsgBox = Not $bExecuteMsgBox
        Case $bExecuteShell
            $bExecuteShell = Not $bExecuteShell
    EndSwitch
WEnd

; Option 2
While (1)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btnRun
            Local $sData = GUICtrlRead($inpInput)

            If (GUICtrlRead($chkShellExecute) = $GUI_CHECKED) Then ShellExecute($sData)
            If (GUICtrlRead($chkMsgBox) = $GUI_CHECKED) Then MsgBox("", "", $sData)
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

Hi InunoTaishou, Thanks a lot for your help. It is really Great.

Besides this, may i ask another question is about the global variables. For example: The passwrod input box is allowing me to input some data and store it. when I wish to run any of the test, inside the function it will request the password as I key inside the input box. So that I just change the data by the input box, then it can work for other scripting as I created.  I have been tried a few times, but it not really work. 

So glad to get the helps from you! Thanks a lot!

Share this post


Link to post
Share on other sites

Im honest, didn't get the question, but i know it's something about a password input.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
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