Jump to content

Dropdown


Recommended Posts

Can someone help i'm trying to get a selection from a dropdown list to start an exe file when the run button is pressed on this form but have been having some problems getting it to do so...

#include <GUIConstants.au3>


Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("AForm1", 633, 447, 193, 115)
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1Restore")
$combo = GUICtrlCreateCombo("", 150, 150, 280, 20)
GUICtrlSetData($combo, "Site1|Site2|Site3|Site4", "Site1")
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$RUN = GUICtrlCreateButton("Run", 32, 360, 169, 65, 0)
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$EXIT = GUICtrlCreateButton("Exit", 436, 359, 169, 65, 0)
GUICtrlSetOnEvent(-1, "AButton1Click")
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$Label1 = GUICtrlCreateLabel("Network Config", 16, 8, 216, 44)
GUICtrlSetFont(-1, 22, 400, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)


Do
    $msg = GUIGetMsg()

;Reads the status of the Checkboxes and sets a variable to either 1 for checked or 4 for not checked
;This HAS to be included before the UNTIL statement
$status1 = GUICtrlRead($combo)
Until $msg = $EXIT or $msg = $RUN

If $msg = $EXIT then EXIT

;Checks the status of the Checkboxes and calls the application function(s) if the checkbox is enabled
IF $status1 = "Site1" then call ("Site1")
IF $status1 = "Site2" then call ("Site2")
IF $status1 = "Site3" then call ("Site3")
IF $status1 = "Site4" then call ("Site4")

Call ("END_APP")
    
Func Site1()
    RunWait ("C:\System\Ipchange\Site1.exe")
EndFunc

        
Func Site2()
    RunWait ("C:\System\Ipchange\Site2.exe")
EndFunc

        
Func Site3()
    RunWait ("C:\System\Ipchange\Site3.exe")
EndFunc

Func Site4()
    RunWait ("C:\System\Ipchange\Site4.exe")
EndFunc

Func AButton1Click()
exit
EndFunc


Func AForm1Close()
exit
EndFunc

        
Func AForm1Maximize()

EndFunc

        
Func AForm1Minimize()

EndFunc

        
Func AForm1Restore()

EndFunc

Func END_APP()
    MsgBox(4096,"Complete","Network has been configured")
EndFunc

Thanks for any help given on this...

Edited by boyemillar
Link to comment
Share on other sites

#include <GUIConstants.au3>


$Form1 = GUICreate("AForm1", 633, 447, 193, 115)
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1Restore")
$combo = GUICtrlCreateCombo("", 150, 150, 280, 20)
GUICtrlSetData($combo, "Site1|Site2|Site3|Site4", "Site1")
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$RUNME = GUICtrlCreateButton("Run", 32, 360, 169, 65, 0)
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$EXIT = GUICtrlCreateButton("Exit", 436, 359, 169, 65, 0)
GUICtrlSetOnEvent(-1, "AButton1Click")
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$Label1 = GUICtrlCreateLabel("Network Config", 16, 8, 216, 44)
GUICtrlSetFont(-1, 22, 400, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $EXIT
            Exit
        Case $msg = $RUNME
            MsgBox(0, "test", GUICtrlRead($combo))
            $status1 = GUICtrlRead($combo)
            If $status1 = "Site1" Then Site1()
            If $status1 = "Site2" Then Site2()
            If $status1 = "Site3" Then Site3()
            If $status1 = "Site4" Then Site4()
            Call("END_APP")
    EndSelect
WEnd


Func Site1()
    RunWait("C:\System\Ipchange\Site1.exe")
EndFunc   ;==>Site1


Func Site2()
    RunWait("C:\System\Ipchange\Site2.exe")
EndFunc   ;==>Site2


Func Site3()
    RunWait("C:\System\Ipchange\Site3.exe")
EndFunc   ;==>Site3

Func Site4()
    RunWait("C:\System\Ipchange\Site4.exe")
EndFunc   ;==>Site4

Func AButton1Click()
    Exit
EndFunc   ;==>AButton1Click


Func AForm1Close()
    Exit
EndFunc   ;==>AForm1Close


Func AForm1Maximize()

EndFunc   ;==>AForm1Maximize


Func AForm1Minimize()

EndFunc   ;==>AForm1Minimize


Func AForm1Restore()

EndFunc   ;==>AForm1Restore

Func END_APP()
    MsgBox(4096, "Complete", "Network has been configured")
EndFunc   ;==>END_APP

Link to comment
Share on other sites

This works :)

#include <GUIConstants.au3>

$Form1 = GUICreate("AForm1", 633, 447, 193, 115)
$combo = GUICtrlCreateCombo("", 150, 150, 280, 20)
GUICtrlSetData($combo, "Site1|Site2|Site3|Site4", "Site1")
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$RUN = GUICtrlCreateButton("Run", 32, 360, 169, 65, 0)
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$EXIT = GUICtrlCreateButton("Exit", 436, 359, 169, 65, 0)
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$Label1 = GUICtrlCreateLabel("Network Config", 16, 8, 216, 44)
GUICtrlSetFont(-1, 22, 400, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)


Do
    $msg = GUIGetMsg()
Switch $msg
    Case $RUN
        $comboread = GUICtrlRead($combo)
        Switch $comboread
                Case "Site1"
                RunWait ("C:\System\Ipchange\Site1.exe")
                Case "Site2"
                RunWait ("C:\System\Ipchange\Site2.exe")
                Case "Site3"
                RunWait ("C:\System\Ipchange\Site3.exe")
                Case "Site4"
                RunWait ("C:\System\Ipchange\Site4.exe")
        EndSwitch
EndSwitch
Until $msg = $EXIT or $msg = $RUN
[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Link to comment
Share on other sites

Cheerz Guys those work perfectly...

I'm getting there slowly but surely,

Do any of you have any idea how to add a status/progress bar to show that it is doing something to stop impatient people clicking the run button again and again...

Link to comment
Share on other sites

Cheerz Guys those work perfectly...

I'm getting there slowly but surely,

Do any of you have any idea how to add a status/progress bar to show that it is doing something to stop impatient people clicking the run button again and again...

To stop/allow anyone using the RUN button use

GUICtrlSetState($RUN,$GUI_DISABLE/$GUI_ENABLE)

Have a look at SplashTextOn in the help.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...