Emulate a mouse click without using the actual mouse on linux - python

I am working with a program that collects a lot of data then shows it to you in the program. Unfortunately, the program is poorly designed and requires you to "approve" each bit of data collected manually by clicking a checkbox to approve it. In order to automate this process, I wrote a small script that scans for a checkbox, clicks it, then clicks "next item".
Unfortunately, this requires moving the actual mouse, meaning I can't use my computer until the program has finished. There are other questions that reference automating this with the winapi, however none of these work on Linux. What is a way to automate this on Linux?

You can simply start the program in a separate X server, for example using xvfb with
xvfb-run YOUR_PROGRAM
If you want to wrap just the instrumented program, that's possible too:
export DISPLAY=:42
Xvfb :42
THE_INSTRUMENTED_PROGRAMM
xdotool mousemove 1 1 click 1 # your instrumentation goes here

Related

Interact with website without sending keystrokes to window (Python, Windows)?

Is it possible to interact with a webpage loaded into a web browser (such as Chrome) without the window being active and without sending keystrokes to it? For example, suppose I have SoundCloud loaded in chrome and the chrome window minimized, but I want to create a hotkey on my computer (such as through Autohotkey) which acts as a play/pause button for the track. Would it be possible to have a Python script somehow interact with the browser to obtain that functionality without having to send it a keystroke?
The reason I'm trying to avoid having to send keystrokes is because it would require the Window to become briefly maximized and active. I can already do this in autohotkey. For example, I have an ahk script that iterates over all the windows, finds one with Soundcloud in the title, maximizes the window if it is minimized, sends the spacebar keystroke (which acts as play/pause on Soundcloud), and then minimizes the Window again if it was minimized to begin with.
This has the undesirable effect of making the Window flash briefly if it was minimized, or if virtual desktops are used, all the Windows flash if the Chrome window with Soundcloud is located on another virtual desktop other than the active one.
Ideally I could just write some program that runs silently in the background to send some kind of the request to the site that has the same effect as pressing the play/pause button without having to use the janky keystroke method I suggested above. But I am not sure if this is possible. What is actually happening when I click the play/pause button on Soundcloud, and is there some way write a program to get Chrome to do that without using keystrokes?
Any suggestions? I would prefer to do this without any browser plugins if possible.

How to run mouse and keyboard events in a minimized window

I am looking for a way to run mouse and keyboard events in a minimized window, simple as that - the code does something in a specific window, while my computer is free - I can search the web and do whatever; I need Python 2 specifically, but open for 3 suggestions too; This is for automatization of certain tasks I have, I managed to make it work while my computer is in use, but now I need to run it in the background.
Thank you in advance.

Create a delay between mouse clicks using Autokey

I am about to switch from Windows to Ubuntu. Since my mouse keeps doing multiple clicks each time I press the middle mouse button, I used AutoHotkey under Windows to add a delay after each click. This worked fine. Now under Ubuntu I want to use AutoKey to do the same. Autokey uses Python for its scripts though.
Here is the AutoHotkey script:
MButton::
If (A_TimeSincePriorHotkey < 200)
Return
Send {MButton}
Return
Currently, (as of version 0.95.4), this is not possible from within AutoKey, because it can’t handle mouse buttons as hotkeys.
This stackoverflow question may be of help: Triggering AutoKey Script via Mouse Button - How To?

Uncomplicated window interface for displaying status in python

I am trying to create a window in python where I will be displaying the status of a large system, a bunch of numbers or some LEDs. The idea is that the system sends messages to the display thread and the thread updates different parts of the window, like displaying a number or turning the color of a field. More importantly, the user interacts with system via command line of python interpreter, e.g. executing commands or updating variables.
One may simply suggest that I need to use one of the GUI packages, like pyqt or xwpython. But these modules are designed to build GUIs, that means they have plenty of resources to handle events moues clicks and so on, which I don't need. Also, these modules run a event loop which is a waste of resources as well as in many cases they block the python shell.
I tried to use pyqt without running the main loop. But when I do this windows thinks my application is not responding, and I get a bunch of problems. For example the close button on the window does not work, and any effort on closing it crashes my python session.
Any ideas on how I can implement my application?
Maybe you should consider to use the Apache's Superset dashboard.
Check this up:
https://superset.incubator.apache.org/installation.html
It makes amazing dashboards incredibly easy and useful.

Python EasyGUI: Systray icon xor multiple windows

I'm writing a simple program that gives you a message to take a break from sitting at your Computer every x minutes. However, I also need to be able to close the program without having to wait for a window to pop up after x minutes.
My ideas are that I either create a systray icon (I'm programming it for a friend who uses Windows) and add the possibility to exit it that way, or that I just add another window, which has an exit button and stays open all the time (less elegant).
From what I have read, it seems that the systray idea requires something more complex than easygui.
So, is there a way to implement any of those ideas with easygui and if not: what do I need to look at to get it working?
Thanks for your time and effort.

Categories