Jump to content
Sign in to follow this  
shutch00

Capture the coordinates of a word on a web page

Recommended Posts

shutch00

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

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
shutch00

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.

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
shutch00

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.

Share this post


Link to post
Share on other sites
shutch00

Here is a mock up of the site (can't use the real thing)

Posted Image

Share this post


Link to post
Share on other sites
shutch00

I'll keep looking, thanks.

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
shutch00

The starting point will always be the same, so I assume that is all I need. From there, I just go down the page by increments. I will definitely check these out, thanks!

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
shutch00

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

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
shutch00

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.

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
czardas

Using mouse click coordinates is a bad idea for several reasons: differences in screen resolution, between browsers and scroll bar positioning.

Edited by czardas

Share this post


Link to post
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
Sign in to follow this  

×