Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How do I attach a python program to a window?

How do I attach a python program to a window? Lets say minecraft how would I attach the program to that window and have it auto click or mine while afk and I go and do other things, is that possible?

 

Link to post
Share on other sites

Does the Python script output keystrokes or mice-movement/clicks?

If not theres no way Minecraft knows whats happening unles you hook into it. Which is most likely considered cheating so not to easy to do.

Im not to familiar with Python in all honesty, but it sounds more like you could use a key macro or something similar.

When i ask for more specs, don't expect me to know the answer!
I'm just helping YOU to help YOURSELF!
(The more info you give the easier it is for others to help you out!)

Not willing to capitulate to the ignorance of the masses!

Link to post
Share on other sites

I don't have an exact solution but you should be able to import the ctypes module and use the win32 libraries (specifically winuser) to send input to a window.

 

I have used those libraries to send input to applications before using C++ but never python (honestly never spent much time with python either). So I don't know exactly how that works.

 

Edit: This would be the specific C function you would want to invoke from python. https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput

 

This will send input to the currently focused window.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×