def up():
global id4, proc, hwnd
mouse = POINT()
user32.GetCursorPos(ctypes.byref(mouse))
hot.removeHotkey(id=id4)
if proc is not None:
proc.terminate()
print("-" * 40)
print_handles("GetForegroundWindow", user32.GetForegroundWindow())
active_window = print_handles("WindowFromPoint", hwnd)
print_handles("GetParent", user32.GetParent(active_window))
ancestor = print_handles(
"GetAncestor", user32.GetAncestor(active_window, 3))
if ancestor:
# GetAncestor is the most correct for our use-case, so prefer it.
active_window = ancestor
rect = RECT()
user32.GetWindowRect(active_window, ctypes.byref(rect))
grid = find_matching_grid(mouse.x, mouse.y)
if grid:
grid = to_rect(grid)
if is_aero_enabled():
arect = get_actual_rect(active_window)
grid.left -= abs(arect.left - rect.left)
grid.top -= abs(arect.top - rect.top)
grid.right += abs(arect.right - rect.right)
grid.bottom += abs(arect.bottom - rect.bottom)
width = grid.right - grid.left
height = grid.bottom - grid.top
print("width: %d height: %d" % (width, height))
HWND_NOTOPMOST = -2
user32.SetWindowPos(active_window, HWND_NOTOPMOST,
grid.left, grid.top, width, height, 0)
user32.SetForegroundWindow(active_window)
proc = None
hwnd = None
评论列表
文章目录