fishweasel Posted December 17, 2010 Share Posted December 17, 2010 Hi, Apologies if this kind of query has been answered somewhere else. I have spent 2 days searching and googling with different ways to do this. I have a small script that logs onto a web service on a fuel pump controller and activates a trace (logging facility) I can successfully navigate, login and send required parameters. At this stage a small java applet is generated (cgi) within a frame. This applet has the start button. Autoit Window Info can select this button and shows it as a control. I however am unable to activate it whatever way i try. I have tried to drill down into the frame and getobjbyname, directly access the control etc. Using mouse coords is not really an option as this script would be used on machines with different resolutions. My next thought was to use PixelSearch but i would only wish to search within the frame (havent been able to figure out the best way to do this.) My script so far ( the commented lines at the bottom are what remains of some of my recent attempts to find and click this button): expandcollapse popup; Script Start #include <IE.au3> #include <_ConfigIO.au3> ; variables - need to come from config file when confirmed to work $user = "admin" $pass = "password" $doms_ip = "172.16.16.25" $doms_port="peep4=on&peep11=on" ; this is the checkbox number from peep select page source $incext="incext=on" $fromzero="fromzero=on" $MaxKbSize="maxsize=5000" $PeepDirectory="filename=C:\PeepTrace\PeepLog" ; open browser to doms ip $oIE = _IECreate("http://" & $doms_ip & "/peep.cgi?" & $doms_port &"&" & $incext & "&" & $fromzero & "&" & $MaxKbSize & "&" & $PeepDirectory, 0, 1, 0, 0) Sleep (2000) $login = WinWaitActive("[TITLE:Connect to]","",3) While WinActive($login) ControlFocus($login, "", "Edit2") ControlSend($login, "", "Edit2", $user) Sleep (1000) ControlFocus($login, "", "Edit3") ControlSend($login, "", "Edit3", $pass) Sleep (1000) ControlClick($login, "", "[CLASS:Button; TEXT:OK]") WEnd _IELoadWait ($oIE) ; allow time for java applet to load Sleep (8000) ; Click Start button ;$oHWnd = WinGetHandle ( "[CLASS:IEFrame]" ) ;ControlClick($oIE, "", "[CLASS:Button; TEXT:Start]") ;$oFrame = _IEFrameGetObjByName($oIE, "peep1.cgi") ;$oButton = _IEGetObjByName($oFrame, "startpeep") ;_IEAction($oButton, "click") The html is understandably limited : <HTML> <FRAMESET rows="330,*"> <FRAME src=peep1.cgi scrolling="no"> <FRAME src=peepfrm2.htm> </FRAMESET> </HTML> I have managed to get some code from applet : <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body rightmargin=0 leftmargin=0 topmargin=0> <table width=100%> <tr> <td class=hdr> <big><big>Peeper</big></big> </td> </tr> </table> <table width=100% height=95%> <tr><td class=tdmain align=center>Do not close the browser window, before pressing the Stop button</td></tr> <tr><td align=center> <APPLET code=ftp.class height=210 width=400 id=ftp archive=ftp.jar alt="Peep Applet Loading ..."> <param name=maxfilesize value=5000> <param name=incext value=true> <param name=startfromzero value=true> <param name=localfile value="C:\PeepTrace\PeepLog"> <param name=servertimeout value=10000> <param name=ipaddr value=172.16.16.25> <param name=startpeep value="strtpeep.cgi"> <param name=stoppeep value="stoppeep.cgi"> <param name=getpeepheader value="getpeeph.cgi"> <param name=getpeepdata value="getpeepd.cgi"> <param name=delpeepdata value="delpeepd.cgi"> <param name=maxblocksize value="65536"> <param name=test value=FALSE> <param name=cabbase value="ftp.cab"> </APPLET> </td></tr> </table> </body> </html> Finally, here are the WindowInfo details : expandcollapse popup>>>> Window <<<< Title: http://172.16.16.25/peep.cgi?peep4=on&peep11=on&incext=on&fromzero=on&maxsize=5000&filename=C:\Class: IEFrame Position: 0, 0 Size: 983, 721 Style: 0x16CF0000 ExStyle: 0x00000100 Handle: 0x000E0792 >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 1 Text: Start Position: 612, 191 Size: 70, 20 ControlClick Coords: 30, 8 Style: 0x5400000B ExStyle: 0x00000000 Handle: 0x001D08D8 >>>> Mouse <<<< Position: 646, 222 Cursor ID: 0 Color: 0xD4D0C8 >>>> StatusBar <<<< 1: Done 2: 3: 4: 5: 6: 7: 8: 9: 10: >>>> ToolsBar <<<< 1: 256 Back 2: 257 Forward 3: 258 Recent Pages >>>> Visible Text <<<< Navigation Bar http://172.16.16.25/peep.cgi?peep4=on&peep11=on&incext=on&fromzero=on&maxsize=5000&filename=C:\PeepTrace\PeepLog Address Combo Control Page Control Google Search Combo Control Search Control Command Bar Favorites Command Bar ITBarHost Menu Bar http://172.16.16.25/peep.cgi?peep4=on&peep11=on&incext=on&fromzero=on&maxsize=5000&filename=C:\Done Zoom Level Start Skip Peep applet ready ... (Version 1.00) C:\PeepTrace\PeepLog 5000 Start from 0 Increment extension >>>> Hidden Text <<<< Google What confuses me is that WindowInfo can see the button and even the text 'start' , but i cannot seem to directly interact with it. I cannot use the controls handle either as it changes each time it is generated. Would i be able to pass the parameter param name=startpeep value="strtpeep.cgi" ? Any assistance with my dilema is greatly appreciated, thanks. Link to comment Share on other sites More sharing options...
DaleHohm Posted December 17, 2010 Share Posted December 17, 2010 Interesting that AutoItWinInfo can see the button... that would lead me to believe taht the button is now a Java button, but rather an Wind32 button. I'd have to see it to get any better idea. Regarding the applet parameters, you can actually change their values via the DOM, but what you ask about passing looks like the same value you provide in the code... would that really help? dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
fishweasel Posted December 20, 2010 Author Share Posted December 20, 2010 Thanks for the reply Dale. It turns out the answer was quite simple (arent the hardest ones to find always simple ?) ; Click Start button $oFrame = _IEFrameGetObjByName($oIE, 0 ) $handle = ControlGetHandle($oFrame, "", "[CLASS:Button; INSTANCE:1]") ControlClick($handle, "", "[CLASS:Button; INSTANCE:1]") Link to comment Share on other sites More sharing options...
DaleHohm Posted December 23, 2010 Share Posted December 23, 2010 (edited) Unfortunately, your code doesn't make sense. My guess is that the only line that does anything useful is the last one and it is just acting on the currently active window because $handle contains a blank string. Your first line would make sense with _IEFrameGetCollection and would return a DOM Window object. DOM Window objects are not valid with ControlGetHandle, so the pair of functions don't go together. I think if you used the third line all by itself it would work the same. Dale Edited December 23, 2010 by DaleHohm Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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