alexk21 Posted January 29, 2019 Share Posted January 29, 2019 Hi guys I have a Script that clicks on a Position (x,y coordinates) on the Internet Explorer. Right now I use the Funktion Mouseclick, but I would like to run it in the background and do something else while it is Running. The Problem is that i have to use the coordinates, there is no other way like using id or something. I dont find a way How to do it. TIA Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 30, 2019 Moderators Share Posted January 30, 2019 @alexk21 It depends on what you are trying to do exactly. AutoIt has IE functions built in, which allow you to automate the browser without mouseclicks. If you can explain more about what you're trying to accomplish we can help. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 Ok so we have a webpage at work with a big Table. In every table row is a Button where i Click on. After i clicked on the table row Button on the top the table row disappears and the others move up. Right now i leave the mouse at the x and y coordinates of this Button and Click on it every 3 seconds to submit every table row. Now i want to do it in the background that i can use my mouse and dont have to leave it there. Link to comment Share on other sites More sharing options...
Danp2 Posted January 30, 2019 Share Posted January 30, 2019 Sounds doable with the _IE functions. Have you taken a look at them in the help file? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 @Danp2 Yes i have tried some things but they all dont work. Thats the button: <a href="#" onclick="text" class="class"></a> And like i said in my previous post there are hundreds of this buttons in the table and i want to click always on the button at the top. That means my mouse has to click always on the same coordinates. I have tried to use the ControlClick function but it doesnt work. I dont find anything on the internet that can help me. Thanks Link to comment Share on other sites More sharing options...
Danp2 Posted January 30, 2019 Share Posted January 30, 2019 Again, should be doable with the _IE functions. Can't really provide further assistance until you give more details on the webpage. Can you save the page's HTML to a file and post it here so that we can analyze it's structure? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 Unfortunately i am not allowed to use the html code of my company. I copied one html row from the table and Xed out the sensitive data. I want to click on this button, but the ID changes after every click, for example here it is "x_4738" and after i clicked on the button the next table row moves up and the id of it is "x_1783". Thats why i think i can do it only with coordinates. I hope you understand how the table works, after i clicked on the button. There is an attachement thats shows you how the table looks like. If i click on the yellow button the table row disappears and the others move up and so on. <a href="#" onclick="return x(this, 4738, 6079)" class="x_4738 x_icon x_icon_b"></a> <tr id="x_4738" class="report_4738 row_a"> <td><a onclick="return x.deleteReport(4738);" class="" href="#"><img src="https://x.png" title="" alt="" class=""></a></td> <td><img src="https://x/green.png" class=""> </td> <td><img src="https://x/0.png" class=""> </td> <td><a href="/x=7110&screen=report&mode=all&view=5539722">4</a></td> <td>12:12:33</td> <td style="text-align: center;" colspan="3"> <span class="">?</span> </td> <td style="text-align: center;">?</td> <td>16.2</td> <td> <a href="#" onclick="return x(this, 4738, 6079)" class="x_4738 x_icon x_icon_b"></a> </td> <td style="text-align: center"> <span class="">?</span> </td> <td><a href="/x=7110&screen=place&target=4738&" onclick="x(4738, event)"><img src="x/place.png" title="" alt="" class=""></a></td> </tr> TIA Link to comment Share on other sites More sharing options...
Danp2 Posted January 30, 2019 Share Posted January 30, 2019 This is how I would handle this -- Use _IEAttach to link to existing IE tab Use another _IE function (_IETableGetCollection, _IEGetObjById, etc) to get table object Use _IETagNameGetCollection to get 1st row Use _IETagNameGetCollection to get 7th table cell Use _IEAction to click link Loop back to get first row again I may have left out some steps, but you should get the idea. There may be an easier way to do this if the page uses jQuery. Let us know how it goes. Dan Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 Okay thanks. I am now here: Use _IETagNameGetCollection to get 1st row How do I get the first table row now? There is never a clearly sign that the row is the first row at the moment? <tr id="x_7116" class="report_7116 row_a" style="display: none;"> <tr id="x_5697" class="report_7116 row_a" style="display: none;"> <tr id="x_1497" class="report_7116 row_a" style="display: none;"> <tr id="x_9638" class="report_7116 row_a" style="display: none;"> Link to comment Share on other sites More sharing options...
Danp2 Posted January 30, 2019 Share Posted January 30, 2019 Assuming that $oTable points to the table object -- $oRow = _IETagNameGetCollection($oTable, 'tr', 0) Then you'd do a similar step to get the table cell - $oCell = _IETagNameGetCollection($oRow, 'td', 6) etc Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 Some hours ago i was able to get the content from the right table, but now i have tried too many things and my code doesnt work anymore. I cant even find the right table and show its content with a MsgBox. I dont know whats wrong and what else i need. I have never programmed very much and this is my first time trying something in Autoit. Thanks for your help. $oIE = _IECreate("link") Sleep(5000) $oIE = _IEAttach("name") $oTable = _IEGetObjById($oIE, "table-id") For $oRow In $oTable $oRow = _IETagNameGetCollection($oDiv, 'tr', 3) $oCell = _IETagNameGetCollection($oRow, 'td', 10) _IEAction($oCell, "click") Next Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 Sorry there is something wrong in the code, this is the right code: $oIE = _IECreate("link") Sleep(5000) $oIE = _IEAttach("name") $oTable = _IEGetObjById($oIE, "table-id") For $oRow In $oTable $oRow = _IETagNameGetCollection($oTable, 'tr', 3) $oCell = _IETagNameGetCollection($oRow, 'td', 10) _IEAction($oCell, "click") Next Link to comment Share on other sites More sharing options...
Danp2 Posted January 30, 2019 Share Posted January 30, 2019 You should be able to drop the _IEAttach because you already have the object from the initial _IECreate. Beyond that, the following is wrong -- For $oRow In $oTable This will never work, because $oTable is a single object reference. Based on your earlier posting, I'm unsure why you are trying to get the 4th row and the 11th column (these are 0-based indexes). But assuming that those values are correct, then you could do something like this -- $oIE = _IECreate("link") $oTable = _IEGetObjById($oIE, "table-id") While True $oRow = _IETagNameGetCollection($oTable, 'tr', 3) If @error Then ExitLoop $oCell = _IETagNameGetCollection($oRow, 'td', 10) _IEAction($oCell, "click") Next Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 30, 2019 Author Share Posted January 30, 2019 Okay i changed it to first table row and 10. column. The table was just an example...not the right size. I will test it now. Could you tell me how i can check what content is in my $oTable? I use MsgBox with a normal variable but i think there is a better way, right? Link to comment Share on other sites More sharing options...
Danp2 Posted January 30, 2019 Share Posted January 30, 2019 Use _IETableWriteToArray and _ArrayDisplay. See first example under _IETableWriteToArray entry in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 31, 2019 Author Share Posted January 31, 2019 (edited) Okay...so i get the right table, but it still doesnt click on the button. Here is my array, the html code of the first table row and 2 example rows that are under my first row and my code. The yellow field is where the button is and i think i have the right numbers in my code to click on it. Could you tell me a way how i can check myself when the script doesnt work anymore or where the mistake is? I dont know how to check if it gets the right object and so on. #include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> $oIE = _IECreate("x") Sleep(5000) $oTable = _IEGetObjById($oIE, "id") $aTableData = _IETableWriteToArray($oTable) _ArrayDisplay($aTableData) While 1 $oRow = _IETagNameGetCollection($oTable, 'tr', 2) If @error Then ExitLoop $oCell = _IETagNameGetCollection($oRow, 'td', 11) _IEAction($oCell, "click") WEnd Edited January 31, 2019 by alexk21 Link to comment Share on other sites More sharing options...
Danp2 Posted January 31, 2019 Share Posted January 31, 2019 1 hour ago, alexk21 said: The yellow field is where the button is and i think i have the right numbers in my code to click on it. Sorry, but this doesn't compute. Your _ArrayDisplay shows a table with 14 rows and 6 cols. Why would you think that the button is in Row 11, Col 2? That HTML code is not useful, because there is no way to me to confirm that it even belongs to the table in question. It doesn't appear to match up to the _ArrayDisplay because it has more columns. 1 hour ago, alexk21 said: Could you tell me a way how i can check myself when the script doesnt work anymore or where the mistake is? I dont know how to check if it gets the right object and so on. You can check the value of @error following each _IE* command to see if the command failed. You could also check the value of innerText to see the contents of an element, like this -- $oCell = _IETagNameGetCollection($oRow, 'td', 11) If Not @error Then ConsoleWrite("InnerText = " & $oCell.innerText & @CRLF) Endif Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexk21 Posted January 31, 2019 Author Share Posted January 31, 2019 This is an example how the table looks like. The length is variable and can change every hour. I think the button is in the right cell between my "1.4" and "?" in the Array because it is in the right cell between my "34" and "?" (screenshot). Please tell me which informations you need and i will try to do it as detailed as possible. Link to comment Share on other sites More sharing options...
Danp2 Posted February 1, 2019 Share Posted February 1, 2019 If that is an accurate representation of the table, then that would indicate that the button is in the 10th column. Have you tried getting this element and examining it's contents using the example I posted above? P.S. You may want to repost an example of the table, it's underlying HTML, and the _ArrayDisplay contents where they all represent the same data set. As is, it's difficult to know how to proceed because none of the data matches up in your examples. Latest Webdriver UDF Release Webdriver Wiki FAQs 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