DeathRow

How to simulate mouse click, WITHOUT moving the cursor ?

26 posts in this topic

Hello Autoit forum,

Does anybody knows how to simulate mouse clicks without moving the cursor ?

Can be accomplished via API somehow ?

Share this post


Link to post
Share on other sites



Could you explain more.

In the meantime There is

MouseClick("Left")

That will click.


shutdown(1)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Could you explain more.

In the meantime There is

MouseClick("Left")

That will click.

LOL What can I explain better than that ? So, I know the Mouseclick command, but I just want to simulate the click, without moving the cursor

Example:

Now my cursor( the mouse cursor ) is on the screen at x=200,y=200 coordinates. I want to simulate a click on a point at x=128, y=310 coordinates, but my cursor to remain at the 200, 200 position.

How can I do that ? Any API function ?

Edited by DeathRow

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Oh I see now!

Not quite sure how,

The cursor can only click where it is.

If you could click without moving the cursor it would open up a whole new window for malicious software!

I.E. not good!

Edited by Scriptmaster

shutdown(1)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Oh I see now!

Not quite sure how,

The cursor can only click where it is.

If you could click without moving the cursor it would open up a whole new window for malicious software!

I.E. not good!

no, I don't want it for malicus software

I just want to use the function for my backup script cause I run it while I navigate and I can't do it in other way :/

EDIT: Ok I managed it :

Sleep(3000)
$pos=MouseGetPos()
MouseClick("left",200,200,1,0)
MouseMove($pos[0],$pos[1],0)
Edited by DeathRow

Share this post


Link to post
Share on other sites

no, I don't want it for malicus software

I just want to use the function for my backup script cause I run it while I navigate and I can't do it in other way :/

I did not mean you would i just meant that is the func exists it could be used for malicious purposes.


shutdown(1)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Use Control click

This example will click the back button in IE without moving the mouse cursor

opt("MouseCoordMode",2)
ControlClick("[CLASS:IEFrame]","","[CLASS:ToolbarWindow32; INSTANCE:1]","left",1,16,16)

I use this method a lot for clicking specific buttons on toolbars where I can not get an ID for the individual buttons.

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950%28v=vs.85%29.aspx

You ve to send WM_LBUTTON message

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645608%28v=vs.85%29.aspx

I am sure, that it will be hard for you, if you didnt code in C lang before

Share this post


Link to post
Share on other sites

Use Control click

This example will click the back button in IE without moving the mouse cursor

opt("MouseCoordMode",2)
ControlClick("[CLASS:IEFrame]","","[CLASS:ToolbarWindow32; INSTANCE:1]","left",1,16,16)

I use this method a lot for clicking specific buttons on toolbars where I can not get an ID for the individual buttons.

But ControlClick command works only for control objects, if I want to click on a specific point or on a picture,it won't work :doh:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950%28v=vs.85%29.aspx

You ve to send WM_LBUTTON message

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645608%28v=vs.85%29.aspx

I am sure, that it will be hard for you, if you didnt code in C lang before

YES This would be perfect! I am learning C++ :oops: but I'm still at pointers so I don't understand too good the APIs yet.

I would really appreciate if someone could show me how to declare this API in a AU3 code :bye:

Thankyou!

Share this post


Link to post
Share on other sites

But ControlClick command works only for control objects, if I want to click on a specific point or on a picture,it won't work :oops:

Just about everything you can see on a PC screen is a control or window including pictures, and controlClick will work with almost all of them if you give it the correct information

The code below will click at coords 247,344 in an IE browser window

if you change the first parameter to match whatever window your picture is in and change the coords at the end to the correct client mode coordinates I'm sure it will work for you. Give it a try you might supprise yourself.

opt("MouseCoordMode",2)
ControlClick("[CLASS:IEFrame]","","","left",1,247,344)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Just about everything you can see on a PC screen is a control or window including pictures, and controlClick will work with almost all of them if you give it the correct information

The code below will click at coords 247,344 in an IE browser window

if you change the first parameter to match whatever window your picture is in and change the coords at the end to the correct client mode coordinates I'm sure it will work for you. Give it a try you might supprise yourself.

opt("MouseCoordMode",2)
ControlClick("[CLASS:IEFrame]","","","left",1,247,344)

Can you make this work for notepad to click on the File (x 20 y 40)? Because I cant :/

Share this post


Link to post
Share on other sites

#13 ·  Posted

to Demete - With ControlClick do not work for me eighter, but with normal mouseclick work fine.

HotKeySet("{F5}", "RunIt")

While 1
Sleep(100)
WEnd

Func RunIt()
Opt("MouseCoordMode", 0)
;ControlClick("[CLASS:Notepad]", "", "", "left", 1, 26, 46)
MouseClick("left",26,46,1, 1)
Exit
EndFunc   ;==>RunIt

Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
Share on other sites

Hello there guys i know this blog is pretty old but maybe some of you are still around, im looking to simulate a click as well and while i see alot of great code im not sure to what language this code belongs to so im a bit lost, i was looking to do this using C++ or C# or even Java via the Processing IDE.

im looking to simulate a left mouse click in a specific window in my pc BUT the key is that i will be using voice to simulate that click, for example i will say "meet" and meet is a String and when this String is heard i want this program im using to do a serial.write(i +"meet"); OR port.write(i +"meet"); and when this string is detected i want that simulation to happen.

the reason is because i have this sketch in processing that requires you to click in order for something to happen and i cant just click because the pc itself will be out of reach, so i thought if i can use Visual Studios to use the speech recognition library and i can use the serial port why cant i use VS2013 to speak to it and have that send a string to processing so that it can simulate that click for me ?

Share this post


Link to post
Share on other sites

FranksDesigNatures,

Quote

 im not sure to what language this code belongs to

The code in this thread (and in the majority of the forum) is AutoIt - a windows scripting language - and this forum is dedicated to helping people use it.

Your explanation of what you wish to do makes me believe that AutoIt would not of itself be suitable (there is no speech recognition ability as far as I am aware) but you might be able to use the AutoItX DLL within your C++/C#/Java code. Perhaps a few more details on what exactly you are attempting to do would be useful to those more experienced in using the DLL than myself.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

well thanks for that explanation but i never heard of Autoit hmmm what ide do you guys use and is only for pc use right ? is not for micro controllers right ?

 

now as for you question yes, i hear you that there is no speech but if your read my post correctly i mention that i already have a written program that uses this features of verbal communication and i can even make shell commands  like open/close IE,Paint,calc,pretty much just about any program installed in my pc SO if i can have Autoit simulate a mouseclick as a  given location by just a press of a button then if my theory is correct then i should be able to tell me program to initiate that key press that autoit would assume to be mouseclick and if so then tadaaaa! we have achieve what i was looking for ? "dammm hows that for a pseudo?"

Share this post


Link to post
Share on other sites

FranksDesigNatures,

Quote

 but i never heard of AutoIt

And yet you posted in a thread of the AutoIt forum......

Quote

what ide do you guys use and is only for pc use right

Most of us use the modified SciTE editor packaged with AutoIt (or its big brother SciTE4AutoIt3) but that is not an IDE as generally understood. There a couple of IDEs available - ISN AutoIt Studio is probably the most developed.  And yes, AutoIt is for Windows only as it uses the Windows APIs to do most of the work (although it does partly work on Linux with WINE).

Quote

i should be able to tell me program to initiate that key press that autoit would assume to be mouseclick

I thought the idea was to get AutoIt to simulate a mouseclick?

M23 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Quote

I thought the idea was to get AutoIt to simulate a mouseclick?

yes but as i been reading autoit does not just randomly do mouseclick does it now? you need todo something for that simulation to occur,

Share this post


Link to post
Share on other sites

 FranksDesigNatures,

Let us try and make some sense out of this request. If I have understood correctly, you have a PC which is "out of reach" for some reason and you want to click in a running app when you speak a certain word. So a few questions:

  • Why is the PC "out of reach"?
  • What is the app that needs to be clicked?
  • How does your existing "speech recognition" program make the shell commands you mentioned - i.e. how will it communicate with an AutoIt executable?

Once we get a better handle on what you are trying to do we can start making sensible suggestions as to how you might achieve your aims.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

your questions seems a bit out of subject, i dont see how this would help you identify my main question.

Quote

Why is the PC "out of reach"?

im not sure why this matters so perhaps you might want to clear this up.

Quote

What is the app that needs to be clicked?

again im not sure why ask, from what i gather this is very little of importance and which is why i like to know how to go about using this script, because as i understand autoit does not care about the program but about the x&y coordinates of your pc screen.

Quote

How does your existing "speech recognition" program make the shell commands you mentioned - i.e. how will it communicate with an AutoIt executable?

lol again though i will admit that for you to ask this specific question that tells me that you do not know C++/C# as if you did you would know how im doing this, so that being said all i can tell you is that i program my  pc todo such feats using vs2013,

Quote

how will it communicate with an AutoIt executable?

well like i said autoit does not care about other programs it just cares about "that" specific key you will press to simulate that mouse click on this part of the screen 'x&y' same goes for my program, it does not interacts with any program but itself all that it cares is that my voice is heard and soon after it will meet a conditional statement saying that IF user said 'click' then it will respond by simulating that key press that autoit is expecting for that mouse click to happen where i have predefined before.

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