immerume2 Posted October 6, 2008 Share Posted October 6, 2008 I have been trying to accomplish a very simple task just to learn about Autoit and how to use it. All the below is trying to do is go into [Tool]->[internet Options]->[Connections]->[Lan Settings] and then click the check box that is next to "Use a proxy server for your LAN", click OK and OK and then close Internet Explorer. I sounds real easy but maybe I just don't understand Autoit. The below code looks like it should work fine to me but all it does is goes into the Lan Settings and displays the Done message box. Can someone throw me a bone and tell suggest why it might do this? I have tried using WinWait thinking maybe there is some kind of lag in clicking the buttons and that seems not to work either. Any help is appreciated. Thank You. expandcollapse popup#include <GuiConstants.au3> GUICreate("Option", 500, 200) GUISETFONT(10,200,-1,"MS Sans Tarriff"); $BrkEnd = GUICtrlCreateButton("&Cancel", 215, 130,90, 25) $RadioSelect1 = GUICtrlCreateRadio("Change Internet Settings", 25, 50) GUISetState() While 1 ; start loop, so the script continues and does not exit. $msg = GUIGetMsg() ; listen for a message. If $msg = $GUI_EVENT_CLOSE Or $msg = $BrkEnd Then ; if exit is pressed, then exit the script. MsgBox(0,"Exit","Goodbye!") Exit EndIf If $msg = $RadioSelect1 Then ; Change the internet options settings when Selected. Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE","",@SW_MAXIMIZE) WinWait("Login to Expeditors Intranet") Send("{ALT}") Send("T") Send("O") Send("^{TAB}") Send("^{TAB}") Send("^{TAB}") Send("^{TAB}") Send("L") WinWait("Local Area Network (LAN) Settings") ControlClick("Local Area Network","Use a pro&xy",1570) ControlClick("Local Area Network (LAN) Settings", "OK",1) WinWait("Internet Options") ControlClick("Internet Options", "OK",1) WinClose("Expeditors Intranet") MsgBox(0,"Turn On/Off Nss","Done!!") Exit EndIf ;~ Send("{TAB}") ;~ Send("{TAB}") ;~ Send("{SPACE}") ;~ Send("{TAB}") ;~ Send("{ENTER}") ;~ Send("{TAB}") ;~ Send("{ENTER}") WEnd ; end loop. Link to comment Share on other sites More sharing options...
bluerein Posted October 6, 2008 Share Posted October 6, 2008 maybe "pro&xy" is wrong?? Link to comment Share on other sites More sharing options...
herewasplato Posted October 6, 2008 Share Posted October 6, 2008 maybe "pro&xy" is wrong??No - that is okay :-) @immerume2, Welcome to the forum! It is a great place to learn AutoIt. The second WinWait in this part of your code might be your problem. You might want to add the info I've added in RED to "line 4". 1 WinWait("Local Area Network (LAN) Settings") 2 ControlClick("Local Area Network","Use a pro&xy",1570) 3 ControlClick("Local Area Network (LAN) Settings", "OK",1) 4 WinWaitActive("Internet Options") 5 ControlClick("Internet Options", "OK",1) 6 WinClose("Expeditors Intranet") Your AutoIt code might be executing faster than the GUI for IE can respond. Here is what might be happening: The ControlClick in "line 3" is executed... The WinWait in "line 4" is evaluated and found to be true because... ...the window named "Internet Options" is already present ...but it is not ready to receive your next line of ControlClick on the OK button ...because the window named "Local Area Network (LAN) Settings" has not had time to go away yet. Another coding option for that segment of your code might be to use WinWaitClose:WinWait("Local Area Network (LAN) Settings") ControlClick("Local Area Network","Use a pro&xy",1570) ControlClick("Local Area Network (LAN) Settings", "OK",1) WinWaitClose("Local Area Network (LAN) Settings", "OK") ControlClick("Internet Options", "OK",1) WinClose("Expeditors Intranet") I see that you are closing the Internet Explorer application after completing this proxy change. If you don't need the browser open, then you might consider just opening the "Internet Options" Control Panel Applet (CPL). You can use this line of code to do that: Run("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4") That one line will take you straight to the connections tab. NOTICE: the window title is different "Internet Properties" - but it does the same thing. You mentioned that you were using this script to learn AutoIt. Great! There are some good lessons to be learned from the task that you picked. It is probably possible to perform the entire task that you want to accomplish without opening the Internet Options or Internet Properties interface - like changing these registry settings directly... but that lesson is for another day :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
immerume2 Posted October 6, 2008 Author Share Posted October 6, 2008 Thank you very much for your reply. It is reassuring to get such a good response. I will try to finish it out this way first and then run one up using internet options. I figured doing it through IE would be a good way to test out the commands. Thank You again for the great response. No - that is okay :-) @immerume2, Welcome to the forum! It is a great place to learn AutoIt. The second WinWait in this part of your code might be your problem. You might want to add the info I've added in RED to "line 4". 1 WinWait("Local Area Network (LAN) Settings") 2 ControlClick("Local Area Network","Use a pro&xy",1570) 3 ControlClick("Local Area Network (LAN) Settings", "OK",1) 4 WinWaitActive("Internet Options") 5 ControlClick("Internet Options", "OK",1) 6 WinClose("Expeditors Intranet") Your AutoIt code might be executing faster than the GUI for IE can respond. Here is what might be happening: The ControlClick in "line 3" is executed... The WinWait in "line 4" is evaluated and found to be true because... ...the window named "Internet Options" is already present ...but it is not ready to receive your next line of ControlClick on the OK button ...because the window named "Local Area Network (LAN) Settings" has not had time to go away yet. Another coding option for that segment of your code might be to use WinWaitClose:WinWait("Local Area Network (LAN) Settings") ControlClick("Local Area Network","Use a pro&xy",1570) ControlClick("Local Area Network (LAN) Settings", "OK",1) WinWaitClose("Local Area Network (LAN) Settings", "OK") ControlClick("Internet Options", "OK",1) WinClose("Expeditors Intranet") I see that you are closing the Internet Explorer application after completing this proxy change. If you don't need the browser open, then you might consider just opening the "Internet Options" Control Panel Applet (CPL). You can use this line of code to do that: Run("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4") That one line will take you straight to the connections tab. NOTICE: the window title is different "Internet Properties" - but it does the same thing. You mentioned that you were using this script to learn AutoIt. Great! There are some good lessons to be learned from the task that you picked. It is probably possible to perform the entire task that you want to accomplish without opening the Internet Options or Internet Properties interface - like changing these registry settings directly... but that lesson is for another day :-) Link to comment Share on other sites More sharing options...
herewasplato Posted October 6, 2008 Share Posted October 6, 2008 Thank you very much for your reply. ...You are welcome.Enjoy AutoIt and this forum :-) [size="1"][font="Arial"].[u].[/u][/font][/size] 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