Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Click by coordinate inside a window

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!

like image 530
Alexander Avatar asked Nov 21 '25 00:11

Alexander


1 Answers

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.

like image 69
Vasily Ryabov Avatar answered Nov 22 '25 16:11

Vasily Ryabov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!