jodayautoit Posted May 5, 2011 Author Posted May 5, 2011 Hi All! I was able to add the checking code and get this script to check the correct page as written below. In this case the user input IP Address is the same as what http://x.x.x.x is. My last part of this is to figure out if just changing http:// to ($sourceip) will allow the user input and the script to work. Currently this script works correctly as long as the http://x.x.x.x is assigned in the code and I type in the same IP address when the input box is shown. If anyone has suggestions or other input it is greatly appreciated. I am still a newbie to this scripting tool. Thanks jodayautoit expandcollapse popup#include <INet.au3> #include <IE.au3> $sourceip = InputBox("Web Test Script", "Enter the IP address . Example x.x.x.x") $oIE = _IECreate($sourceip) Sleep(2000) Send("username") Sleep(2000) Send("{TAB}") ;Code for Password input Sleep(2000) Send("password") Send("{ENTER}") Local $URL_Array[2] = ["http://x.x.x.x", "http://x.x.x.x/htm_login.htm"] Local $Text_Array[2] = ["Web", "Login"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://x.x.x.x/htm_login.htm") & @CR & @CR) Next Local $URL_Array[2] = ["http://x.x.x.x", "http://x.x.x.x/htm_menu.htm/htm_login.htm"] Local $Text_Array[2] = ["Menu", "Start"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://x.x.x.x/htm_menu.htm/htm_login.htm") & @CR & @CR) Next ;some other test code with mouse clicks etc.
somdcomputerguy Posted May 5, 2011 Posted May 5, 2011 (edited) Instead of re-defining the two array variables to add two more checks, define them as $URL_Array[4] and $Text_Array[4]. Then change the For loop to '0 To 3'. So that part of your code will look like this. I also added an Else statement to the If loop, just if or if not the page is 'Ok'. Local $URL_Array[4] = ["http://x.x.x.x", "http://x.x.x.x/htm_login.htm", "http://x.x.x.x", "http://x.x.x.x/htm_menu.htm/htm_login.htm"] #cs <- comment start or like this - Local $URL_Array[4] = ["http://x.x.x.x", _ "http://x.x.x.x/htm_login.htm", _ "http://x.x.x.x", _ "http://x.x.x.x/htm_menu.htm/htm_login.htm"] #ce ;<- comment end Local $Text_Array[4] = ["Web", "Login", "Menu", "Start"] For $a = 0 To 3 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) Else ConsoleWrite("Page Not OK" & @LF) EndIf ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://x.x.x.x/htm_login.htm") & @CR & @CR) Next ;some other test code with mouse clicks etc. Edited May 5, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change.
jodayautoit Posted May 5, 2011 Author Posted May 5, 2011 Thanks somdcomputerguy! I am following what you have for the multiple array. However I am still confused as to adding it using a user specific IP address at the being of the script. As you have seen in my previous post I use $sourceip and I still have not figured out how to substitute it in these checks. I am getting the sytanx wrong since I get errors when I try to change where http: is and put $sourceip. If you could kindly tell me what is wrong with the following example I will be able to see what I am doing wrong. Part of you example Local $URL_Array[4] = ["http://x.x.x.x", "http://x.x.x.x/htm_login.htm", "http://x.x.x.x", "http://x.x.x.x/htm_menu.htm/htm_login.htm"] I would substitute like this????? which I know is wrong via syntax or just not how you use the function but I need an explaination why. Local $URL_Array[4] = [$sourceip,$sourceip/htm_login.htm,$sourceip/htm.menu.htm/htm_login.htm]
somdcomputerguy Posted May 5, 2011 Posted May 5, 2011 Put $sourceip into the array like this Local $URL_Array[4] = ["http://" & $sourceip & """, "http://" & $sourceip & "/htm_login.htm", "http://x.x.x.x", "http://x.x.x.x/htm_menu.htm/htm_login.htm"] Well, like I started anyway. It's called 'string concatenation'. Look it up in the help file for more, it'll be explained better there than I could. See the ampersands? That's what does it. - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change.
jodayautoit Posted May 6, 2011 Author Posted May 6, 2011 Hi all! I have added the code for my webpage checking. Here is the basic code to accomplish what I was trying to test in case someone else has a similar project. Thanks to all on assisting me with my script. Below is the code and at the bottom I put what the console output is. I will be adding the suggested code from somdcomputerguy on changing the array to 4 in his example as a different script.There are probably a couple things that need tidy up that I can do later. For the most part I am satisfied this is a good start for my project. jodayautoit expandcollapse popup#include <INet.au3> #include <IE.au3> ;Code to get user input for IP address $sourceip = InputBox("Web", "Enter the IP address") ;Code to make sure valid address or script exits. If $sourceip = 0 Then Exit EndIf ; Create a browser window , maximize it and navigate to selected IP address of Web $oIE = _IECreate($sourceip) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) _IEAction($oIE, "visible") _IELoadWait($oIE) ;Code for Username input Sleep(2000) Send("Username") Sleep(2000) Send("{TAB}") ;Code for Password input Sleep(2000) Send("Password") Send("{ENTER}") ;Code to check Webpage has loaded and contains valid information for that page ;In this example there is one page containing 3 Frame sets the first frame is main_htm = the main page of the IP Address ;the second frame = /htm_login.htm and the third frame = htm_menu.htm. The ConsoleWrite was for debugging the Script ;to verify the "Checking" code and the _INetGetSource is loading the correct HTML data. It is commented out ;since it is not longer needed. Local $URL_Array[2] = [ "http://" & $sourceip & "","http://" & $sourceip & "/htm_login.htm "] Local $Text_Array[2] = ["Web", "login"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) ;ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://" & $sourceip & "/htm_login.htm ") & @CR & @CR) Next Local $URL_Array[2] = ["http://" & $sourceip & "","http://" & $sourceip & "/htm_menu.htm/htm_login.htm "] Local $Text_Array[2] = ["Web", "Start-up"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) ;ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://" & $sourceip & "/htm_menu.htm/htm_login.htm") & @CR & @CR) Next ;put other testing code here Test results of script >Running:(3.3.2.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Examples\samplepagecheck.au3" Checking.. Page OK Checking.. Checking http://x.x.x.x - Page OK Checking http://x.x.x.x/htm_login.htm - Page OK Checking http://x.x.x.x - Page OK Checking http://x.x.x.x/htm_menu.htm/htm_login.htm - Page OK +>08:30:43 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 184.385
jodayautoit Posted May 9, 2011 Author Posted May 9, 2011 Hi All! Since I have been able to get the results of the webpages to print to the console whether "Page Ok" or "Page not OK" I also thought it would be of benefit to have it log to a file. I looked at the examples for the FILEOPEN and FileWrite functions. I was able to get my first test case to log but the second test case seems to be logging a double input. I am slightly confused as to why. Could some one look at the two test cases and the test result file and point out what I am doing wrong. It appears I have part of the FileWrite working but not completely. My objective is to have it log similar as what is shown in the console. Also I noticed if I do not put the same FileOpen function as in the Page OK into the Page Not OK it will not log it to the file. I am probably doing this a hard way. Any suggestions or input is greatly appreciated. Below are the two test cases and the test result file. Thanks jodayautoit. expandcollapse popup$Pass = "Page OK" $Fail = "Page not OK" Ping($sourceip, 500) If @error = 0 Then ConsoleWrite("Pass Ping" & @LF) ;MsgBox(0, "", "Page found!") ;Code to check if correct page is loaded. ConsoleWrite("Checking.. ") ;$sHTML = _INetGetsource($oIE) $sHTML = _IEDocReadHTML($oIE) ;MsgBox(0, "Document Source", $sHTML); use this to get the correct information for $Text then comment out. Local $Text = "Login" If StringInStr($sHTML, $Text, 2) <> 0 Then ConsoleWrite("Page OK" & @LF) $file = FileOpen("testresults.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Test Results " & @CRLF) FileWrite($file, "" & @CRLF) FileWrite($file, "Test case 1 Result" & @CRLF) FileWrite($file, $Pass & @CRLF) FileWrite($file, "" & @CRLF) Else $file = FileOpen("testresults.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ConsoleWrite("Page not OK" & @LF) FileWrite($file, "Test case 1" & @CRLF) FileWrite($file, $Fail & @CRLF) FileWrite($file, "" & @CRLF) EndIf ;Code to verify IP address is active Ping($sourceip, 500) If @error = 0 Then ConsoleWrite("Pass Ping" & @LF) ;MsgBox(0, "", "Page found!") ;Code to check if correct page is loaded. Local $Text = "Login Page" If StringInStr($sHTML, $Text, 2) <> 0 Then ConsoleWrite("Checking.. ") $sHTML = _IEDocReadHTML($oIE) ;MsgBox(0, "Document Source", $sHTML); use this to get the correct information for $Text then comment out. Local $URL_Array[2] = ["http://" & $sourceip & "", "http://" & $sourceip & "/htm_setup.htm/htm_login.htm "] Local $Text_Array[2] = ["Web", "Startup"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) ;ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://" & $sourceip & "/htm_setup.htm/htm_login.htm ") & @CR & @CR) FileWrite($file, "Test case 2 Result" & @CRLF) FileWrite($file, $Pass & @CRLF) FileWrite($file, "" & @CRLF) Else ConsoleWrite("Page Not OK" & @LF) ;FileWrite($file, "Test case 2 Result" & @CRLF) FileWrite($file, $Fail) FileWrite($file, "" & @CRLF) EndIf Next EndIf Test Results Test case 1 Page OK Test case 2 Result Page OK Test case 2 Result Page OK
jodayautoit Posted May 9, 2011 Author Posted May 9, 2011 Hi All! I did some more debugging with the console printout and the File Write. My above post question I think I have the answer. It is going to print test case two twice since I have two tests in that test case. One for each part of the array. I guess I need to figure a way to have it print it the same as the console which is why I missed it earlier. Any suggestions are still greatly appreciated. Thanks jodayautoit
smartee Posted May 9, 2011 Posted May 9, 2011 I need to figure a way to have it print it the same as the consolehi, Try a custom function. Here's a quick example:Func _ConsoleFileWriteLine($_text, $fileName = -1) If $fileName = -1 Then $fileName = @ScriptDir & "\ConsoleOutput.txt" $_text &= @CRLF ConsoleWrite($_text) FileWrite($fileName, $_text) EndFunc ;==>_ConsoleFileWriteLine $addressList = StringSplit("192.0.0.1,142.12.43.23,98.123.44.2,74.125.229.113", ",") For $i = 1 To $addressList[0] _ConsoleFileWriteLine("Pinging address: " & $addressList[$i]) $pingErrors = StringSplit("Host is offline,Host is unreachable,Bad destination,Other errors", ",") $pingRoundtrip = Ping($addressList[$i], 500) If @error = 0 Then _ConsoleFileWriteLine("Ping succeeded. Roundtrip-time in milliseconds: " & $pingRoundtrip) Else _ConsoleFileWriteLine("Ping failed with @error=" & @error & ". Error details: " & $pingErrors[@error]) EndIf Next Hope this helps, -smartee
jodayautoit Posted May 9, 2011 Author Posted May 9, 2011 Thanks smartee! I compiled your example function to see how it works and it does do what I would like. I modified it into my script for the ping test and it works fine. I will have to read some more of the help file to see how I would make it a function for the page checking since each test case is going to be different , based on a different page loading and I am not sure how I can adapt one function for the whole test script yet. See my post 5/6 for what the base code looks like. It might be simple but I am still a newbie and do not have enough knowledge yet. Thanks for pointing me in the correct direction. jodayautoit
jodayautoit Posted May 10, 2011 Author Posted May 10, 2011 Hi All! I am slightly confused about how to implement what smartee had in his example on the code below to print to a file the way he suggested. I was able to modify his example and get the ping part of my script to work. I have looked at the help file but I am missing something. My above attempt for printing to a file works but is not the same as the console. I would like to make them the same if possible. Please advise if there is an an example using a Local Array and StringinStr would be involved. thanks jodayautoit ;Code to check if correct page is loaded. Local $Text = "Login Page" If StringInStr($sHTML, $Text, 2) <> 0 Then ConsoleWrite("Checking.. ") $sHTML = _IEDocReadHTML($oIE) ;MsgBox(0, "Document Source", $sHTML); use this to get the correct information for $Text then comment out. Local $URL_Array[2] = ["http://" & $sourceip & "", "http://" & $sourceip & "/htm_setup.htm/htm_login.htm "] Local $Text_Array[2] = ["Web", "Startup"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) ;ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://" & $sourceip & "/htm_setup.htm/htm_login.htm ") & @CR & @CR)
jodayautoit Posted May 10, 2011 Author Posted May 10, 2011 Hi all! I got it by simplifying smartee's Ping function to the bare minimum substituting my script. It was not obvious to me at first since I was not looking at it correctly. All I needed to do is make the code to open a file callED "testresults.txt" and add the FileWrite function after my ConsoleWrite. It works as I would expect now. So my smaller test script is finished. I thank all for their input. Below is the working code and outputs in case others have similar projects. If anyone has some improvements to make it better since I am still a newbie ,I am open to all suggestions. Thanks jodayautoit expandcollapse popup#include <INet.au3> #include <IE.au3> ;Code to get user input for IP address $sourceip = InputBox("Test Script", "Enter the IP address ") ;Code to make sure valid address or script exits. If $sourceip = 0 Then Exit EndIf ; Create a browser window , maximize it and navigate to selected IP address of Webmaster to be Tested ;$Pass = "Page OK" maybe substitute use later ;$Fail = "Page not OK" maybe substitute use later $oIE = _IECreate($sourceip) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) _IEAction($oIE, "visible") _IELoadWait($oIE) ;Code for Username input Sleep(2000) Send("Username") Sleep(2000) Send("{TAB}") ;Code for Password input Sleep(2000) Send("Password") Send("{ENTER}") ;Code to check Webpage has loaded and contains valid information for that page ;In this example there is one page containing 3 Frame sets the first frame is main_htm = the main page of the IP Address ;the second frame = /htm_login.htm and the third frame = htm_menu.htm. The ConsoleWrite was for debugging the Script ;to verify the "Checking" code and the _INetGetSource is loading the correct HTML data. It is commented out ;since it is not longer needed. ; Code to open a file call "testresults.txt and log the same as the console output $file = FileOpen("testresults.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Begin testing" & @LF) ;FileWrite($file, $Pass & @CRLF) ;FileWrite($file, "" & @CRLF) ;Code the prints to the console and to the file the same output of the Webpage being checked. Local $URL_Array[2] = ["http://" & $sourceip & "", "http://" & $sourceip & "/htm_login.htm "] Local $Text_Array[2] = ["Web", "login"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") FileWrite($file,"Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) Filewrite($file,"Page OK" &@LF) ;ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://" & $sourceip & "/htm_login.htm ") & @CR & @CR) Endif Next Local $URL_Array[2] = ["http://" & $sourceip & "", "http://" & $sourceip & "/htm_menu.htm/htm_login.htm "] Local $Text_Array[2] = ["Web", "Start-up"] For $a = 0 To 1 ConsoleWrite("Checking " & $URL_Array[$a] & " - ") FileWrite($file,"Checking " & $URL_Array[$a] & " - ") If StringInStr(_INetGetSource($URL_Array[$a]), $Text_Array[$a], 2) <> 0 Then ConsoleWrite("Page OK" & @LF) FileWrite($file,"Page OK" & @LF) ;ConsoleWrite("***** _INetGetSource *****" & @CR & _INetGetSource("http://" & $sourceip & "/htm_menu.htm/htm_login.htm") & @CR & @CR) Endif ; Next FileWrite($file, "end of testing" & @LF) Fileclose($file) ;put other testing code here console output is >Running:(3.3.2.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Examples\simplepagecheck.au3" Checking http://X.X.X.X - Page OK Checking http://X.X.X.X/htm_login.htm - Page OK Checking http://X.X.X.X - Page OK Checking http://X.X.X.X/htm_menu.htm/htm_login.htm - Page OK +>10:02:04 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 14.375 testresult.txt file is expandcollapse popup Begin testing Checking http://X.X.X.X - Page OK Checking http://X.X.X.X/htm_login.htm - Page OK Checking http://X.X.X.X - Page OK Checking http://X.X.X.X/htm_menu.htm/htm_login.htm - Page OK end of testing (adsbygoogle = window.adsbygoogle || []).push({}); jodayautoit Posted May 10, 2011 jodayautoit Active Members 40 Author Posted May 10, 2011 Hi all! I have run into a problem with my full test script that I found out that not all the HTML code can be read and is updated like when you select view source code. Apparently some parts of the webpage are updated by AJAX or java script thru another process that I do not fully understand. In any case I can not use the method that is working on all the web page checks so far. I need to do another method I think?????? I did find a couple of examples about PRINTSCREEN to a MSPaint or other application but that is not wnat I would like to have happen. I did find one on copy and paste the piece of information into Notepad. So I used the following under the AU3 recorder and got this part of code. I recorded the mouse click and movement of where the information on the screen was and copied it. The below code works to paste it into notepad. It does not save it or anything yet. I was wondering if there is a function that would allow the reading of the control C copied information and thus I could use the same process I had for consolewrite and filewrite to my testresults.txt file. Is this even possible? Is there a way to read this AJAX hidden application that updates the part of the screen I need? Any suggestions are greatly appreciated. I thought I was all set and just had to duplicate my smaller script into my full test script and be able to read any information on any webpage I needed. I guessed wrong. All that is in the control c block is the word "PASS" . I am checking a block on the webpage that has a pass or fail status once you click a button. Unfortunately it activates that AJAX applet and does something I do not know how to explain yet. thanks jodayautoit. [autoit] MouseMove(1015,510) MouseDown("left") MouseMove(968,510) MouseUp("left") Opt("WinTitleMatchMode", 2) Send("^c") ;Send ("^c");; copy the test block Run("notepad") WinWaitActive("Notepad") Send("^v");; paste it into Notepad somdcomputerguy Posted May 10, 2011 somdcomputerguy Active Members 2.8k 17 Posted May 10, 2011 Sorry I can't help with your specific problem right now, but those four Mouse commands can be replaced with this function, MouseClickDrag. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. jodayautoit Posted May 11, 2011 jodayautoit Active Members 40 Author Posted May 11, 2011 Hi all! I was trying to adapt to a GUI box to use my 3 inputs in one GUI box instead of the code above that I had each input as an individual Inputbox for IP, username and password. The below code is modified from a couple examples from this forum to get a basic 3 input GUI box and an OK button. Unfortunately I tried to use this with my working code and now the script never goes beyond the successful login msgbox to launch an Internet explorer session at the IP address of $sourceip. I do not understand why and it is probably since I pieced a few examples together and missed something. Can someone check what I did wrong. This code builds and will stop before it gets to $IE code. Thanks jodayautoit. #include <IE.au3> #include <INet.au3> ;This section of code is the new gui to replace INPUTbox for each user entry. $GUI = GUICreate("Web Test Script ",300,300,-1,-1,0x16C80000,0x00000181) $widthCell=70 $sourceip = GUICtrlCreateInput(" ",75,15,90,20,0X0001 ) $sourceuser = GUICtrlCreateInput("",75,50,90,20,0x0001) $sourcepassword = GUICtrlCreateInput("",75,95,90,20,BitOR(0x0020,0x0001)) GUICtrlCreateLabel ("IP Address: ", 5, 15, $widthCell) GUICtrlCreateLabel ("Username: ", 5, 50, $widthCell) GUICtrlCreateLabel ("Password: ", 5, 95, $widthCell) GUICtrlCreateLabel ("Input the above information to start Test Script", 5, 150 ) GUICtrlCreateLabel ("Must click OK: ", 5, 170, $widthCell) $OK = GUICtrlCreateButton("OK",200,200,60,20) GUISetState(@SW_SHOW,$GUI) ;commented out below pass/fail conditon since this will be used with the JIMwebautoit file ; the IP address , username and password are checked by the webmaster or it fails. While 1 $MSG = GUIGetMsg() Switch $MSG Case $OK If VerifyLogin(GUICtrlRead($sourceuser),GUICtrlRead($sourcepassword)) = 1 Then ;GUIDelete($GUI) MsgBox(-1,"Login Session","SUCCESSFUL LOGIN") Else MsgBox(-1,"Login Session","INCORRECT IP Address,Uusername or Password") EndIf Case -3 Exit EndSwitch WEnd Func VerifyLogin($sourceuser,$sourcepassword) If $sourceuser>"" And $sourcepassword>"" Then Return 1 Else Return 0 EndIf EndFunc ; NEVER gets to line to open webpage page at IP Address. What did I do wrong?? $oIE = _IECreate($sourceip) ;other code for username etc.
somdcomputerguy Posted May 11, 2011 Posted May 11, 2011 Change this$oIE = _IECreate($sourceip)to this$oIE = _IECreate(GUICtrlRead($sourceip)) - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change.
jodayautoit Posted May 11, 2011 Author Posted May 11, 2011 Hi Somdcomputerguy! I replaced what you said but it still never opens an IE session to the IP address . It for some reason is using 0.0.0.0 as the IP address or 0.0.0.3 and opens IE. I am commenting out sections of the above code until I can figure out how to just get the IP address working and then I will add username and password boxes. This GUI is a little bit confusing but it would be of great benefit to have all the user input information in one box then three different Input boxes. Thanks for the command . I hope I do not have to change every instance of IE commands I already used because that would be a pain now that the test script is working. BTW I found a reasonable solution to my previous problem until I study more on AJX/JAVA scripts and if Autoit can access the code. I ended up using the CLIP(GET) and CLIP(PUT) functions on the webpage that I need information from . I recorded the mouse clicks/moves to that position of the screen and copy and pasted it to the notepad then I changed it to get it to write it to the file. So, for now I can deal with those parts that way. Once I get more knowledge of autoit and how stuff works I might be able to figure out a better solution with your and others advise. Thanks jodayautoit.
somdcomputerguy Posted May 11, 2011 Posted May 11, 2011 I kinda rushed earlier, try this: $oIE = _IECreate("http://" & GUICtrlRead($sourceip)), that oughta work.. - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change.
jodayautoit Posted May 12, 2011 Author Posted May 12, 2011 Hi All! I still have not figured out my original GUI to get it to work but I found another example that almost gets me the same end result. I just can not figure out how to set the embedded window to be the active window and maximize it. Any suggestions ? I looked at the WINActive and WinSetstate but I must have not put the correct syntax. below is the code I am attempting to try. If this ends up working I will just copy all my code from the other test script that works into the middle section of this code and be done. thanks jodayautoit expandcollapse popup#include <GuiConstantsEx.au3> #include <windowsconstants.au3> #include <IE.au3> #include <INet.au3> Global $oIE = _IECreateEmbedded() ; Create a simple GUI for our output ;Global $hGUI = GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) ;Global $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 490, 500) ;My new version of example Global $hGUI = GUICreate("Embedded Web control Test", 1600, 1000, (@DesktopWidth - 1600) / 2, (@DesktopHeight - 1000) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) Global $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 1600, 1000) ;Code to get user input for IP address $sourceip = InputBox(" Test Script", "Enter the IP address ") ;Code to make sure valid address or script exits. If $sourceip = 0 Then Exit EndIf $sourceuser = InputBox("Enter the username ") ;Code to make sure valid address or script exits. If $sourceuser = 0 Then ;Exit EndIf $sourcepassword = InputBox(" "Enter the password ") If $sourcepassword = 0 Then ;Exit EndIf _IENavigate($oIE, $sourceip) ;How to make this window the active one and maximize it?????? ;Winactive("what name ???) ;$HWND = _IEPropertyGet($oIE, "readystate") ;WinSetState($HWND, "", @SW_MAXIMIZE) Sleep(2000) Send($sourceuser) Sleep(2000) Send("{TAB}") Sleep(2000) Send($sourcepassword) Send("{ENTER}") Sleep(2000) $file = FileOpen("C:\testresults.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Test Results For Web" & @CRLF) FileWrite($file, "Begin testing" & @LF) ;Code to verify IP address is active Ping($sourceip, 500) If @error = 0 Then ConsoleWrite("Pass Ping" & @LF) FileWrite($file, "Pass Ping" & @LF) EndIf ; if above gets working put all my other working test script code here Global $o_doc = _IEDocGetObj($oIE) $o_doc.DocumentElement.ScrollTop = 140 $o_doc.DocumentElement.ScrollLeft = 170 GUISetState() While GUIGetMsg() <> -3 WEnd ; below code from another example on this forum. ; Get rid of scrollbars ;If IsObj($oIE.document.documentElement) Then ; HTML4 transitional or strict ; $oIE.document.documentElement.style.overflow = "hidden" ;Else ; IE in quirks mode ; $oIE.documentElement.scroll = "no" ;EndIf
jodayautoit Posted May 16, 2011 Author Posted May 16, 2011 Hi all! I ran into another issue with using a simple web browser GUI code and placing my working code in it. I started writing this test script using a 1680 X 1050 display( Dell) and was thinking if I just make the GUI browser a minimum default of 1024 X 768 it would run my test script on my other PC or any PC that had atleast 1024 X 768. Not so with the current code. If I take what works on the 1680 X 1050 display which the test script only opens a 1024 X 768 browser in the center and runs the mouseclicks etc when running on an actual 1024 X 768 displauy the mouseclicks/moves are completely different. example of first 3 mouse movements on 1680 X 768 that actually work as I expect. MouseClick("left",400,279,1) MouseClick("left",400,289,1) MouseClick("left",400,321,1) If run on the 1024 X 768 display they actually need to be MouseClick("left",40,279,1) MouseClick("left",40,289,1) MouseClick("left",40,321,1) Is it even poosible to write a GUI with mouse movements on one display and PC and have it work on another PC that may not have the same display? Can someone enlighten me? I hope that I do not have to make one test script for 1680 X 1050 , then another for 1024 X 768? Thanks jodayautoit.
jodayautoit Posted May 16, 2011 Author Posted May 16, 2011 Hi All! Typo last post "example of first 3 mouse movements on 1680 X 768 that actually work as I expect." should have been example of first 3 mouse movements on 1680 X 1050 that actually work as I expect. Sorry got ahead of myself. jodayautoit
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