Jump to content
Sign in to follow this  

How to simulate a mouse click on selected text?

Recommended Posts

Hi, I just start to learn Autoit, right now I am working on something that needs to simulate a mouse click on selected text. The scenario is like this:

I open a webpage, then there is a message box popping up, I need to click the OK button on that message box. The annoying thing is that, I cannot use keyboard to control the OK button (TAB or ENTER or else doesn’t work). So I want to use a mouse click instead, however, the message box keeps on changing its position each time I reload the webpage, which gives me a big headache.

I suppose my way to solve the problem should be like this:

Step 1: search for text “OK” on the screen

Step 2: select the text “OK”

Step 3: get the –x, -y position value (or range) of the selected text

Step 4: then use mouseclick() to click on the button

But I am not sure whether Autoit has such a function for Step 3, I read through the help file but couldn’t find any clue. Can anyone give me some hints on this? Or suggest a new approach?

Thanks a lot!

Share this post

Link to post
Share on other sites

Use ControlClick(), and see "Controls" in the help file for all the ways you can specify the control, including by text:

ControlClick("Your Popup Title", "", "[CLASS:Button; TEXT:OK]")


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...