Scrippter Posted October 26, 2009 Share Posted October 26, 2009 Alright is is what i got, I have a file that i want to read from, if the value of the read line creates a network connection, then write it to a file. I done most of the code, but cant seem to find a way to detect if the connection fails. expandcollapse popup#include <Inet.au3> Global $answer1, $answer2,$answer3,$anser4,$answer5 ;HotKeySet("{END}", "Terminate") ProgressOn("A Scrippter Production", "Opening program", "0 %") For $i = 0 to 100 step 1 sleep(10) ; wait time. ProgressSet( $i, $i & " %") ; set the progress meter to the variable $i. Next ProgressSet(100 , "Done", "Complete") ; when the loop is complete, set the progress meter to 100 percent. sleep(500) ; wait a half of a second. ProgressOff() ; close the progress meter. $PublicIP = _GetIP() $file = FileOpen("c:\names.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached $answer1 = FileReadLine($file,1) $answer2=FileReadLine($file,2) $answer3=FileReadLine($file,3) $answer4=FileReadLine($file,4) $answer5=FileReadLine($file,5) ;If @error = -1 Then ExitLoop ;$answer1 = InputBox("Selection 1", "What do you want to Log on with?", "", "", _ ;-1, -1, 0, 0) ;$answer2 = InputBox("Selection 2", "What do you want to Log on with?", "", "", _ ;-1, -1, 0, 0) Call ("user") Func user () Send("{LWINDOWN}r{LWINUP}") WinWait("Run","") If Not WinActive("Run","") Then WinActivate("Run","") WinWaitActive("Run","") Send("control netconnections{ENTER}") WinWait("Network Connections","") WinWaitActive("Network Connections","") WinWait("Network Connections","FolderView") If Not WinActive("Network Connections","FolderView") Then WinActivate("Network Connections","FolderView") WinWaitActive("Network Connections","FolderView") Call ("Answer1") EndFunc Func Answer1 () MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer1) Send ("{TAB}") Send($answer1) Send ("{ENTER}") sleep(3000) WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) call ("Answer2") EndFunc Func Answer2 () MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer2) Send ("{TAB}") Send($answer2) Send ("{ENTER}") WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) Call("Answer3") EndFunc Func Answer3 () MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer3) Send ("{TAB}") Send($answer3) Send ("{ENTER}") WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) Call ("Answer4") EndFunc Func Answer4 () MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer4) Send ("{TAB}") Send($answer4) Send ("{ENTER}") sleep(3000) WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) Call ("Answer5") EndFunc Func Answer5 () MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer5) Send ("{TAB}") Send($answer5) Send ("{ENTER}") WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) Call ("Terminate") EndFunc Func Terminate () Exit 0 EndFunc would creating an array be easier? Plus im not sure how to incorporate it into this. Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 26, 2009 Share Posted October 26, 2009 That looks way over-complicated. What is the source text file from? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 a text file that sits in my c:\ Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 that $PublicIP = _GetIP() code is for future developmet, later im going to add a box that states what the ip is Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 yeah its complicated, i dont know the commands to call a network connection, so i used the script writer to trace my actions, and then adjusted it. Is there a better way to call a network connection? Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 26, 2009 Share Posted October 26, 2009 What do you mean by calling a network connection? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 i want to connect to my Wan Mini Port PPPOE Link to comment Share on other sites More sharing options...
Authenticity Posted October 26, 2009 Share Posted October 26, 2009 You do realize that all those Func AnswerX function do the same but operate on different variables? I think that defining a single function as follows and iterating over an array, or sending it a variable will make it shorter:Func Answer($answer) MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then _ WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer, 1) Send ("{TAB}") Send($answer, 1) Send ("{ENTER}") sleep(3000) WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) EndFunc..then you can call it like this:Answer($answer1) Answer($answer2) ;...This one will block your script forever if the error window is never shown. Find a better way or use the timeout parameter of the function.WinWait("Error Connecting to Tester","") Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 26, 2009 Share Posted October 26, 2009 That is also just a step to reach your goal. I guess you've got more then one network interface and you want to test which one can connect to the WAN? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 Basiclly in a nut shell i saved my user names in a txt file. I want to read that file and input it to my PPPOE Connection, and if it fails then delete the last name tried and resave the file, then move on to next name. Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 26, 2009 Share Posted October 26, 2009 i want to connect to my Wan Mini Port PPPOESo, where do the multiple username/password combinations in the file come from? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 yeah i tried to use a time out, but then when the connection does fail, its not caught. Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 in my test server i use the same text for user name and password, i read it line by line from a txt file on my hardrive. Its a file i created with one username per line. Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 (edited) ok here is the reformated file, the suggestion by Authenticity was great. expandcollapse popup#include <Inet.au3> Global $answer1, $answer2,$answer3,$anser4,$answer5 ;HotKeySet("{END}", "Terminate") ProgressOn("A Team 102 Production", "Opening program", "0 %") For $i = 0 to 100 step 1 sleep(10) ; wait time. ProgressSet( $i, $i & " %") ; set the progress meter to the variable $i. Next ProgressSet(100 , "Done", "Complete") ; when the loop is complete, set the progress meter to 100 percent. sleep(500) ; wait a half of a second. ProgressOff() ; close the progress meter. $PublicIP = _GetIP() $file = FileOpen("c:\names.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached $answer1 = FileReadLine($file,1) $answer2=FileReadLine($file,2) $answer3=FileReadLine($file,3) $answer4=FileReadLine($file,4) $answer5=FileReadLine($file,5) ;If @error = -1 Then ExitLoop Call ("user") Func user () Send("{LWINDOWN}r{LWINUP}") WinWait("Run","") If Not WinActive("Run","") Then WinActivate("Run","") WinWaitActive("Run","") Send("control netconnections{ENTER}") WinWait("Network Connections","") WinWaitActive("Network Connections","") WinWait("Network Connections","FolderView") If Not WinActive("Network Connections","FolderView") Then WinActivate("Network Connections","FolderView") WinWaitActive("Network Connections","FolderView") Call ("Answer") EndFunc Func Answer($answer) MouseClick("left",23,169,2) WinWait("Connect Tester","&Save this user name") If Not WinActive("Connect Tester","&Save this user name") Then _ WinActivate("Connect Tester","&Save this user name") WinWaitActive("Connect Tester","&Save this user name") Send($answer, 1) Send ("{TAB}") Send($answer, 1) Send ("{ENTER}") sleep(3000) WinWait("Error Connecting to Tester","") If Not WinActive("Error Connecting to Tester","") Then WinActivate("Error Connecting to Tester","") WinWaitActive("Error Connecting to Tester","") Send("{TAB}{ENTER}") sleep(3000) EndFunc Answer($answer1) Answer($answer2) Answer($answer3) Answer($answer4) Answer($answer5) Call ("Terminate") Func Terminate () Exit 0 EndFunc Edited October 26, 2009 by Scrippter Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 maybe i can reduce more text by somehow getting it to read the file line by line with telling it to, kinda like $answer4=FileReadLine($file,4) but have it add the next line and also add the answer, so the next step would be $answer5=FileReadLine($file,5) but without typing it out, i think i need an aray of some type. What you think Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 (edited) ok, its 1:22 am here, and i have to get up and fight a war tomorrow, ill check back after patrol tomorrow, i mean today. Edited October 26, 2009 by Scrippter Link to comment Share on other sites More sharing options...
Scrippter Posted October 26, 2009 Author Share Posted October 26, 2009 thanks to all thats helping me Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 27, 2009 Share Posted October 27, 2009 If you want to test the connection of your WAN with different username and password combinations, wouldn't it be easier to do it via rasdial and commandline? http://technet.microsoft.com/de-de/library/dd450369%28en-us,WS.10%29.aspx Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Scrippter Posted October 27, 2009 Author Share Posted October 27, 2009 If you want to test the connection of your WAN with different username and password combinations, wouldn't it be easier to do it via rasdial and commandline?http://technet.microsoft.com/de-de/library/dd450369%28en-us,WS.10%29.aspx yep, thats it, thanks Xenobiologist you saved me a ton of time Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 27, 2009 Share Posted October 27, 2009 No Problem. All you need is a good description of what you want to achieve, then the forum will nearly always give you a solution. If you need help with calling the rasdial.exe with username and passwort combinations from your file - just let me know. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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