lostangel556 Posted August 18, 2008 Share Posted August 18, 2008 Hi, I know this probably sounds like an really easy thing to do but please bear with me, im just starting with gui's in autoit.I need to be able to select an option in the combobox on my GUI and select the button which will then run the specified function.Heres what i have so far for my test scriptCODE#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <GuiButton.au3>#Include <GuiComboBox.au3>Global $btn, $hGUIExample1()Func Example1() Local $msg $hGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ;Create an Button $btn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 50) ;Combo Selection Box $hcombo = _GUICtrlComboBox_Create($hGUI, "", 50, 120, 100, 120) _GUICtrlComboBox_AddString($hcombo, "Script 1") _GUICtrlComboBox_AddString($hcombo, "Script 2") ;Pass Value to function to find which script to run _ComboCompare(GUICtrlRead($hcombo)) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete()EndFunc ;==>Example1Func _ComboCompare($hmsg) If $hmsg = "Script 1" Then _myscript1() Else _myscript2() EndIf EndFuncFunc _myscript1() MsgBox(0,"", "Hello1")EndFuncFunc _myscript2() MsgBox(0,"", "Hello2")EndFuncWhat i cant figure out is how to get the part in italics to run when i press the button. please help Link to comment Share on other sites More sharing options...
martin Posted August 18, 2008 Share Posted August 18, 2008 Hi, I know this probably sounds like an really easy thing to do but please bear with me, im just starting with gui's in autoit.I need to be able to select an option in the combobox on my GUI and select the button which will then run the specified function.Heres what i have so far for my test scriptCODE#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <GuiButton.au3>#Include <GuiComboBox.au3>Global $btn, $hGUIExample1()Func Example1() Local $msg $hGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ;Create an Button $btn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 50) ;Combo Selection Box $hcombo = _GUICtrlComboBox_Create($hGUI, "", 50, 120, 100, 120) _GUICtrlComboBox_AddString($hcombo, "Script 1") _GUICtrlComboBox_AddString($hcombo, "Script 2") ;Pass Value to function to find which script to run _ComboCompare(GUICtrlRead($hcombo)) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete()EndFunc ;==>Example1Func _ComboCompare($hmsg) If $hmsg = "Script 1" Then _myscript1() Else _myscript2() EndIf EndFuncFunc _myscript1() MsgBox(0,"", "Hello1")EndFuncFunc _myscript2() MsgBox(0,"", "Hello2")EndFuncWhat i cant figure out is how to get the part in italics to run when i press the button. please helpLook up GuiGetMsg in the help and the example. 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 More sharing options...
lostangel556 Posted August 18, 2008 Author Share Posted August 18, 2008 Cheers, But how do i get the event for the button? Ive set this part CODE If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $btn MsgBox(0, "", "Button Pressed", 2) EndSelect but it just keeps bringing up the msgbox on an loop Link to comment Share on other sites More sharing options...
lostangel556 Posted August 18, 2008 Author Share Posted August 18, 2008 Nevermind, got it working now. Thanks for your help Martin Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now