Guest Phibian Posted May 20, 2005 Share Posted May 20, 2005 I'm a new user, so please be kind. I've combed the manual, forum and the examples, but can't seem to apply them to my situation. I am trying to create a basic window with a dropdown to let the user select IE or FireFox. When the dropdown selection changes, I want to open the program they selected. I started out using GUIGetMsg, but then the documentation I read suggested that I needed to use On Event mode. So I was more or less fine until in my function I needed to differentiate between the options in the dropdown. The example used GUI_CTRLID, which I think I set to $SelectBrowser, but that is the whole element and not the individual items. Here's my non-working code, because I got stuck in the function and don't know how to access the info I need.. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("Select system for testing") $SelectBrowser = GUICtrlCreateCombo("--Select your browser--", 60, 20, 160,21) GUICtrlSetData (-1, "IE|FireFox") GUICtrlSetOnEvent($SelectBrowser, "BrowserSelected") GUISetState(@SW_SHOW) While 1 Sleep(10) Wend Func BrowserSelected() Select Case @GUI_CTRLID = ?? If $msg = "IE" then Run("C:\Program Files\Internet Explorer\iexplore.exe") If $msg = "FireFox" then Run ("C:\Program Files\Mozilla Firefox\firefox.exe") EndFunc Thanks for any help! PS If anyone could point me to some simple examples of clicking around a web page, that would be super (I'm really looking for examples on the level of the tutorials that came with autoitscript). I'm hoping to find a more reliable way to select elements without figuring out where the mouse coordinates should be, because although I can set the size of the window, this doesn't help me if the dropdown menu moves slightly to the right for other reasons. Link to comment Share on other sites More sharing options...
jpm Posted May 20, 2005 Share Posted May 20, 2005 (edited) analyse the modification I did#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("Select system for testing") GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI") $SelectBrowser = GUICtrlCreateCombo("--Select your browser--", 60, 20, 160,21) GUICtrlSetData (-1, "IE|FireFox") GUICtrlSetOnEvent($SelectBrowser, "BrowserSelected") GUISetState(@SW_SHOW) While 1 Sleep(10) Wend Func BrowserSelected() If GUICtrlRead($SelectBrowser) = "IE" then Run(@programfilesdir & "\Internet Explorer\iexplore.exe") If GUICtrlRead($SelectBrowser) = "FireFox" then Run (@programfilesdir & "\Mozilla Firefox\firefox.exe") EndFunc Func CloseGUI() Exit EndFunc EDIT: slight edition about @programfilesdir Edited May 20, 2005 by jpm Link to comment Share on other sites More sharing options...
Josbe Posted May 20, 2005 Share Posted May 20, 2005 I suggest you that:- Check the examples included. Read this: Install Directory StructureRead more about GUI Event modes and differences.#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("Select system for testing") $SelectBrowser = GUICtrlCreateCombo("--Select your browser--", 60, 20, 160, 80) GUICtrlSetData (-1, "IE|FireFox") GUICtrlSetOnEvent($SelectBrowser, "BrowserSelected") GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit") GUISetState(@SW_SHOW) While 1 Sleep(10) Wend Func BrowserSelected() $sBrowser = GUICtrlRead(@GUI_CTRLID) Select Case $sBrowser = "IE" MsgBox(0, "", "IE selected") ;Run("C:\Program Files\Internet Explorer\iexplore.exe") Case $sBrowser = "FireFox" MsgBox(0, "", "Firefox selected") ;Run ("C:\Program Files\Mozilla Firefox\firefox.exe") EndSelect EndFunc Func OnExit() Exit EndFunc AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta 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