Joke Collection Website - Talk about mood - Tutorial on using Pywin32 under Python

Tutorial on using Pywin32 under Python

You can go directly to the win32 directory under site-packages of lib, there is a demos. Several other directories starting with win32 also have demos subdirectories. Go in and see the examples they have written.

A few simple tutorials:

Use

query handle

# Query the handle based on the class name and title name,

hwnd = win32gui.FindWindow("Tfrm_YzzPlayer","YeZhu Mobile Game Simulator")

# Find the subhandle of the specified handle. The last two parameters are the class name and title of the subclass. If there is none or you are not sure, you can write None

hwnd = win32gui.FindWindow(hwnd,None,"sub_class","sub_title")

Modify the window size

# There is no way to directly modify the window size, but it can save the country. Several parameters respectively represent the handle, starting point coordinates, width and height, and whether to redraw the interface. If you want to change the window size, you must specify the coordinates of the starting point, but it does not work. There is no requirement for the coordinates of the starting point, you can just write it casually; if you still want to place it at the original position, you need to get the previous border position first, and then call this method

win32gui.MoveWindow(hwnd, 20,20,405,756,True)

Foreground and background

# Specify the handle to be set to the foreground, that is, activate

win32gui.SetForegroundWindow(hwnd)

< p># Set as background

win32gui.SetBkMode(hwnd, win32con.TRANSPARENT)