Sign in to follow this  
Followers 0
hozdaman

help creating a function using combobox

4 posts in this topic

Hi,

I am trying to create a script that will open a msgbox combobox that when you select an option it opens another combobox. When I execute the code below it will open the first combobox, but when I select "malaware" the script just stops. Any help with be really great. Thanks.

;Required includes
#include<GUIConstantsEx.au3>;constants for GUI events
#include<EditConstants.au3>;Edit Constants. Required for the styles we used.
#include<GUIConstants.au3>


;GUI Creation
GUICreate("PC ToolMan Utilities", 225, 80)

;Combobox Creation
$combobox = GUICtrlCreateCombo("Malawarebytes", 10, 10, 120, 20)
GUICtrlSetData(-1, "CCleaner|Combofix|Win Utilities")

;Button Creation
$button = GUICtrlCreateButton("Open", 10, 40, 60, 20)

GUISetState(@SW_SHOW)

While 1
    $guimsg = GUIGetMsg()
    Select
        Case $guimsg = $button
            ;MsgBox(0, "", "Choose an option " & GUICtrlRead($combobox) & ".")
            Select
                Case GUICtrlRead($combobox) = "Malawarebytes"
                    Run('malaware()')
                    Exit
                Case GUICtrlRead($combobox) = "CCleaner"
                    Run('notepad.exe')
                    Exit
                Case GUICtrlRead($combobox) = "Combofix"
                    Run("combofix()")
                Case ($combobox) = "Win Utilities"
                    Run("winutl()")
                    Exit
            EndSelect
        Case $guimsg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd


Func malaware()
;GUI Creation
    GUICreate("Malawarebytes", 225, 80)

    ;Combobox Creation
    $combobox1 = GUICtrlCreateCombo("Install", 10, 10, 120, 20)
    GUICtrlSetData(-1, "Uninstall")

    ;Button Creation
    $button1 = GUICtrlCreateButton("Run", 10, 40, 60, 20)


    While 1
        $guimsg = GUIGetMsg()
        Select
            Case $guimsg = $button1
                ;MsgBox(0, "", "Choose an option" & GUICtrlRead($combobox1) & ".")
                Select
                    Case GUICtrlRead($combobox1) = "Install"
                        Run('C:\Documents and Settings\PC ToolMan\My Documents\Downloads\mbam-setup-1.45.exe')
                        Exit
                    Case GUICtrlRead($combobox1) = "Uninstall"
                        Run('notepad.exe')
                        Exit
                EndSelect
            Case $guimsg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
    WEnd
EndFunc   ;==>malaware

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The Run command is only used for calling external exes. You should/can not use it to call internal functions. Just call them by name.

Case GUICtrlRead($combobox) = "Malawarebytes"
     malaware()
     Exit
Case GUICtrlRead($combobox) = "CCleaner"
     Run('notepad.exe')
     Exit
Edited by spudw2k

Share this post


Link to post
Share on other sites

Thanks for your help.

I have one other question. I am going to create a zip file for all the installers (i.e malawarebytes, ccleaner...), currently they are in my documents and settings if i make this portable what path do I use? Thanks.

Share this post


Link to post
Share on other sites

if it will be a part of your package and it will be near the exe you re making could be @ScriptDir

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
Sign in to follow this  
Followers 0