本文整理匯總了Python中lib.common.defines.USER32類的典型用法代碼示例。如果您正苦於以下問題:Python USER32類的具體用法?Python USER32怎麽用?Python USER32使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了USER32類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: click_mouse
def click_mouse():
# Move mouse to top-middle position.
USER32.SetCursorPos(RESOLUTION["x"] / 2, 0)
# Mouse down.
USER32.mouse_event(2, 0, 0, 0, None)
KERNEL32.Sleep(50)
# Mouse up.
USER32.mouse_event(4, 0, 0, 0, None)
示例2: foreach_child
def foreach_child(hwnd, lparam):
# List of buttons labels to click.
buttons = [
"yes",
"ok",
"accept",
"next",
"install",
"run",
"agree",
"enable",
"don't send",
"don't save",
"continue",
"unzip",
"open",
"close the program",
"save",
"later",
"finish",
"end",
"allow access",
"remind me later",
]
# List of buttons labels to not click.
dontclick = [
"check online for a solution",
"don't run",
"do not ask again until the next update is available",
"cancel",
"do not accept the agreement",
"i would like to help make reader even better"
]
classname = create_unicode_buffer(128)
USER32.GetClassNameW(hwnd, classname, 128)
# Check if the class of the child is button.
if "button" in classname.value.lower() or classname.value == "NUIDialog" or classname.value == "bosa_sdm_msword":
# Get the text of the button.
length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
if not length:
return True
text = create_unicode_buffer(length + 1)
USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
textval = text.value.replace('&','')
if "Microsoft" in textval and (classname.value == "NUIDialog" or classname.value == "bosa_sdm_msword"):
log.info("Issuing keypress on Office dialog")
USER32.SetForegroundWindow(hwnd)
# enter key down/up
USER32.keybd_event(0x0d, 0x1c, 0, 0)
USER32.keybd_event(0x0d, 0x1c, 2, 0)
return False
# we don't want to bother clicking any non-visible child elements, as they
# generally won't respond and will cause us to fixate on them for the
# rest of the analysis, preventing progress with visible elements
if not USER32.IsWindowVisible(hwnd):
return True
# Check if the button is set as "clickable" and click it.
for button in buttons:
if button in textval.lower():
dontclickb = False
for btn in dontclick:
if btn in textval.lower():
dontclickb = True
if not dontclickb:
log.info("Found button \"%s\", clicking it" % text.value)
USER32.SetForegroundWindow(hwnd)
KERNEL32.Sleep(1000)
USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
# only stop searching when we click a button
return False
return True
示例3: foreach_child
def foreach_child(hwnd, lparam):
# List of buttons labels to click.
buttons = [
"yes",
"ok",
"accept",
"next",
"install",
"run",
"agree",
"enable",
"don't send",
"don't save",
"continue",
"unzip",
"open",
"close the program",
"save",
"later",
"finish",
"end",
"allow access",
]
# List of buttons labels to not click.
dontclick = [
"don't run",
"do not ask again until the next update is available",
]
classname = create_unicode_buffer(128)
USER32.GetClassNameW(hwnd, classname, 128)
# Check if the class of the child is button.
if "button" in classname.value.lower() or classname.value == "NUIDialog":
# Get the text of the button.
length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
if not length:
return True
text = create_unicode_buffer(length + 1)
USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
textval = text.value.replace('&','')
if classname.value == "NUIDialog" and "Microsoft" in textval:
log.info("Issuing keypress on Office dialog")
USER32.SetForegroundWindow(hwnd)
# enter key down/up
USER32.keybd_event(0x0d, 0x1c, 0, 0)
USER32.keybd_event(0x0d, 0x1c, 2, 0)
return False
# Check if the button is set as "clickable" and click it.
for button in buttons:
if button in textval.lower():
dontclickb = False
for btn in dontclick:
if btn in textval.lower():
dontclickb = True
if not dontclickb:
log.info("Found button \"%s\", clicking it" % text.value)
USER32.SetForegroundWindow(hwnd)
KERNEL32.Sleep(1000)
USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
# only stop searching when we click a button
return False
return True
示例4: click_mouse
def click_mouse():
USER32.mouse_event(4, 0, 0, 0, None)
示例5: move_mouse
def move_mouse():
x = random.randint(0, RESOLUTION["x"])
y = random.randint(0, RESOLUTION["y"])
USER32.mouse_event(1, x, y, 0, None)
示例6: click_mouse
def click_mouse():
# mouse down
USER32.mouse_event(2, 0, 0, 0, None)
KERNEL32.Sleep(50)
# mouse up
USER32.mouse_event(4, 0, 0, 0, None)