本文整理汇总了Python中ctypes.windll.user32方法的典型用法代码示例。如果您正苦于以下问题:Python windll.user32方法的具体用法?Python windll.user32怎么用?Python windll.user32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ctypes.windll
的用法示例。
在下文中一共展示了windll.user32方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
# 需要导入模块: 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}
# 需要导入模块: 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()
# 需要导入模块: 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)
# 需要导入模块: 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=[]
# 需要导入模块: 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)
# 需要导入模块: 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)
# 需要导入模块: 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)
# 需要导入模块: 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.
注:本文中的ctypes.windll.user32方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;
联系客服