本文整理汇总了Python中ctypes.windll.user32方法的典型用法代码示例。如果您正苦于以下问题:Python windll.user32方法的具体用法?Python windll.user32怎么用?Python windll.user32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ctypes.windll
的用法示例。
在下文中一共展示了windll.user32方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryMousePosition
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def queryMousePosition():
pt = POINT()
windll.user32.GetCursorPos(byref(pt))
return { "x": pt.x, "y": pt.y}
示例2: run
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def run(self):
if self.install_hook():
print "mouselogger installed"
else:
raise RuntimeError("couldn't install mouselogger")
msg = MSG()
user32.GetMessageA(byref(msg),0,0,0)
while not self.stopped:
time.sleep(1)
self.uninstall_hook()
示例3: hook_proc
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def hook_proc(self, nCode, wParam, lParam):
##http://www.pinvoke.net/default.aspx/Constants.WM
if wParam == 0x201:
buf, height, width = self.get_screenshot()
self.screenshots.append((datetime.datetime.now(), height, width, buf))
return user32.CallNextHookEx(self.hooked, nCode, wParam, lParam)
示例4: __init__
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def __init__(self, *args, **kwargs):
threading.Thread.__init__(self, *args, **kwargs)
self.hooked = None
self.daemon=True
self.lUser32=user32
self.pointer=None
self.stopped=False
self.screenshots=[]
示例5: set_process_dpi_aware
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def set_process_dpi_aware():
if sys.platform[0:3] == 'win':
windll.user32.SetProcessDPIAware(True)
示例6: get_screen_size
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def get_screen_size():
if sys.platform[0:3] == 'win':
user32 = windll.user32
return user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
elif 'darwin' in sys.platform:
pass
elif 'linux' in sys.platform:
pass
return (1366, 768)
示例7: notify_win
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def notify_win(title, text):
try:
from servo.win32_toast import WindowsToast
w = WindowsToast()
w.balloon_tip(title, text)
except:
from ctypes import Structure, windll, POINTER, sizeof
from ctypes.wintypes import DWORD, HANDLE, WINFUNCTYPE, BOOL, UINT
class FLASHWINDOW(Structure):
_fields_ = [("cbSize", UINT),
("hwnd", HANDLE),
("dwFlags", DWORD),
("uCount", UINT),
("dwTimeout", DWORD)]
FlashWindowExProto = WINFUNCTYPE(BOOL, POINTER(FLASHWINDOW))
FlashWindowEx = FlashWindowExProto(("FlashWindowEx", windll.user32))
FLASHW_CAPTION = 0x01
FLASHW_TRAY = 0x02
FLASHW_TIMERNOFG = 0x0C
params = FLASHWINDOW(sizeof(FLASHWINDOW),
windll.kernel32.GetConsoleWindow(),
FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0)
FlashWindowEx(params)
示例8: __init__
# 需要导入模块: from ctypes import windll [as 别名]
# 或者: from ctypes.windll import user32 [as 别名]
def __init__(self):
"""Initialize our object"""
# Find the start x,y pos of the main pygame *screen* (the screen in the
# window):
sdlpos = os.getenv("SDL_VIDEO_WINDOW_POS")
if sdlpos is None:
raise Exception("Must have previously setup a Pygame window starting position via the 'SDL_VIDEO_WINDOW_POS' evn var.")
self.initPygameScreenPos = [int(i) for i in sdlpos.split(",")]
# Run our ctypes code to query window position:
try:
# It's said that not all systems support this dictionary key. I'm
# not sure what systmes those are, but might as well put a check in.
self.hwnd = pygame.display.get_wm_info()["window"]
except KeyError:
raise Exception("Your system isn't accepting the code: 'pygame.display.get_wm_info()[\"window\"]', must not be supported :-(")
self.prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
self.paramflags = (1, "hwnd"), (2, "lprect")
self.GetWindowRect = self.prototype(("GetWindowRect", windll.user32), self.paramflags)
# Find the initial *window* position:
rect = self.GetWindowRect(self.hwnd)
# Calculate the thickness of the *window* border to the *screen* object inside:
self.borderThickness = int(self.initPygameScreenPos[0]) - rect.left
self.titleThickness = int(self.initPygameScreenPos[1]) - rect.top
# borderThickness is the left, right, and bottom window edges. titleThickness
# is th thickness of the top title-bar of the window.