Why won't simulated mouse click at X Y coordinates like a real mouse click?

chuckchuckit

Well-known Member
Joined
Sep 18, 2010
Messages
541
Is the only way to get a simulated mouse to click on the screen, is to go through window handles, setfocus, mouse_event etc?

Can't we somehow just use the same interrupt system the physical left button on the mouse uses when this left button is clicked by a user, and then use the mouse coordinates X Y on the screen just like the physical mouse system does?

Going through window handles etc is prone to many problems, and does not always click when it should such as applications with embedded menu codes.

Thanks.
Chuck
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Anyone have experience with Mouse driver system interrupts, via converting to VBA from code from "Assembly" or "C" languages?

Looks like the mouse port 0X33 can be accessed through the "mouse driver interrupt". Perhaps that is where direct screen clicking can be done?
 
Upvote 0
Thanks for that info. The simulated info seems to go through forms, instead of any direct screen X Y coordinates clicking I need to do.

My limited research seems to say there is no VBA access to registers like in Assembly language to trigger a screen click. But am still thinking it can be done higher level such as through the mouse driver interrupt instead?

Or perhaps, an executable file can be written in "C" that VBA can shell to, with X Y coordinate arguments passed that will perform the click, then return to VBA control.

Does this seem a possibility?
 
Upvote 0
It might be possible. Clearly Excel "knows" exactly where is cursor is with regard to its own coordinate system (otherwise Comments would never pop-up!). Its just that the information is not exposed thru VBA.
 
Upvote 0
I'm thinking it likely is possible through some round about way. Much lower level "C" language can be translated to VBA.

Perhaps someone has re-invented this wheel already, or at least may be able to get me going in the right direction, as that would save much time.

Thanks.
 
Upvote 0
There are some API functions such as mouse_event that can simulate mouse clicks and other functions that can retrieve information on the area clicked.
 
Upvote 0
Hi Jaafar, Yes I have been using the API functions such as mouse_event to do the actual clicking. And others like WindowFromPoint to find window handles, and SetForegroundWindow for focus. All those work well to set up my mouse_event clicks which click well in Excel and most other applications also.

The problem though is have an application that I can simulate clicks ok in certain places of its screen, "except" certain other places a simulated click will not work.

I have to click on a "gear" type symbol to open a drop down menu. This gear will click ok manually, but I cannot get it to simulate click no matter what approach I take. It perhaps is "imbedded java byte code" was what someone thought it might be, so there would then be no HTML tags to get at.

I know when I manual click the gear, the menu window that drops down generates a new handle #. But that handle # becomes invalid once it is closed, as the next time that menu is opened, it uses a new window handle (so can't seem to trace info like class or title through its window handle).

I seem to be stuck with somehow having to literally duplicate whatever the actual mouse does when I physically click its left button on a screen location. That is why I am starting to look at going through the mouse driver interrupt or possible lower level Assembly or "C" language calls directly to the hardware like a real mouse click does.
 
Upvote 0
Where is the gear type symbol located - Is it on a web page ? can we take a look at it so I can give it a shot.
 
Upvote 0
Its not on the web. Its a program downloaded to my computer onto hard disk, then run from desktop icon.
The gear is one of many different small icon type pictures on its window screen. Others such icon buttons such as print, export, etc also have similar drop down menus when you click them. None of which will simulate click.

Since it is not on the web might not help much to see it. But am trying to get a screenshot clip that I have of it imported into this thread but can't seem to copy it here.
 
Upvote 0

Forum statistics

Threads
1,215,490
Messages
6,125,094
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top