Simulating Mac Mouse Events beyond CGCreateMouseEvent - macos

I've been successfully using CG mouse events to simulate mouse down/drag/up events using a specialized hardware controller. However, I come across some applications in which using these CG mouse events has no effect- that is, I can click and drag the actual mouse to change controls within a certain area of the application, but simulating these exact same movements using CGCreateMouseEvent (tried posting to HID system state and CombinedSession state) does not work.
Perhaps these apps are listening specifically for a mouse/touchpad hardware device? Is there any way to more "realistically " simulate mouse events so that these app think the actual mouse/touchpad is dragging?

Related

How to prevent mouse click event on Windows

I record the mouse events on windows by using robotgo package. Package provides to get bitmap of clicked area but the latency of having bitmap is super sensitive situation here.
For example:
If I click any checkbox which is unchecked on the screen, provided bitmap must contains the state of unchecked but it provides me checked state and cannot simulate it with robotgo or cannot trigger click by using bitmap.
Solution to this scenario is that I need to prevent windows mouse click event until bitmap provided by the package (or adding some delay for click event) then trigger the click event on windows.
I made some research online but couldn't find a proper solution. How prevent click event on Windows in Go? Is it possible or is there any other way to make it happen?
A low-level mouse hook can eat mouse events. SendInput can generate mouse input events.
You would have to set a flag somewhere so you don't eat your own fake input events.
Keep in mind that SendInput is not perfect (can be detected by other hooks) and playing with the input system like this is usually not the best solution. Adding 500ms (or some other delay) to every mouse click is going to be very annoying for your users.
It is better to use UI Automation to get information about UI element states in other applications...

Secondary touch monitor not moving with the cursor but still pressing buttons (or emitting events for Qt app)

I intend to make an app for Windows in Qt with multi-monitor support, one (secondary) monitor being touch. I want one person to be able to work with the touch screen independently on a second person, which would be working on the main screen with mouse and keyboard.
I don't have the the touch monitor yet, so I don't know how it really works, but I am afraid that touching the monitor would move the cursor (mouse pointer), making the work with mouse very hard.
So my question:
Is it possible somehow to make the touch screen not to affect the cursor in any way (not interrupting drag&drop counts, too), but still to be able to push buttons n' stuff, and that on either Windows or Qt level?
No buttons pushing, but generating QTouchEvents (or similar) would be sufficent, too.
Thanks for your responses.

Is X11's design tightly coupled to a program's usage capabilities?

Say I want to create my own button with an arduino. Would I be able to call an X11 Event with that button every time it was clicked so that my program running would see it as a mouse click? Does the window currently have to be in focus for this to happen? Is the mechanism behind graphical user interfaces (X11) tightly dependent on the conventional windowing system, mouse, keyboard, and screen?

Limit mouse movement to one window only

I am trying to mimic a Head-Up Display in a racing simulator, and I want to display a semi-transperant program window (i.e. a browser window showing a java applet) which limits mouse movements to that window only.
That way I can use a USB-track pad or the like to interact with the content in the dialog screen while still interacting with the racing simulator.
My question is mainly focused on the restriction of mouse movement, is this possible in Windows 7?
Regards
Use the ClipCursor API call - Make sure you undo any clipping when your window is deactivated or minimized.

VC++ mouse events

I want to write a console program for mouse events (Only mouse scroll). How do I do it in VC++? The application will listen only to scroll events.
Description: If the user scrolls down, the Desktop window fades down, and fades-in when user scrolls up.
Here I just need to know to to listen to mouse events in console app.
Note: I am developing using win32 API, and for development environment I am using VS2010.
I've never actually done this myself. It seems that a console application responding to mouse events almost belies its nature and intended purpose. Generally, you would only need to respond to keyboard input from a console app and leave the mouse stuff to a GUI app.
That being said, this tutorial indicates that it is in fact possible to capture these mouse events from a Win32 console application. Generally, the suggestion is to use the ReadConsoleInput function and extract the information of interest from the INPUT_RECORD structure that it fills. The only tricky thing is that the call to ReadConsoleInput is a blocking call, which means it will not return until there is an input event fired. You'll need to structure your application's code accordingly. Mouse events are covered in detail about 3/4 of the way down the page.

Resources