Python: Click by coordinate inside a window - python-3.x

The goal of the program i'm trying to write is a bot that can click and play flash games and press keys inside a window webpage even when I do not have the window selected. My question is very similar to this. What I want to know is how to use win32, selenium, and PIL to take screenshots, analyze the screenshots, and click and press buttons accordingly from the bot. I've looked through the win32api documentation and found little about how to click inside a window in the background.
If someone could give a link to someone who has done this before or just a little nudge in the right direction would be amazing!

pywinauto is even simpler, but it may not recognize Flash controls. The code should just look a bit shorter:
import pywinauto
app = pywinauto.Application().connect(path='process_name.exe')
app.MainDialog.click_input(coords=(953, 656))
To check which controls are visible:
app.MainDialog.print_control_identifiers()
P.S. If you work with Python 3.x, this clone is compatible with Py3.

If your goal is detecting and interacting with images on screen, you might want to take a look at Sikuli. This is exactly what it does. Sikuli automates anything you see on the screen. It uses image recognition to identify and control GUI components. It is especially useful when there is no easy access to a GUI's internal or source code. More info here.

Related

Writing panels/docks with pyQt

I want to write something like a taskbar/dock/panel(like tint2,...) with pyQt5.
I know how to write regular GUI applications with it, but my tiling window manager(herbstluftwm) maximizes my panels and openbox makes them resizable etc.
My question : How can I make pyQt show my application as a panel instead of a window? I haven't found anything about that in the documentation.
Thank you.
Thanks to musicamente's help, i could find that the function setWindowFlags() is what I need. It allows to change the behavior of a window.
A website explaining this function is https://pythonprogramminglanguage.com/pyqt5-window-flags/

Xlib: XCreateSimpleWindow steal steals focus

I have a question regarding the XCreateSimpleWindow function in Xlib.
I have a small screen on my graphical panel, which steals the keyboard input once this function gets called, and does not allow me to navigate/do anything, on the rest of the screen, e.g. use keys to navigate in the menu or similar.
The small screen is used for video streaming, and I have tried to use the function XSetInputFocus on the parent window, but that does not seem to help. I would be grateful if somebody could give me some ideas on how to solve this issue. Please let me know if more info is needed.

slide-in animation while opening new applications in linux

I am looking to achieve the following :
when an application stars up, I want it to slide in from the left of the screen
Is this possible to do in linux ? How do I go about achieving it ? I could not find any resources online, so if anyone could point me in the right direction, that would be great.
I am open to programming a solution for this too. It would be great if i can get an answer on how to program something like this.
Presumably you have control over the placement of the window. Place the window off screen, then set up a loop that moves it over one pixel at a time. Exactly how to do that depends on your GUI toolkit.

Is it possible to scale the content of a QVBoxLayout in pyqt4?

couldn't find anything with google or search.
I have some QPushButtons and QLabels in a QVBoxLayout. Now I want them to scale down. Not only the text, the hole QButton and QLabel. Is that possible? If yes, can you please tell me how or post me a link to the doc. I'm pretty sure, that there must be a way. But I think I'm searching with the wrong words.
Not sure what you mean, but perhaps you're looking for QBoxLayout::addStretch? By the way, I recommend using Qt Designer to create your layout, PyQt4 comes with a tool called pyuic4 that creates the Python code for you. Qt Designer allows you to visually insert spacer items.

How to write an X11 app that follows the cursor

I'd like to write a Linux screen magnifier that's customized to my liking. Ideally, the magnified window would be a square about 150 pixels wide that follows the mouse cursor wherever it goes.
Is it possible to do this in X11? Would it be easier to have an application window that follows the mouse around, or would it be better (or possible) to forget about the window altogether and just make the mouse pointer a 150x150 square that magnifies whatever's underneath?
Look at the source to xeyes?
This actually already exists, it's called Xmag (do a Google search for additional info). You might want to check out the source code for it if you want to know how it works.
EDIT: looks like I misread your question a little bit... if you want a magnified square to follow the mouse pointer around, I suppose it should be possible, but I don't know the technical details of how you'd do it. Regardless, the place to start is probably by looking at Xmag as a starting point.
I am unsure if this can run as its own app or would have to be integrated into your window manager. Either way, you would need libx11 (might have a different name from distro to distro). Also, I would suggest taking a look at swarp. I know this is not even close to what you are talking about, but the source code is only 35 lines and it shows what can be done with libx11.
I would personally make that a frameless window that always stays atop with a 1px hole in the middle. The events that the user makes (Mouse clicks, keypresses, whatever) is passed to the window below.
And when the user moves it's cursor it is ought to be visible to your window and you just move it over a bit. For the magnifying part, well - that is left as an exercise to the reader (Because I do not know how to do that as of yet ;-).
Texworks comes with such a feature to inspect the pdf resulting from typesetting a latex source. You can also choose between a square or a circular magnifier. See https://www.tug.org/texworks/ for access to the code which can serve a launchpad.

Resources