LetsAuto Posted October 16, 2012 Share Posted October 16, 2012 Hi everyone I'm relatively new to AutoIt and im using the v3 (if there is any other version.. just to clear up which one im using). I have a function that creates a GUI and has the user select which browswer they would like to use. I got all of that to work with the buttons and everthing, and now I just cant get the other functions to run after the user selects their button. If i comment out the GUI function, the other functions work perfect.. can someone tell me how to get the other functions to work AFTER the GUI function has already happened? Thanks Link to comment Share on other sites More sharing options...
kylomas Posted October 16, 2012 Share Posted October 16, 2012 LetsAuto, Post your code or we are just guessing. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
LetsAuto Posted October 16, 2012 Author Share Posted October 16, 2012 Func DoGUI() local $ie_Button, $ff_Button, $gc_Button, $msg GUICreate("Please Select Browswer") $ie_Button = GUICtrlCreateButton("Internet Explorer", 50, 30, 100) _GUICtrlButton_Enable($ie_Button) $ff_Button = GUICtrlCreateButton("Firefox", 150, 30, 100) _GUICtrlButton_Enable($ff_Button) $gc_Button = GUICtrlCreateButton("Google Chrome", 250, 30, 100) _GUICtrlButton_Enable($gc_Button) GUISetState() ;~ MsgBox(0, "condition",StringFormat("GUICtrlRead=%dnGUICtrlGetState=%d", GUICtrlRead($chkst), GUICtrlGetState($chkst))) While 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $ie_Button ;~ MsgBox(0, "HEY! LISTEN!", "HEY LISTEN!") If $system = 32 Then Run("C:\Program Files\Internet Explorer\iexplore.exe","",@SW_MAXIMIZE,"") Elseif $system = 64 Then Run("C:\Program Files\Internet Explorer\iexplore.exe","",@SW_MAXIMIZE,"") EndIf case $msg = $ff_Button If $system = 32 Then Run("C:Program FilesMozilla Firefoxfirefox.exe","",@SW_MAXIMIZE,"") ElseIf $system = 64 Then Run("C:Program FilesMozilla Firefoxfirefox.exe","",@SW_MAXIMIZE,"") EndIf case $msg = $gc_Button If $system = 32 Then Run("C:Program FilesGoogleChromeApplicationchrome.exe","",@SW_MAXIMIZE,"") ElseIf $system = 64 Then Run("C:Program FilesGoogleChromeApplicationchrome.exe","",@SW_MAXIMIZE,"") EndIf EndSelect WEnd sleep(1000) EndFunc all of that works, i just cant get the next function to work which is just an IE click event.. the click event wont trigger Link to comment Share on other sites More sharing options...
kylomas Posted October 16, 2012 Share Posted October 16, 2012 (edited) LetsAuto, The ENTIRE code and please use code tags. kylomas edit: also, if you are trying to automate a web site this is not how you do it. Edited October 16, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
LetsAuto Posted October 16, 2012 Author Share Posted October 16, 2012 expandcollapse popup;~ DoGUI() DoLogin() ;Programmed Functions Func DoGUI() local $ie_Button, $ff_Button, $gc_Button, $msg GUICreate("Please Select Browswer") $ie_Button = GUICtrlCreateButton("Internet Explorer", 50, 30, 100) _GUICtrlButton_Enable($ie_Button) $ff_Button = GUICtrlCreateButton("Firefox", 150, 30, 100) _GUICtrlButton_Enable($ff_Button) $gc_Button = GUICtrlCreateButton("Google Chrome", 250, 30, 100) _GUICtrlButton_Enable($gc_Button) GUISetState() ;~ MsgBox(0, "condition",StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d", GUICtrlRead($chkst), GUICtrlGetState($chkst))) While 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $ie_Button ;~ MsgBox(0, "HEY! LISTEN!", "HEY LISTEN!") If $system = 32 Then Run("C:\Program Files\Internet Explorer\iexplore.exe","",@SW_MAXIMIZE,"") Elseif $system = 64 Then Run("C:\Program Files\Internet Explorer\iexplore.exe","",@SW_MAXIMIZE,"") EndIf case $msg = $ff_Button If $system = 32 Then Run("C:\Program Files\Mozilla Firefox\firefox.exe","",@SW_MAXIMIZE,"") ElseIf $system = 64 Then Run("C:\Program Files\Mozilla Firefox\firefox.exe","",@SW_MAXIMIZE,"") EndIf case $msg = $gc_Button If $system = 32 Then Run("C:\Program Files\Google\Chrome\Application\chrome.exe","",@SW_MAXIMIZE,"") ElseIf $system = 64 Then Run("C:\Program Files\Google\Chrome\Application\chrome.exe","",@SW_MAXIMIZE,"") EndIf EndSelect WEnd sleep(1000) EndFunc Func DoLogin() $module = "Login" Sleep(5000) ; click address bar MouseClick("primary",130,39,3,75) Sleep(1000)the rest of the code contains sensitive information Link to comment Share on other sites More sharing options...
BrewManNH Posted October 16, 2012 Share Posted October 16, 2012 First things first, you run the program with your button, but you never exit the While loop, so it will never do anything other than run the browser chosen. You should use an ExitLoop after running the browser.Secondly, these lines "_GUICtrlButton_Enable(xx)" are totally unnecessary, the buttons are already enabled when you created them.Thirdly, why do you have separate Run lines for $system = 32 or 64 when they both use the exact same command to run the programs?Fourthly, lose the Sleep(1000) after the Wend statement, it's not doing anything, and even if it did it would make your program very unresponsive. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
LetsAuto Posted October 16, 2012 Author Share Posted October 16, 2012 the sleep(1000) is just the standard for where I am. also the $system = 32 or 64 is because i had differen Run events (program files x86, and no x86). also, where do i need the exitloop you were speaking of? Link to comment Share on other sites More sharing options...
LetsAuto Posted October 16, 2012 Author Share Posted October 16, 2012 Thanks so much guys! I figured out where to put that exitLoop and everything is working now. thanks again!! this was very helpful Link to comment Share on other sites More sharing options...
BrewManNH Posted October 16, 2012 Share Posted October 16, 2012 I'm glad it worked. BTW, with a sleep(1000), if it were inside the While loop, would make your buttons very hard to interact with and when using GUIGetMsg is not needed. GUIGetMsg sleeps the script for 10ms or so if there are no events to process. It is best to keep the sleep low inside the While loop if you're using it to check controls. What would happen is the script will sleep for 1 second, during which time you can't interact with your controls at all. Then it wakes up, and goes through the message loop very quickly, then sleeps again for 1 second. That means you have to hold the buttons down to make them activate. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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