Airwolf Posted May 12, 2006 Posted May 12, 2006 (edited) I am trying to use the selection in a combo box to determine what a button does. This is my code thus far: expandcollapse popup#include <GuiConstants.au3> Opt('GUIOnEventMode', 1) Opt("TrayIconHide", 1) Global $region Global $selected GuiCreate("Gui", 400, 350) GuiSetIcon("icon.ico") GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose') GUICtrlCreateButton("Button", 100, 170, 200, 30) GUICtrlSetOnEvent(-1, 'function') $region = GUICtrlCreateCombo("", 130, 310, 150, 120, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "item1|item2|item3|item4|item5","item2") $selected = GuiCtrlRead($region) Func function() GUISetState(@SW_HIDE) If $selected = "item1" or "item2" or "item3" Then Run("program1.exe") ElseIf $selected = "item4" Then Run("program2.exe") ElseIf $selected = "item5" Then Run("program3.exe") EndIf Exit EndFunc GUISetState(@SW_SHOW) While 1 Sleep(250) WEnd Func Event_GUIClose() Exit EndFunc I don't receive any errors, but nomatter what is selected in the combo box it always runs program1.exe. Thanks! Edited May 12, 2006 by Airwolf123 Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
GaryFrost Posted May 12, 2006 Posted May 12, 2006 (edited) no-no If $selected = "item1" or "item2" or "item3" Then try this If $selected = "item1" or $selected = "item2" or $selected = "item3" Then plus you'll want to move this just above that line $selected = GuiCtrlRead($region) Edited May 12, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Moderators big_daddy Posted May 12, 2006 Moderators Posted May 12, 2006 no-no If $selected = "item1" or "item2" or "item3" Then try this If $selected = "item1" or $selected = "item2" or $selected = "item3" Then plus you'll want to move this just above that line $selected = GuiCtrlRead($region)gafrost is exactly right, but if you use the beta version you could go at it this way: expandcollapse popup#include <GuiConstants.au3> Opt('GUIOnEventMode', 1) Opt("TrayIconHide", 1) GUICreate("Gui", 400, 350) GUISetIcon("icon.ico") GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose') GUICtrlCreateButton("Button", 100, 170, 200, 30) GUICtrlSetOnEvent(-1, 'function') $region = GUICtrlCreateCombo("", 130, 310, 150, 120, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "item1|item2|item3|item4|item5", "item2") GUISetState(@SW_SHOW) While 1 Sleep(250) WEnd Func function() $selected = GUICtrlRead($region) GUISetState(@SW_HIDE) Switch $selected Case "item1", "item2", "item3" Run("program1.exe") Case "item4" Run("program2.exe") Case "item5" Run("program3.exe") EndSwitch Exit EndFunc ;==>function Func Event_GUIClose() Exit EndFunc ;==>Event_GUIClose
Airwolf Posted May 12, 2006 Author Posted May 12, 2006 no-no If $selected = "item1" or "item2" or "item3" Then try this If $selected = "item1" or $selected = "item2" or $selected = "item3" Then plus you'll want to move this just above that line $selected = GuiCtrlRead($region) That worked great! Thanks! Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
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