Jump to content

Capture the coordinates of a word on a web page


Recommended Posts

This has me stumped. I've checked help files and google and have no idea how to do this.

My script is going down a column of text on a web page. It copies the text to the clip board, reads it, and depending on what the text says performs an action. The problem is that the text is not always in the exact same location; some times its on (260, 370), sometimes its on (265, 375) and so forth. Because of this, I have to get the coordinates manually before running my script each time, then make adjustments.

Is there a way to have autoit search for the text and capture its coordinates before moving on with the rest of the script?

Edited by shutch00
Link to comment
Share on other sites

What have you coded so far?

Did you have a look at the IE UDF that comes with AutoIt?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The script is done except for this part. The way it works right now, I get the location of the word AKA starting point and plug it into variables x and y

#include <IE.au3>
$oIE = _IEAttach("home")
$x = 260  ;X COORD STARTING POSITION
$y = 365  ;Y COORD STARTING POSITION
$x2 = $x-90 
$x3 = $x-63
WinActivate("WEBPAGE GOES HERE")
MouseClick("left",$x,$y,3)
sleep(1000)
$Clipboard = ClipGet()

So I am using the AU3Info Finder tool to capture the coordnates of the word and then I plug it in above. It would be nice if Autoit could find the word, get its coords and plug it in for me.

I've checked the IE UDF and tried a few things but was unsuccessful.

Link to comment
Share on other sites

The word you are looking for is a link you want to click on?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

No, unfortunately. It is simply text. It is for a web app that I am supporting. We have picklist items that need deleted if they do not match a certain criteria. My script crawls down the page, reads the picklist item and decides whether or not to delete it. The picklists are setup for different accounts, so I have to go into each account and run my script. The issue occurs when I go to a new account's page, because the text is moved slightly.

Sorry if this is confusing. And thanks for your input.

Link to comment
Share on other sites

  • Moderators

Hi, shutch00. In the IE UDF you'll find _IEBodyReadHTML and _IEBodyReadText. Do you know what the text is going to be (i.e. either "a" or "b") or were you thinking of needing StringRegExp to compare a number of values? If you expect the text to always be the same, or only one or two variants, you should be able to read the source of the page and then perform your action, regardless of where it exists on the page itself.

"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

Is the text you are looking for just simple text or embedded in an object that has a name or an id?

Could you post the html code of a line you need to search?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Here is a snippet of the html. Looking for the word time_code. That is the start position.

<div>
<table border="0" cellspacing="0" cellpadding="3" width="100%"><tr><td class="detailColHeader" nowrap="nowrap">&nbsp;</td><td class="detailColHeader" nowrap="nowrap">[color=#ff0000]time_code[/color]&nbsp;</td><td class="detailColHeader" nowrap="nowrap">Description&nbsp;</td><td class="detailColHeader" nowrap="nowrap">Time/Shift Count&nbsp;</td>

**Edited the code.

Edited by shutch00
Link to comment
Share on other sites

You could try _IETableGetCollection to access the table that contains the data you need.

Then use _IETableWriteToArray to write the content to an array.

Then it's pure AutoIt to process the data the way you need.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

So I've got the table written into an array, but I'm not understanding how to get the screen coords from that. Or are you saying to just navigate via the table.

I may have gone over my head with this one. ;)

I'll have to do some research.

Link to comment
Share on other sites

If you can get the object that the text is in (the lowest level element), then you can get the starting X,Y by doing the following (the x,y is inside the client of the browser):

$iStartX = $oObj.offsetHeight

$iStartY = $oObj.offsetLeft

and then width, heighth by:

$iHeight = $oObj.offsetTop

$iWidth = $oObj.offsetWidth

edit: just realized i missinterpreted your issue...you can perform _ieaction to click on the Dom element you find, so you don't need the X,Y, you just need to drill down to the <td> to read the data, and then move to a sibling <td> to perform an action, such as click link = delete...is that what you are shooting for?

Edited 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.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...