cadeleon Posted July 29, 2011 Share Posted July 29, 2011 Hi there ! Newbie question. Im creating a program to automate entry of the username and password in an intranet website for our company. The username consists of some characters and a variable which is the third octet of the IP address of the PC hosting the script. My problem is that the variable is only showing the first number. Some numbers have 2 and some have three but nevertheless, send is only sending the first integer of the variable represented. Help!!! $chosenip = Run ("c:\ipget.bat");This batch file is actually doing a single ping and sends it to a file called pingtest.txt $pStr = FileRead ("c:\PINGtest.txt") $oct = StringSplit($pStr , ".") $range = $oct[1] & "." & $oct[2] & "." & $oct[3] & "." & $oct[4] MsgBox(0, "You are now in Computer number:", $oct[3]);at this point, all is still ok. $sComputernumber = $oct[3] Local $sUserName = "comp-" & $oct[3] Local $sPassword = "<password>" Local $sDomain = "<dummy.com>" run ("C:\Program Files\Internet Explorer\iexplore.exe https://www.intranetwebsite.net/operations") WinWaitActive("Connect to www.intranetwebsite.net") sleep(100) ;Enter Login Credentials sleep(100) send("comp-{"& $sComputernumber & "}");This is where my problem is. $$sComputernumber for some reason only outputs the first integer. Say, if the computer is comp-195. Output will only be comp-1 sleep (100) ;send ("{TAB}") Sleep(2000) ;Send("<password>{ENTER}") Sleep(100) Link to comment Share on other sites More sharing options...
JohnOne Posted July 29, 2011 Share Posted July 29, 2011 (edited) Depends on how your ip.bat works, but try this $chosenip = RunWait ("c:\ipget.bat");This batch file is actually doing a single ping and sends it to a file called pingtest.txt $pStr = FileRead ("c:\PINGtest.txt") $soct = StringStripWS($pStr) $oct = StringSplit($soct, ".") EDIT: Or even $pStr = @IPAddress1 $oct = StringSplit($pStr, ".") Edited July 29, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cadeleon Posted July 29, 2011 Author Share Posted July 29, 2011 Depends on how your ip.bat works, but try this $chosenip = RunWait ("c:\ipget.bat");This batch file is actually doing a single ping and sends it to a file called pingtest.txt $pStr = FileRead ("c:\PINGtest.txt") $soct = StringStripWS($pStr) $oct = StringSplit($soct, ".") EDIT: Or even $pStr = @IPAddress1 $oct = StringSplit($pStr, ".") HI John thanks for your reply. Here is what is contained on Pingtest.txt Pinging mylaptop3 [192.168.152.72] with 32 bytes of data: Reply from 192.168.152.72: bytes=32 time<1ms TTL=128 Ping statistics for 192.168.152.72: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms Link to comment Share on other sites More sharing options...
JohnOne Posted July 29, 2011 Share Posted July 29, 2011 So the above cod amendments work then? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cadeleon Posted July 29, 2011 Author Share Posted July 29, 2011 Hi there. I tested your suggestions and it still did not fix the problem. Thanks though for presenting me with the line $pstr = @ipaddress. This saved me some tow lines of code and relying on the batch file for the results. $soct = StringStripWS($pStr) does not work (Had an error) so i tried everything except this time I used $pStr = @IPAddress1. I still got the same results. (Please see attached.). The third octet of my IP address is 100 and the username is only showing comp-1. Should show comp-100. Link to comment Share on other sites More sharing options...
JohnOne Posted July 29, 2011 Share Posted July 29, 2011 Pretty weird Try Local $sUserName = "comp-" & String($sComputernumber) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cadeleon Posted July 29, 2011 Author Share Posted July 29, 2011 Well, I did not find what the solution was but I found a workaround. What I did was that I created a subroutine to copy the third octet to a file then tell the program to read the entry from that file and completely write all of the third octet onto the field. Final program looks like this...Thanks for all your help ! $pStr = @IPAddress1 $oct = StringSplit($pStr , ".") $range = $oct[1] & "." & $oct[2] & "." & $oct[3] & "." & $oct[4] MsgBox(0, "You are now on comp-", $oct[3]) ;;This subroutine saves the 3rd octet to a temporary text file called c:\temp\test.txt $file = FileOpen("c:\temp\test.txt", 1);this creates a blank file called test.txt file If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf filewrite("c:\temp\test.txt" , $oct[3]);this writes the 3rd octet onto the text file) $ipoct = FileReadLine($File);This reads the line written to memory ans assigned a variable $ipoct FileClose($file) filedelete("c:\temp\test.txt") https://www.intranet.net/operations") run ("C:\Program Files\Internet Explorer\iexplore.exe https://www.intranet.net/storeoperations") WinWaitActive("Connect to www.intranet.net") sleep(100) ;Enter Login Credentials sleep(100) send("comp-") send($ipoct) sleep (100) send ("{TAB}") Sleep(2000) Send("<password>{ENTER}") Sleep(100) Link to comment Share on other sites More sharing options...
JohnOne Posted July 29, 2011 Share Posted July 29, 2011 Its good you found a workaround, but its a great deal to do to get that desired result. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cadeleon Posted July 29, 2011 Author Share Posted July 29, 2011 Well, this is my first program using autoit and I am still getting my feet wet in this environment. I have done a lot of scripts before but this was to modify logins, create batch files to automate mundane processes, mostly admin stuff. I was introduced to this program very recently by one of my colleagues. Now that I got my first program going, I can get more creative =) Thanks again! Link to comment Share on other sites More sharing options...
JohnOne Posted July 29, 2011 Share Posted July 29, 2011 (edited) Indeed. You could start with getting familiar with Control* functions an example would be $hWnd = WinWaitActive("Connect to www.intranetwebsite.net"); returns a handel to the window If you use the window info toll, its possible to get info about the controls in it, so you couls use ControlSend(), or ControlSetText() using the window handle and the control ID of the input field. So say for instance, the window became minmized somehow, the data would still get sent to the control. Edited July 29, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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