WPF, "emulate" mouse click
Hi. I am working with WPF and I am adding Wintab API(tablet API). I want to "emulate" mouse click event on specific coordinates to avoid creating own buttons and other controls that will have this compatibility. Is there any option to call some kind of event or easily create own?
9 Replies
And I don't wanna move cursor to this position
Why do you need to emulate a mouse click
I have a pen input from Wintab that is independent from mouse. I want to have possibility e.g. clicking a button with pen
Is it a physical pen device?
I don't know if there is a way to force WPF events, but if not and nothing else works you could use possibly harmony to force trigger an event at the desired location
Yes it is psychical wacom tablet
I will try to find some solution
Or maybe somebody else have any idea
i wrote some code here to turn my tablet into a mouse. tl;dr you could use sendinput to send mouse clicks or mouse_event. but you will have to dllimport one of these functions
https://github.com/QubitTooLate/RawWacom/tree/main/src
GitHub
RawWacom/src at main · QubitTooLate/RawWacom
Small app to use a Wacom tablet as a mouse. Contribute to QubitTooLate/RawWacom development by creating an account on GitHub.
$dllimport
You can use the DllImportAttribute to call functions from C dlls in C#. In newer versions of C# use LibraryImportAttribute.
Example:
im assuming you want to do a mouse click on your desktop trough code. if you want it just in your wpf app id suggest pinvoking PostMessage instead and sending a WM_LBUTTONUP