This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import win32api, win32con, win32gui, win32ui | |
| def main(): | |
| hInstance = win32api.GetModuleHandle() | |
| className = 'MyWindowClassName' | |
| # https://msdn.microsoft.com/en-us/library/windows/desktop/ms633576(v=vs.85).aspx | |
| # win32gui does not support WNDCLASSEX. | |
| wndClass = win32gui.WNDCLASS() | |
| # https://msdn.microsoft.com/en-us/library/windows/desktop/ff729176(v=vs.85).aspx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import namedtuple | |
| KeyboardEvent = namedtuple('KeyboardEvent', ['event_type', 'key_code', 'scan_code', 'alt_pressed', 'time']) | |
| handlers = [] | |
| def listen(): | |
| from ctypes import windll, CFUNCTYPE, POINTER, c_int, c_void_p, byref | |
| import win32con, win32api, win32gui, atexit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ctypes, time | |
| SendInput = ctypes.windll.user32.SendInput | |
| # C struct redefinitions | |
| PUL = ctypes.POINTER(ctypes.c_ulong) | |
| class KeyBdInput(ctypes.Structure): | |
| _fields_ = [("wVk", ctypes.c_ushort), | |
| ("wScan", ctypes.c_ushort), | |
| ("dwFlags", ctypes.c_ulong), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ctypes | |
| def winGetClipboard(): | |
| ctypes.windll.user32.OpenClipboard(0) | |
| pcontents = ctypes.windll.user32.GetClipboardData(13) # CF_UNICODETEXT | |
| data = ctypes.c_wchar_p(pcontents).value | |
| ctypes.windll.user32.CloseClipboard() | |
| return data | |
| print (winGetClipboard()) |