I am writing a program that connects to design software, like an external plugin, then monitors mouse movement and events. It will take actions based on to the state of the connected software mouse events.
The idea is the external application will have the capability to interface to multiple similar programs instead of program specific plugins.
The prototype, and potentially the production software, is being written in python using the Tkinter GUI library. The attempt is to make it simple and portable.
I was easily able to grab "OS" level mouse position (true screen X,Y) without the Tkinter window needing to be active. My issue is that I am not finding a way to easily get the mouse click events from Tkinter. I can only gather events when over the active Tkinter window.
Tkinter provides this for mouse position:
coord = self.gui.winfo_pointerxy()
I cannot find similar for mouse events. There are libraries like selfspy and Pymouse (now part of PyUserInput) that monitor events, but are mainly for control of the input devices. My backup idea is to use these libraries for reference on writing my own input monitoring program.
My two main platforms are Mac and Windows.
Long story short:
- Can Tkinter give me mouse events when the events are outside the Tkinter window.
- If not, are there other options "out of the box" that can give me mouse X,Y and mouse events.
- If there are no out of the box solutions, some recommendation on approach and API. (looks like win32api for windows, Quartz and/or Cocoa in Mac and Xlib in Linux)
Thanks for your time