Jump to content

Left Mouse Click


Recommended Posts

I start a video capture program and position my mouse on top

of the little "stop" button, and I want to go away for a long

time and have a left mouse click for that task (the capture

program) happen after a specified number of minutes,

say 90 minutes later. Can autoit do that? Is it difficult

to set up? Can someone show me how?

Would I start autoit bfore, or after, I start the capture

program?

Thanks,

Littleberry

Link to comment
Share on other sites

  • Developers

If you're starting with AutoIt, it's better to have a look at the Version3.

It's reasonable easy to write a script that can click a button for you at a give interval or when e.g. specific text is shown on the screen.

Just as an example for a 90 minutes timer and then click a give button:

sleep(90*60000)   ; sleep 90 minutes
ControlClick("title of your program window","","Button1")

ControlClick will do a LeftMouseClick in the window with the given Title/Text combination on the specified Controlname which is Button1 in the example.

The name of the BUTTON to push can be found by running a program called AU3_Spy.exe that comes with AutoIt. For more details on this, open the helpfile and look at the subject: Using Autoit \ Windows Titles and Text

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thankyou, JdeB, for your post.

I downloaded autoit 3 and as a test,

I altered your example to see if I could

get a left mouse click to notepad after

I positioned the mouse over the "edit"

button to see if it would pull down.

I modified the script as follows:

sleep(10000) ; sleep 10 seconds

ControlClick("Notepad.exe","","Button1")

I saved this as Autoit3_notepad.au3, and then

I started notepad and then ran this script

from autoit3, then, right away i made

notepad acctive and put my mouse

over the "edit" button and waited

for about 20 seconds, but nothing

happened.

I am thinking that I do not have the

correct name in the script for notepad,

it must want something other than the

name used when you start the program.

Do you know how I go about finding the

correct name that autoit3 needs, given

that I only know the program name

right now?

Thanks,

Littleberry

Link to comment
Share on other sites

  • Developers

The Edit menu option is not a button.

When you run AU3_Spy.exe and you hover the mouse over the edit option in notepad it will show the below info...

As you can see there is no "LastControl under Mouse" information.

I used Button1 as an example but in your case you need to run AU3_SPY and also run your program and then when you see the windows where you need to click a button, you hover the Mousepointer over this button and then read what AU3_Spy says the Control name is...

>>>>>>>>>>>>( Window Title )<<<<<<<<<<<<<

Untitled - Notepad

(  classname=Notepad  )

>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<

On Desktop: x: 146  y: 101

In Window: x: 43  y: 38

>>>>>>>>>>>>>( Pixel Color Under Mouse)<<<<<<<<<<<<<

Dec: 13088699      Hex: 0xC7B7BB

>>>>>>>>>>>( Window Position )<<<<<<<<<<<

left: 103  top: 63  width: 711  height: 413

>>>>>>>>( Last Control Under Mouse )<<<<<<<

>>>>>>>>>( Status Bar Text )<<<<<<<<

(1):

(2):    Ln 1, Col 1 

>>>>>>>>>>>( Visible Window Text )<<<<<<<<<

>>>>>>>>>>( Hidden Window Text )<<<<<<<<<

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

And another thing, the title of the window isn't Notepad.exe :

ControlClick("Notepad.exe","","Button1")

As JdeB and AU3_SPY is saying is correct :

>>>>>>>>>>>>( Window Title )<<<<<<<<<<<<<

Untitled - Notepad

Which could make your code like this :

ControlClick("Untitled - Notepad","","Button1")

Note that the code above isn't to functional as it is, as JdeB tried to say :

The Edit menu option is not a button.

Hope I helped you more than I confused you.. :whistle:
Link to comment
Share on other sites

I didn't really want to specify particularly the "edit" button, that was

just a quick example I used just to know for sure that the mouse

click did happen. I do not understand very well the concept

of "conrols" under windows, and I don't think I would be able

to figure all of that out, so, i just wanted to find a way to get

the mouse to click as if I were here doing it physically. I didn't

think it should matter really where in the window the mouse

is at the time autoit3 wakes up and sees that it needs to

send a left mouse click to my active task.

Just to keep it simple, how can I test the abiblity of autoit3

being able to cause a left mouse click in some active widnow,

say notepad because we all know about it, without necessarily

specifiying in the script just where the mouse will be?

The script that I tried to use (after letting autospy show me

the name) is:

sleep(10000) ; sleep 10 seconds

ControlClick("Untitled - Notepad","","Button1")

And as you say, I can't detect the mouse actually

clicking after the 10 second wait. I guess I am not

using autoit3 the way it is intended to be used.

I also see there is a function called MouseClick,

but it doesn't let you tell which task is supposed

to recieve the click.

I think it might be an easy and instructive example

to show a script that does what i susggest - just cause

a left mouse click in notepad after 10 seconds, providing

the user starts notepad before running the script,

and physically moves the mouse somewhere in

the notepad window. How would you do that?

Even better would be for autoit to send a mouse click

at the right time, irregardless of which task is active,

just as if someone physically pushed the left mouse

button at that time. Is that something autoit can do?

Littleberry

Link to comment
Share on other sites

Well knock my socks off! I just tried it using MouseCLick("left") and

IT WORKED!

Here is the script I used:

sleep(10000) ; sleep 10 seconds

MouseClick("left")

I started notepad first, then I ran the script, and then

I quickly moved my mouse over the notepad just

under the "edit" button and waited. After a few

seconds, bingo!, the edit pull-down appeared!

This is very exciting - I can figure it out from here.

Thanks,

Littleberry

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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