Detect Mouse Cursor changes in Windows - python-3.x

I will like to know which python library I can use for detecting changes to the mouse pointer state. Say a change from "arrow" to "hand". I have looked at pyhook, pyautogui, pynput, pywin32, pynput. These may have functions for detecting mouse movements and clicks but none dedicated to detecting cursor icon change. I know this can be implemented because i have code implementing it in C++ but just not python. Looking forward to the communities response.

Related

Disabling minimize feature in qml

Is there a way to make a Qt window (qml with pyside2) to never minimize?
(Not the minimize button)
I'm trying to achieve something like conky (Linux) or rainmeter (Windows) with python 3 and qml (Qt).
I want a borderless window to stay on the back of the screen and stay there no matter what as if it's part of the wallpaper. Making the window borderless was achieved with the Qt.SplashScreen flag but disabling minimize turns out to be much harder than I initially thought. All the methods I've tried hides the window when win+D is pressed.

Detecting touchpad movement vs regular mouse programmatically on Linux

I love the mod4 + mouse-drag combo for moving/resizing windows in Awesome WM, it's very intuitive with regular mouse. Now that I'm using Awesome WM on my laptop, however, I find this combo more annoying when using the touchpad vs regular mouse.
The problem stems from the fact that I now need 3 fingers to perform a gesture that I could do with 2 before (1 to move on the touchpad, 1 to keep on the left-click at all times, and one on mod4). Alternatively, I can apply more force to the touchpad and have it pressed as I drag my finger, which is not any better since it puts a lot of stress on the finger doing the dragging).
What I would like to do instead is have awesome treat left-mouse button as pressed if both of the following conditions are met:
mod4 is pressed
movement event is coming from touchpad and not regular mouse
To do so, however, I need to be able to detect that the movement is coming from the touchpad. Is there a way to do so in Awesome WM/Linux? I've looked through the keysyms (http://wiki.linuxquestions.org/wiki/List_of_keysyms) but don't see anything for the mouse. I've also looked at the mouse.lua file in Awesome WM but it doesn't seem to have anything to differentiate between the two either (https://github.com/awesomeWM/awesome/blob/master/lib/awful/mouse/init.lua). If there is a way to tell that the last coordinate change came from a touchpad on Linux that would resolve the issue as I could simply create a lua file to run such check whenever Mod4 is pressed.
To do so, however, I need to be able to detect that the movement is coming from the touchpad. Is there a way to do so in Awesome WM/Linux?
Nope, there is no such way in AwesomeWM. Sorry.
In X11, this is possible via the input extension. However, awesome does not use that extension.

Drawing Custom Context Menus Anywhere on Desktop

I'm trying to figure out a way to draw a context menu foo at the cursor's current position no matter where on screen it is (i.e. over a window that has nothing to do with my program), and I can't seem to find a clean way of doing this, as all the libraries I can find define context menus upon the current window.
The things that come to mind for me are:
A: Drawing a tiny window at the cursor and then immediately opening up a context window
B: Drawing borderless windows that act like context menus
C: Drawing directly to the root window
However, none of these seem like clean and portable solutions, so I figured I would ask before diving into code.
I know that this is not what context menus were designed for, but the look fits my application very well. I would prefer to use Qt to keep things portable across systems, but at the moment I really only care about X on Linux.
Edit: 1st paragraph expansion

Propagating all events from a X window

I'a currently working on a small utility, it's my first ever X project. The utility is used to draw a small circle around your mouse pointer. I use an app called Pinpoint to do the same on my Mac, it helps me find my mouse as I'm visually impaired.
The utility creates an transparent X window and draw a circle inside, it then moves that window with the mouse pointer so that the circle follows the mouse.
It currently works, except for one detail. Mouse events are not propagated up to the underlying windows. Basically, the utility makes the mouse useless.
As far as I can tell from the Xlib docs, if not otherwise specified, new windows should propagate all events. How can I fix this?
The code can be found on GitHub: https://github.com/blubber/circle-cursor it's a bit messy currently, becaue it is just a proof of concept.
I would suggest doing via cursor image as well, there are many ways when you won't be able to receive mouse events and only possible source would be polling with XQueryPointer.
With xfixes extension you can subscribe to all cursor image changed events and get most recent shape of the cursor, and whit XRender you can set your own ( possibly animated cursor )

Click events in linux using opencv

I am doing a project to control mouse events by hand gestures using opencv in linux. I am able to control the mouse pointer with my hand movements.
I have achieved counting the number of fingers in the hands. I want to trigger mouse events depending upon the number of fingers shown. In windows there is a function mouse_event. But i am working in linux.
If there is any function for click events in opencv(linux) please let me know. Also help me with the header files to be included for those functions.
Thanks in advance!!
You can use Xlib library for handling mouse events in Linux environment. Xlib is an XWindow System protocol library. It contains functions for interacting with an X server. Main advantage of using Xlib in you project is that, you can handle mouse events globally( throughout the desktop, or in other window, not locally in your application window ).
Check out Xlib-MouseClick.
Just call the function mouseClick() in your program with argument -
0 - for left click,
1 - for middle click, and
2 - for right click, at current position of mouse pointer.

Resources