Open kmorgan2 opened 8 years ago
Example: Getting a pixel color of the top window at a given position
color = int(win32gui.GetPixel(win32gui.GetWindowDC(app.top_window_().handle), 130,130))
(color & 0xff), ((color >> 8) & 0xff), ((color >> 16) & 0xff)
@tmalauskas
def get_color(window, x,y):
handle = window.handle
color = int(win32gui.GetPixel(win32gui.GetWindowDC(handle), x,y))
return ((color & 0xff), ((color >> 8) & 0xff), ((color >> 16) & 0xff))
you should break it up to ensure memory management works as intended Before the return you should run
def get_color(window, x,y):
handle = window.handle
dc = win32gui.GetWindowDC(handle)
color = int(win32gui.GetPixel(dc, x,y))
win32gui.ReleaseDC(handle, dc)
return ((color & 0xff), ((color >> 8) & 0xff), ((color >> 16) & 0xff))```
Write Malwarebytes run/install automation using pywinauto
For reference, previous code available here