Jump to content

Working with check-boxes and buttons.


Go to solution Solved by somdcomputerguy,

Recommended Posts

I have the following code, and it seems to work. But, the only problem I am running into is trying to get it to download only the files that are checked. I plan on having more than two checkboxes in the future.

#RequireAdmin

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <InetConstants.au3>

$hGUI = GUICreate("FixIt GUI", 650, 650, -1, -1)
$hTab = GUICtrlCreateTab(5, 5, 640, 640)
GUICtrlCreateTabItem("Virus Removal Software ")
$hCheckbox = GUICtrlCreateCheckbox("ComboFix", 270, 140, 130, 30)
GUICtrlSetFont(-1, 9, 800, 0)

GUICtrlCreateTabItem("")
$hCheckbox2 = GUICtrlCreateCheckbox("Eset", 270, 178, 130, 30)
GUICtrlSetFont(-1, 8.5, 800, 0)
GUISetState()

$hButton = GUICtrlCreateButton("Download Selected", 220, 590, 270, 40)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If GUICtrlRead($hCheckbox) = 1 Then
                DirCreate(@DesktopCommonDir & "\Virus Removal\")
                DirCreate(@DesktopCommonDir & "\Virus Removal\1- ComboFix\")
                InetGet("http://download.bleepingcomputer.com/sUBs/ComboFix.exe",@DesktopCommonDir &"\Virus Removal\1- ComboFix\Combofix.exe")
            Else
                GUICtrlRead($hCheckbox2) = 1 Then
                DirCreate(@DesktopCommonDir & "\Virus Removal 2\")
                DirCreate(@DesktopCommonDir & "\Virus Removal\1- ComboFix\")
                InetGet("http://download.bleepingcomputer.com/sUBs/ComboFix.exe",@DesktopCommonDir &"\Combofix.exe")
            EndIf
        EndSwitch
WEnd

I realize they are the same files, which I am using just for testing purposes. But, they are in different locations. If I select the first one, it only does the first one. If I only select the second one, it does the commands of both the first and second check boxes. Thanks for any help.

Link to post
Share on other sites
  • Solution

Do it without the Else. This is one way..

#include <GUIConstantsEx.au3>

Local $hGUI = GUICreate("FixIt GUI", 650, 650, -1, -1), _
$hButton = GUICtrlCreateButton("Download Selected", 220, 590, 270, 40), _
$hCheckbox1 = GUICtrlCreateCheckbox("ComboFix", 270, 140, 130, 30), _
$hCheckbox2 = GUICtrlCreateCheckbox("Eset", 270, 178, 130, 30)

GUISetState()

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $hButton
If BitAnd(GUICtrlRead($hCheckbox1), $GUI_CHECKED) Then ConsoleWrite("Checkbox 1 is checked" & @LF)
If BitAnd(GUICtrlRead($hCheckbox2), $GUI_CHECKED) Then ConsoleWrite("Checkbox 2 is checked" & @LF)
EndSwitch
WEnd
edit: the autoit tag gods are taking a break at the moment it seems, or Mr. Murphy is just doing his thing.. Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to post
Share on other sites

Ya, if only one line is to be executed, it can be put right after the Then, but multiple executions have to be each on a separate line with an EndIf as the last line.

As you learn more about AutoIt, you'll find that any particular thing can be done in at least 3 or 4 different ways. Some ways better or worse than other ways..

Good luck with your project!

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...