kmorgan2 / ResTool-NXT

Computer Repair and Troubleshooting utility for ResTech, a department of NIU Housing and Dining
1 stars 1 forks source link

MWB implementation #34

Open kmorgan2 opened 8 years ago

kmorgan2 commented 8 years ago

Write Malwarebytes run/install automation using pywinauto

For reference, previous code available here

kmorgan2 commented 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)
kmorgan2 commented 8 years ago

@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))
kmorgan2 commented 8 years ago

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))```