Jump to content

Recommended Posts

Posted

Hi friends,

I have searched this forum thoroughly but I couldn't find my answer yet.

Basically I would like to write an AutoIt script to highlight any text (which could be a word, a character, ...) which is under the current position of the mouse cursor. Is this possible? If Yes, please suggest me a way to do it.

Thank you very much.

Posted (edited)

This is not easy and methods will vary depending on circumstances. If you try to do this with an edit control that you created yourself then it should be quite feasible. You will need to use StringRegExp to identify the word at the coordinates. You could find the character nearest the mouse using MouseGetPos combined with _GUICtrlEdit_CharFromPos. However all this seems rather complicated to me.

Edited by czardas
Posted

  On 7/17/2012 at 11:27 AM, 'czardas said:

This is not easy and methods will vary depending on circumstances. If you try to do this with an edit control that you created yourself then it should be quite feasible. You will need to use StringRegExp to identify the word at the coordinates. You could find the character nearest the mouse using MouseGetPos combined with _GUICtrlEdit_CharFromPos. However all this seems rather complicated to me.

Hi czardas,

Thank you for your response. However I would like my program to highlight text in any situation, no matter what I am doing. Several examples are reading pdf files, surfing the web, composing email and docs, etc.

So in your opinion this task cannot be done with AutoIt?

Posted (edited)

So you're reading some text that's on your screen, you see a word that you want to highlight, you move the cursor to that word and hit the HotKey to start the script and it Send's a double click (which selects whatever text is at the cursor postion). Does this meet your scenario? If so, this can probably be done this simply, but maybe not..

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Posted (edited)

  On 7/18/2012 at 2:42 AM, 'somdcomputerguy said:

So you're reading some text that's on your screen, you see a word that you want to highlight, you move the cursor to that word and hit the HotKey to start the script and it Send's a double click (which selects whatever text is at the cursor postion). Does this meet your scenario? If so, this can probably be done this simply, but maybe not..

The functionality you described is exactly what I intend to do. However, if we are handling a hyperlink, we cannot send a double click to it, because if we do so, we would be navigated to the address pointed to by the hyperlink, and the text would not be highlighted in this case.

Do you have any idea for special cases like that?

Edited by bobbyab9987
Posted

  On 7/18/2012 at 3:11 AM, 'somdcomputerguy said:

I use to use this function, MouseClickDrag, in a similar situation. Maybe this would work too in your case.

Unfortunately this does not work. I have tried your method with a hyperlink on a google search-result page but nothing is highlighted.

Thank you for your answer anyway :)

  • 2 years later...
Posted

Hi everyone.

I am very new to AutoIt, and I must thank you all for your support and help.

In regards to this issue, I am using AutoIt to look for any word in RED and double click on > my search returns one hit though so you might want to update the script.

$pixel = PixelSearch(1242,212,1765,466,0xFF0000)
 
If IsArray($pixel) = True Then
  MouseMove($pixel [0], $pixel [1], 1)
EndIf
 
MouseClick("left",$pixel [0], $pixel [1],2)

 

-0mar4fendi

  • Moderators
Posted

0mar4fendi,

Welcome to the AutoIt forums. :)

But if you really must post in a fairly old thread, please at least post something relevant. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • 1 year later...
Posted

Melba23, actually it is your post the one that does not contribute to this forum.

For those interested, based on 0mar4fendim reply, I was able to complete a tiresome task.

Here is my approach:

; Triger search
Send("^f")
Sleep(500)
Send("@")
Sleep(500)
Send("{ENTER}")
Sleep(2000)

;Find , in Chrome, the higlighted @ sign, yellow pixel
$pixel = PixelSearch(470,193, 845,248, 0xffff00)


;Copy e-mail from X-OnlineApp
MouseClick($MOUSE_CLICK_SECONDARY, $pixel[0], $pixel[1], 1, 0)
Sleep(500)
Send("e")
Sleep(1000)

 

Thanks 0mar4fendim, that is a very creative approach.

- And yes I know this is an old post; however, even today people may have the same problem.

 

 

---
vicsar
https://about.me/vicsar
 

 

  • Moderators
Posted

vicsar,

Thanks for that - I will give myself a stern talking-to sometime later this evening.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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