Jump to content

find a text and the text position?


Recommended Posts

hi, folks

i'm new at autoit3

it's really good at handling internet automation

here , my problem to be solved

i have a web and find a text

then the text will be marked

in this case

how can i get the marked text x, y position?

Link to comment
Share on other sites

Welcome to the forum.

If your goal is to click on a link within a web page, then look in the help file under _IE_Example...

If that is too hard for you right now, consider "tabbing" to the link of interest as described in this post: http://www.autoitscript.com/forum/index.php?showtopic=14395

If the text on the website is not a link that you want to click on, then please explain a bit more about what you want to do.

-MSP-

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Welcome to the forum.

If your goal is to click on a link within a web page, then look in the help file under _IE_Example...

If that is too hard for you right now, consider "tabbing" to the link of interest as described in this post: http://www.autoitscript.com/forum/index.php?showtopic=14395

If the text on the website is not a link that you want to click on, then please explain a bit more about what you want to do.

-MSP-

Well, my poor english..

When I want to find a special text "freeware" at http://www.autoitscript.com/autoit3/

I use Control+F to find that text (as attached file)

in this case

How can i find text x, y position ?

Link to comment
Share on other sites

...

How can i find text x, y position ?

That might be hard to do reliably. If you find the x, y position, what are you going to do with it.

There might be a better way to do the entire task - if we knew what that task was.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

That might be hard to do reliably. If you find the x, y position, what are you going to do with it.

There might be a better way to do the entire task - if we knew what that task was.

well.

After I find the text's x, y position

move the mouse to that position and use Clipget() the text after "freeware"

post-24828-1183527559_thumb.gif

Link to comment
Share on other sites

Run this little sample and see if we are getting closer to what you want:

#include <INet.au3>
$page = _INetGetSource("http://www.autoitscript.com/autoit3/")
$pageArray = StringSplit($page, @CRLF)

For $i = 1 To $pageArray[0]
    If StringInStr($pageArray[$i], "freeware") Then MsgBox(0, "Found it", $pageArray[$i])
Next
The _INetGetSource function reads the entire page into a variable... in this case named $page.

The StringSplit functions turns that page of text lines into an array:

$pageArray[0] = number of lines of text on the page

$pageArray[1] = first line of the web page text

$pageArray[2] = next line of the web page text

$pageArray[3] = next line of the web page text

......

The For/Next loop works through each line of text.

The StringInStr looks for "freeware"...

If "freeware" is found, the MsgBox displays that line.

How much text after freeware do you want?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Run this little sample and see if we are getting closer to what you want:

#include <INet.au3>
$page = _INetGetSource("http://www.autoitscript.com/autoit3/")
$pageArray = StringSplit($page, @CRLF)

For $i = 1 To $pageArray[0]
    If StringInStr($pageArray[$i], "freeware") Then MsgBox(0, "Found it", $pageArray[$i])
Next
The _INetGetSource function reads the entire page into a variable... in this case named $page.

The StringSplit functions turns that page of text lines into an array:

$pageArray[0] = number of lines of text on the page

$pageArray[1] = first line of the web page text

$pageArray[2] = next line of the web page text

$pageArray[3] = next line of the web page text

......

The For/Next loop works through each line of text.

The StringInStr looks for "freeware"...

If "freeware" is found, the MsgBox displays that line.

How much text after freeware do you want?

thks for reply

there is table at a web(LOOK AT THE IMAGE)

let's say, what i'm going to do is find "ILSAN" at the table

and i'm going to FOLLOW the link "3" just behind the "ILSAN" text

the link located +x, +y position from the "ILSAN" text position

post-24828-1183532125_thumb.gif

Link to comment
Share on other sites

Someone may have to help you use the IE.au3 functions.

I'm not good with them.

I see now why you wanted to use the "find text" method.

If no forum member comes up with a way to use the IE.au3 functions for you, then you can go back to the "find text" method that you started out with. I'm just not sure how best to do that.

Is the website that you showed something that forum members could look at and test some AutoIt code on for you?

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Someone may have to help you use the IE.au3 functions.

I'm not good with them.

I see now why you wanted to use the "find text" method.

If no forum member comes up with a way to use the IE.au3 functions for you, then you can go back to the "find text" method that you started out with. I'm just not sure how best to do that.

Is the website that you showed something that forum members could look at and test some AutoIt code on for you?

sorry

that's my company site .

i'm trying to web_check_automation

- open web

- check error value

- check detail report excel file if err

- alarm if duplicate err with err detail list

Link to comment
Share on other sites

Dale Hohm's IE library is the most applicable solution...however, you'll have to extract certain information from your website in order to apply it. If you can provide source, or at least the URL, we can take this another step, otherwise you're more or less on your own. Here's the idea behind the _IE* stuff.

#Include <IE.au3>                   ;include Dale's IE library

$url = "www.yourURLhere.com"
$oIE = _IECreate($url, 1)

#cs
_IECreate() is trying to attach to an existing instance of this URL (that's what the "1" means), if it doesn't find one
it will create a new IE window and navigate to the page.

Now depending on the setup of your webpage, you can either click the link if it's in the main body,
or else you'll have to get reference to the proper frames/forms which contain your link.
#ce

$oFrame = _IEFrameGetObjByName($oIE, "YourFrameNameHere")

$oLinks = _IELinkGetCollection($oFrame)

For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
Next

It also looks like your link is in a table, hinting at _IETable. You'll have to provide some more info.

Edit: typos

Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

  • 5 years later...

I too have the same question as leehy250 about finding the text position so I can mouse over that text. I'm trying to accomplish something that's a bit different but finding the position of the text is neccessary.

I'm trying to mimic what a real user would do in Google Search (i.e. type in key word and click on relevant page in SERP). I can accomplish this already by using IE.au3 to retrieve the DOM object and use document.click() to click on the link. ADDITIONALLY, I also want to find the URL link and move over it because who knows... google may send an event to their server when the mouse would be hoovered.

Any tips would be appreciated.

Link to comment
Share on other sites

  • 3 years later...

besides necroposting its better to open a new supportquestion and provide with more details.

Is it an html page, which browser, ......, what did you try yourself.

https://www.autoitscript.com/wiki/FAQ question 31 is probably a good starting point

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...