Zeerti Posted May 1, 2014 Posted May 1, 2014 I am having some issues with Page Down and Page up and below is my sample code trying to figure out why Internet Explorer isn't receiving the page down and page up commands correctly due to it not scrolling at all. I have some error checking and the ControlSend is correctly identifying the instance of Internet Explorer. while $testLoop MsgBox($MB_SYSTEMMODAL, "PGDOWN", "PAGE DOWN") _WinAPI_SetFocus($IEHandle) $pageDownClick = ControlSend("", "", $IEHandle, "{PGDN}") if $pageDownClick == 0 then ; MsgBox($MB_SYSTEMMODAL, "Error", "Failed to find IEWindow for PageDown") ; endif $testLoop = $testLoopBool + 1 if $testLoop == 6 then ; $testLoop = 0 ; endif ; wend
jdelaney Posted May 1, 2014 Posted May 1, 2014 (edited) I'm not sure why you would need to scroll, but if you use the _IE* functions, you can get an element, and focus on it. That will bring that element to be visible. This would be the best way, but explain why you would want to scroll, if that's the case. Edited May 1, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Zeerti Posted May 1, 2014 Author Posted May 1, 2014 (edited) I am working on making a script for my job and the website is almost entirely javascript so I can't use a lot of the _IE functions. At least to my knowledge... Regardless, this is the best solution I could come up with, since I have limited programming knowledge. I am all ears of a better way to do it, I just need to be pointed in the right direction Edited May 1, 2014 by Zeerti
jdelaney Posted May 1, 2014 Posted May 1, 2014 (edited) Ok, then yes, that's basically your best option ControlSend with "" as the window handle, sends to the active window, i believe. You should instead force the send at a control in your IE window (the embedded browser/client) $IEHandle = WinGetHandle("[CLASS:IEFrame]") WinActivate($IEHandle) ControlSend($IEHandle, "", "[CLASS:Internet Explorer_Server]", "{PGDN}") Edited May 1, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Zeerti Posted May 1, 2014 Author Posted May 1, 2014 (edited) I was picking around the source for our website and part of it might be possible to do the way you mentioned. <tr class="row-4 even"> -> <tr class="column-8"> -> -> <div class="ld-container" tid="websitename" action="/web/ajax_likes.php> -> -> -> <button type ="button class= "ld-btn-enable" title="Enable device"> if I could call to press that specific button... the page has about 5-6 identical tr classes and buttons in total and so I'm not sure how to tell it to press the specific one in the row/column Edited May 1, 2014 by Zeerti
jdelaney Posted May 2, 2014 Posted May 2, 2014 (edited) Is the Div surrounding it unique? If so, you can use my signature's example to grab the button by it's XPath... such as the following, where $oIE is the return of _IEAttach, or _IECreate $xpathButtons = "//div[@class='Id-container']/button" $aoButtons = BGe_IEGetDOMObjByXPathWithAttributes ($oIE, $xpathButtons) ConsoleWrite("There are [" & UBound($aoButtons) & "] objects matching your xpath.") ; loop through, and focus on all objects matching your xpath...you can change this to click on the first instance For $i = 0 To UBound($aoButtons)-1 $aoButtons[$i].focus ;~ $aoButtons[$i].click Next Edited May 2, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Zeerti Posted May 2, 2014 Author Posted May 2, 2014 the outermost DIV that contains all the buttons is as follows: <div id="tablepress-27_wrapper" class="datatables_wrapper" role="grid"> inside of that there are all the <tr class="row-x"> and in each row-x there is <td class="column-x> and in column-8 of each is the div class for what I assume is for the buttons? but the innermost div class to the enable/disable buttons has a unique TID but everything else is the same.
jdelaney Posted May 2, 2014 Posted May 2, 2014 (edited) What you can do, is find a cell that has a specific value you are looking for. Then, on that object (the td), use .parentnode (or something like that, quick google will find it), to grab the row object (tr)...then you can drill back down, relative to the row, to the button. Edited May 2, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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