I'm currently in the process of making my Nintendo Wiimote (Kinda sad actually) to work with my computer as a mouse. I've managed to make the nunchuk's stick control actually move the mouse up and down, left and right on the screen! This was so exciting. Now I'm stuck.
I want to left/right click on things via python when I press A, When I went to do a search, All it came up with was tkinter?
So my question is, What do I call to make python left/right click on the desktop, and if it's possible, maybe provide a snippet?
Thank you for your help!
NOTE: I guess I forgot to mention that this is for Linux.
I didn't see this mentioned, so here it goes - there is also
python-dogtail
; see:It requires "Enable assistive technologies" in the Gnome Desktop - but can in principle obtain e.g. names of GUI buttons of an application, and allow virtual clicks on them (rather than via x/y coordinates).
python-uinput is very easy to use.
http://tjjr.fi/software/python-uinput/
Here's an example https://github.com/tuomasjjrasanen/python-uinput/blob/master/examples/mouse.py
You can install the PyAutoGUI GUI automation module from PyPI (run
pip install pyautogui
) and then call thepyautogui.click()
to click on a certain X and Y coordinates of the screen:PyAutoGUI works on Windows, Mac, and Linux, and on Python 2 and 3. It also can emulate the keyboard, do mouse drags, take screenshots, and do simple image recognition of the screenshots.
Full docs are at https://pyautogui.readthedocs.org/
You can try to interface XTE program from the Python script.
You can use PyMouse which has now merged with PyUserInput. I installed it via pip:
apt-get install python-pip
pip install pymouse
In some cases it used the cursor and in others it simulated mouse events without the cursor.
You can also specify which mouse button you want used. Ex left button:
Keep in mind, on Linux it requires Xlib.
Open your terminal and goto cd /usr/share/pyshared/twisted/protocols/mice
may this
__init__.py
mouseman.py
python script will work for you,check them out.