mannrak2003 Posted October 8, 2006 Share Posted October 8, 2006 Hello everybody, I am from India and I am new to coding.I will comment the code later .Please forgive me for that.I ahve posted my code as an attachment Please advise me on this.I am working on TO CONNECT TO ONLY ONE DIALUP SERVER AMONG THREE ,IE FROM 61.1.253.1,61.1.253.5 AND 61.1.253.12 I WANT TO CONNECT ONLY TO 61.1.253.12..HOW TO DO THAT,PLEASE ?I have written the code in patches. I am using the "rasphone.exe -s" (Connection Manager) 's functionality to detect the dial up server.That is once the connection is established the "Details" button on Connection Manager window becomes enabled. Then "ControlClick" button,"Network registration" window appears.From this i try to detect the text of "Static7"which is address of the dial up server,when Static7 is"IsVisible."And then after converting"Static7 "string output to number afterstring-to-array conv,stripping of dots of IPaddress.then converting back to Number type using "Number()" function Here I have a doubt .Should I convert it to Number or Int ?And then finally using Logic algorithm to filter the IPie ,$notdesiredserver = ($z1 <> 61125312)Is anything wrong with the following code?;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; expandcollapse popupMsgBox(0,"The final number form we required",$z1) $notdesiredserver = ($z1 <> 61125312) MsgBox(0,"We check for notdesiredserver",$notdesiredserver) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; ;HERE IS THE PROBLEM PART.$notdesiredserver ALWAYS RETURNS TRUE.PlEASE ADViCE ME ON A BETTER WAY FO CODING THIS. If $notdesiredserver = False Then endscript() ;WHAT IS THE PROBLEM WITH THIS STATEMENT? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MsgBox(4096,"Your dial up server is",$var,1) Run("rasphone.exe -h gate") $list = ProcessList("rasphone.exe") For $j = 1 to $list[0][0] ProcessClose($list[$j][0]) Next If ProcessExists("rasphone.exe") Then ProcessWaitClose("rasphone.exe") EndIf EndIf EndIf Next Msgbox(4096,"THE BSNL","Won't allow me to connect to 61.1.253.12") Func endscript() MsgBox(0,"","after last statement " & @EXITMETHOD) EndFunc Func MyExit() Exit EndFunc 61.1.253.12_AutoIt_v3_Script.au3 Link to comment Share on other sites More sharing options...
/dev/null Posted October 8, 2006 Share Posted October 8, 2006 what's the value of $text and $z1? MsgBox(0, "All spaces stripped", $text) $z1 = Number($text) MsgBox(0,"The final number form we required",$z1) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
mannrak2003 Posted October 8, 2006 Author Share Posted October 8, 2006 (edited) what's the value of $text and $z1? MsgBox(0, "All spaces stripped", $text) $z1 = Number($text) MsgBox(0,"The final number form we required",$z1) Cheers Kurt Hope, the follwing code will help you in understanding my problem,Sir Thank you $var = ControlGetText("classname=#32770", "Network Registration", "Static7") $array = StringSplit($var, '.') $avArray = _ArrayCreate($array[1], $array[2], $array[3], $array[4]) _ArrayDisplay( $avArray, "Array created with _ArrayCreate" ) Dim $sArrayString = _ArrayToString( $avArray,@TAB) MsgBox( 4096, "_ArrayToString() Test", $sArrayString ) $text = StringStripWS($sArrayString,8) MsgBox(0, "All spaces stripped", $text) $z1 = Number($text) Edited October 8, 2006 by mannrak2003 Link to comment Share on other sites More sharing options...
/dev/null Posted October 8, 2006 Share Posted October 8, 2006 $var = ControlGetText("classname=#32770", "Network Registration", "Static7") $array = StringSplit($var, '.') $avArray = _ArrayCreate($array[1], $array[2], $array[3], $array[4]) _ArrayDisplay( $avArray, "Array created with _ArrayCreate" ) Dim $sArrayString = _ArrayToString( $avArray,@TAB) MsgBox( 4096, "_ArrayToString() Test", $sArrayString ) $text = StringStripWS($sArrayString,8) MsgBox(0, "All spaces stripped", $text) $z1 = Number($text) ???? what's the value (content) of $text and $z1? Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
mannrak2003 Posted October 8, 2006 Author Share Posted October 8, 2006 ???? what's the value (content) of $text and $z1? Cheers Kurt Sir, $var contains the IP address of the dialup server like 61.1.253.12or the other two dailup server addresses obtained by ControlGetText Then StringSplit the address to 4 different arrays then _ArrayCreate join the four arrays into another array then _ArrayToString to a string separated by @TAB then StringStripWS remove all whitespace ,parameter 8 and store the value to $text ,ie string value of 61125312 or similar. then convert string value of 61125312 or similar. to numeric value using $z1 = Number($text) $z1 contains numeric value of IP adress stripped of points,ie,61125312 Then comes the problem !!! I dont know to use logic functions (True and False to filter out my desired dial-up server ,ie 61125312 When 61125312 is the dial-upserver the dial-up connection should remain connected and the script should stop execution. When other 2 dial-up servers are detected the dial-up connection should disconnect and script continue execution . I have put all the code inside a for loop to execute the script 10 times and then the script should stop execution Of course there are bugs like sometime carrier not present and modem wont respond and sometimes timeout occurs and modem wont respond even after acquiring Ip address. But the bugs are not importnat for the time being .I would just like to see the basic functionality. Thank You Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 8, 2006 Moderators Share Posted October 8, 2006 Don't you think it would just be smarter to post the entire script rather than section by section? Then just use comments in the script itself where you are running into issues at? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
mannrak2003 Posted October 8, 2006 Author Share Posted October 8, 2006 (edited) Don't you think it would just be smarter to post the entire script rather than section by section? Then just use comments in the script itself where you are running into issues at?OK ,Sir Here goes expandcollapse popup$g_szVersion = "My Script 1.1" If WinExists($g_szVersion) Then Exit; It's already running AutoItWinSetTitle($g_szVersion) HotKeySet("^!x", "MyExit") #include <Array.au3> Dim $avArray Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Opt("OnExitFunc", "endscript") ;MsgBox(0,"","first statement") For $i=1 To 10 ;~ Const $scUserAgent = "WinInet Example" ;~ $INTERNET_OPEN_TYPE_PRECONFIG = 0x0 ;~ $aiInternetAttemptConnect=DllCall("WinInet.dll","int","InternetAttemptConnect","int",0) ;~ If $aiInternetAttemptConnect[0] <> 0 Then Exit ;~$aiInternetOpen=DllCall("WinInet.dll","int","InternetOpen","str","$scUserAgent","int",$INTERNET_OPEN_TYPE_PRECONFIG,"str","","str","","int",0) ;~ $isConnectToISP=($aiInternetOpen[0]=0) ;~ If $aiInternetOpen[0]=0 Then ;~ $isConnectToISP=False ;~ MsgBox(4096,"FALSEisConnecttoISP","FALSE") ;~ Else ;~ $isConnectToISP=True ;~ MsgBox(4096,"isConnecttoISP","true") ;~ EndIf Run("rasphone.exe -d gate") WinWait("classname=#32770","&Save Password") If Not WinActive("classname=#32770","&Save Password") Then WinActivate("classname=#32770","&Save Password") WinWaitActive("classname=#32770","&Save Password") ControlFocus("classname=#32770","&Save Password",1590) ControlClick("classname=#32770","&Save Password",1590) Run("rasphone.exe -s") WinWait("classname=#32770","Connection statistic") If Not WinActive("classname=#32770","Connection statistic") Then WinActivate("classname=#32770","Connection statistic") WinWaitActive("classname=#32770","Connection statistic") ;-------------------------------------------------------------------------------------------- ;check $ret[0] for trueness, and $ret[1] for type of connection according to variables provided... ;-------------------------------------------------------------------------------------------- $INTERNET_CONNECTION_MODEM = 0x1 $INTERNET_CONNECTION_LAN = 0x2 $INTERNET_CONNECTION_PROXY = 0x4 $INTERNET_CONNECTION_MODEM_BUSY = 0x8 $INTERNET_RAS_INSTALLED = 0x10 $INTERNET_CONNECTION_OFFLINE = 0x20 $INTERNET_CONNECTION_CONFIGURED = 0x40 Do $ret = DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0) $isconnect = ($ret[0] <> 0) If $ret[0] then ;check type of connection $sX = "" If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX = $sX & "MODEM" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX = $sX & "LAN" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX = $sX & "PROXY" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX = $sX & "MODEM_BUSY" & @LF If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX = $sX & "RAS_INSTALLED" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX = $sX & "OFFLINE" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX = $sX & "CONFIGURED" & @LF Else $sX = "Not Connected" Endif Until $isconnect=True ;~ MsgBox(4096,$ret[0] & ":" & $ret[1],$sX,2) $enabledetails=ControlCommand("classname=#32770","Connection statistic","Button5","IsEnabled", "") ;~ MsgBox(4096,"Is Details enabled ?",$enabledetails,2) If $enabledetails Then ControlFocus("classname=#32770","Connection statistic",1190) ControlClick("classname=#32770","Connection statistic",1190) WinWait("classname=#32770","Network Registration") If Not WinActive("classname=#32770","Network Registration") Then WinActivate("classname=#32770","Network Registration") WinWaitActive("classname=#32770","Network Registration") $enabledialupserver=ControlCommand("classname=#32770","Network Registration","Static7","IsVisible", "") If $enabledialupserver Then $var = ControlGetText("classname=#32770", "Network Registration", "Static7") $array = StringSplit($var, '.') $avArray = _ArrayCreate($array[1], $array[2], $array[3], $array[4]) _ArrayDisplay( $avArray, "Array created with _ArrayCreate" ) Dim $sArrayString = _ArrayToString( $avArray,@TAB) MsgBox( 4096, "_ArrayToString() Test", $sArrayString ) $text = StringStripWS($sArrayString,8) MsgBox(0, "All spaces stripped", $text) $z1 = Number($text) MsgBox(0,"The final number form we required",$z1) $notdesiredserver = ($z1 <> 61125312) MsgBox(0,"We check for notdesiredserver",$notdesiredserver) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; ;HERE IS THE PROBLEM PART.$notdesiredserver ALWAYS RETURNS TRUE.PEASEADVCE ME ON A BETTER WAY FO CODING THIS. If $notdesiredserver = False Then endscript() ;WHAT IS THE PROBLEM WITH THIS STATEMENT? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MsgBox(4096,"Your dial up server is",$var,1) Run("rasphone.exe -h gate") $list = ProcessList("rasphone.exe") For $j = 1 to $list[0][0] ProcessClose($list[$j][0]) Next If ProcessExists("rasphone.exe") Then ProcessWaitClose("rasphone.exe") EndIf EndIf EndIf Next Msgbox(4096,"THE BSNL","Won't allow me to connect to 61.1.253.12") Func endscript() MsgBox(0,"","after last statement " & @EXITMETHOD) EndFunc Func MyExit() Exit EndFunc Edited October 8, 2006 by mannrak2003 Link to comment Share on other sites More sharing options...
/dev/null Posted October 8, 2006 Share Posted October 8, 2006 (edited) Sir, $var contains the IP address of the dialup server like 61.1.253.12or the other two dailup server addresses ... too much text ... simple question: Why don't you check the IP directly, instead of removing the dot and converting it to a number ?? $current_ip = "61.1.253.11" $desired_server = "61.1.253.12" if $current_ip <> $desired_server then MsgBox(0,"","Wrong Server: " & $current_ip) else MsgBox(0,"","Good Server: " & $current_ip) EndIf Cheers Kurt Edited October 8, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
dnsi Posted October 9, 2006 Share Posted October 9, 2006 I am not getting what the poster guy said. My Programs:Flip-Flop File Encryption SysyemMULTIPLAYER-SOCKETSERVERHide An Archive In A Picture Link to comment Share on other sites More sharing options...
mannrak2003 Posted October 9, 2006 Author Share Posted October 9, 2006 I am not getting what the poster guy said.At last it works !!!!!!!!!! My joy knows no bounds :):) Thank you very much,Sir for prompting me to change my line of thought. I used StringRight to extract the rightmost character of the IP address and surprise it works !!! My first working AutoIt script !!!!! Here it goes !!!!!!!!!! expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.1.1.0 Author: Rakesh Gopalan myName Script Function:TO CONNECT TO ONLY ONE DIALUP SERVER AMONG THREE ,IE FROM 61.1.253.1,61.1.253.5 AND 61.1.253.12 I WANT TO CONNECT ONLY TO 61.1.253.12. Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; Place at the top of your script $g_szVersion = "My Script 1.1" If WinExists($g_szVersion) Then Exit; It's already running AutoItWinSetTitle($g_szVersion) HotKeySet("^!x", "MyExit") Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Opt("OnExitFunc", "endscript") Global $ipright Do Run("rasphone.exe -d gate") WinWait("classname=#32770","&Save Password") If Not WinActive("classname=#32770","&Save Password") Then WinActivate("classname=#32770","&Save Password") WinWaitActive("classname=#32770","&Save Password") ControlFocus("classname=#32770","&Save Password",1590) ControlClick("classname=#32770","&Save Password",1590) Run("rasphone.exe -s") WinWait("classname=#32770","Connection statistic") If Not WinActive("classname=#32770","Connection statistic") Then WinActivate("classname=#32770","Connection statistic") WinWaitActive("classname=#32770","Connection statistic") ;-------------------------------------------------------------------------------------------- ;check $ret[0] for trueness, and $ret[1] for type of connection according to variables provided... ;-------------------------------------------------------------------------------------------- $INTERNET_CONNECTION_MODEM = 0x1 $INTERNET_CONNECTION_LAN = 0x2 $INTERNET_CONNECTION_PROXY = 0x4 $INTERNET_CONNECTION_MODEM_BUSY = 0x8 $INTERNET_RAS_INSTALLED = 0x10 $INTERNET_CONNECTION_OFFLINE = 0x20 $INTERNET_CONNECTION_CONFIGURED = 0x40 Do $ret = DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0) $isconnect = ($ret[0] <> 0) If $ret[0] then ;check type of connection $sX = "" If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX = $sX & "MODEM" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX = $sX & "LAN" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX = $sX & "PROXY" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX = $sX & "MODEM_BUSY" & @LF If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX = $sX & "RAS_INSTALLED" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX = $sX & "OFFLINE" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX = $sX & "CONFIGURED" & @LF Else $sX = "Not Connected" Endif Until $isconnect=True ;~ MsgBox(4096,$ret[0] & ":" & $ret[1],$sX,2) $enabledetails=ControlCommand("classname=#32770","Connection statistic","Button5","IsEnabled", "") ;~ MsgBox(4096,"Is Details enabled ?",$enabledetails,2) If $enabledetails Then ControlFocus("classname=#32770","Connection statistic",1190) ControlClick("classname=#32770","Connection statistic",1190) WinWait("classname=#32770","Network Registration") If Not WinActive("classname=#32770","Network Registration") Then WinActivate("classname=#32770","Network Registration") WinWaitActive("classname=#32770","Network Registration") $enabledialupserver=ControlCommand("classname=#32770","Network Registration","Static7","IsVisible", "") If $enabledialupserver Then $current_ip = ControlGetText("classname=#32770", "Network Registration", "Static7") $ipright = StringRight($current_ip,1) ;~ MsgBox(0,"Rightmost of IP",$ipright) If $ipright = "2" Then MsgBox(0,"","Good Server: " & $current_ip,1) Else MsgBox(0,"","Wrong Server: " & $current_ip,1) Run("rasphone.exe -h gate") $list1 = ProcessList("rasphone.exe") For $j = 1 to $list1[0][0] ProcessClose($list1[$j][0]) Next If ProcessExists("rasphone.exe") Then ProcessWaitClose("rasphone.exe") EndIf EndIf EndIf EndIf Until $ipright = "2" Msgbox(4096,"THE BSNL","Finally connected to 61.1.253.12 !!!",1) Func endscript() MsgBox(0,"","after last statement " & @EXITMETHOD,1) EndFunc Func MyExit() Exit EndFunc 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