Beispiel #1
0
def set_mouse_key():
        byref = cy.byref
        user32 = cy.windll.user32
        WM_HOTKEY   = 0x0312
        HOTKEYS = {
                1 : (121, 0x0001),    #alt + F10  
                #1 : (0x020A, 0x0001),    #alt + MWU
        }

        HOTKEY_ACTIONS = {
                1 : handle_win_f10,
        }
        
        for id, (vk, modifiers) in HOTKEYS.items ():
                if not user32.RegisterHotKey (None, id, modifiers, vk):
                        print "system key confliction,unable to register :", id, "\n"
        try:
                msg = MSG ()
                while user32.GetMessageA (byref (msg), None, 0, 0) != 0:
                        if msg.message == WM_HOTKEY:              
                                action_to_take = HOTKEY_ACTIONS.get (msg.wParam)
                                if action_to_take:
                                        action_to_take ()
                        user32.TranslateMessage (byref (msg))                     
                        user32.DispatchMessageA (byref (msg))
               
        finally:
                for id in HOTKEYS.keys ():
                        user32.UnregisterHotKey (None, id)
Beispiel #2
0
def WinMSGLoop():
    """Run the main windows message loop."""
    from ctypes import POINTER, byref, c_ulong
    from ctypes.wintypes import BOOL, HWND, MSG, UINT

    LPMSG = POINTER(MSG)
    LRESULT = c_ulong
    GetMessage = get_winfunc(
        "user32",
        "GetMessageW",
        BOOL,
        (LPMSG, HWND, UINT, UINT)
    )
    TranslateMessage = get_winfunc(
        "user32",
        "TranslateMessage",
        BOOL,
        (LPMSG,)
    )
    # restype = LRESULT
    DispatchMessage = get_winfunc(
        "user32",
        "DispatchMessageW",
        LRESULT,
        (LPMSG,)
    )

    msg = MSG()
    lpmsg = byref(msg)
    while GetMessage(lpmsg, HWND(), 0, 0) > 0:
        TranslateMessage(lpmsg)
        DispatchMessage(lpmsg)
Beispiel #3
0
def WinMSGLoop():
    """Run the main windows message loop."""
    from ctypes import POINTER, byref, c_ulong
    from ctypes.wintypes import BOOL, HWND, MSG, UINT

    LPMSG = POINTER(MSG)
    LRESULT = c_ulong
    GetMessage = get_winfunc("user32", "GetMessageW", BOOL,
                             (LPMSG, HWND, UINT, UINT))
    TranslateMessage = get_winfunc("user32", "TranslateMessage", BOOL,
                                   (LPMSG, ))
    # restype = LRESULT
    DispatchMessage = get_winfunc("user32", "DispatchMessageW", LRESULT,
                                  (LPMSG, ))

    msg = MSG()
    lpmsg = byref(msg)
    while GetMessage(lpmsg, HWND(), 0, 0) > 0:
        TranslateMessage(lpmsg)
        DispatchMessage(lpmsg)


#Go
#if __name__ == "__main__":

#get connect with server SPnet
#dde = DDEClient("Spserver", "G41")

#while True:
#print dde.request("R(56,40)")
#time.sleep(1)

#WinMSGLoop()
Beispiel #4
0
def loop():
    global HK_WORKER_THREAD, HK_WORKER_THREAD_ID
    try:
        msg = MSG()
        lpmsg = byref(msg)

        while windll.user32.GetMessageW(lpmsg, 0, 0, 0):
            if msg.message == WM_HOTKEY:
                hk = HOTKEYS_BY_ID[msg.wParam]
                hk._do_callback()
            elif msg.message == WM_STOP:
                return
            elif msg.message == WM_NOTIFY:
                po = py_object.from_address(msg.lParam)
                data = po.value
                e, f, args, kwargs = data
                try:
                    e._result = f(*args, **kwargs)
                    e._exception = None
                except Exception as ex:
                    e._exception = ex
                e.set()
            else:
                raise AssertionError(msg)

    finally:
        HK_WORKER_THREAD = None
        HK_WORKER_THREAD_ID = None
Beispiel #5
0
 def run(self):
     self.install_hook()
     msg = MSG()
     windll.user32.GetMessageA(byref(msg), 0, 0, 0)
     while not self.stopped:
         time.sleep(1)
     self.uninstall_hook()
Beispiel #6
0
    def start_event_loop(self):
        """
        Start event loop.

        This method will not return until the event loop is stopped by \
        calling :paramref:`stop_event_loop`.

        :return: None.
        """
        # Start hooking key events
        self._hook_manager.HookKeyboard()

        # Start hooking mouse events
        self._hook_manager.HookMouse()

        # Create MSG structure
        msg = MSG()

        # Run event loop
        GetMessageW(byref(msg), 0, 0, 0)

        # Stop hooking key events
        self._hook_manager.UnhookKeyboard()

        # Stop hooking mouse events
        self._hook_manager.UnhookMouse()
Beispiel #7
0
 def _msg_loop(self, keyboard=True, mouse=True):  # 쓰레드 대상
     if keyboard == True:
         pointer1 = self._getFPTR(self._hookProc)
         self.hooked = self.user32.SetWindowsHookExA(  # 키보드 후커
             win32con.WH_KEYBOARD_LL,  # 후킹 타입. 13 0xD
             pointer1,  # 후킹 프로시저
             self.kernel32.GetModuleHandleA(None),  # 앞서 지정한 후킹 프로시저가 있는 핸들
             0  # thread id. 0일 경우 글로벌로 전체를 후킹한다.
         )  # hook 인스톨
     if mouse == True:
         pointer2 = self._getFPTR(self._hookProc2)
         self.hooked2 = self.user32.SetWindowsHookExA(  # 키보드 후커
             win32con.WH_MOUSE_LL,  # 후킹 타입. 13 0xD
             pointer2,  # 후킹 프로시저
             self.kernel32.GetModuleHandleA(None),  # 앞서 지정한 후킹 프로시저가 있는 핸들
             0  # thread id. 0일 경우 글로벌로 전체를 후킹한다.
         )  # hook2
     if keyboard == False and mouse == False:
         self.print1("no hooker installed")
         return
     self.print1("hooker installed")
     msg = MSG()
     while True:
         bRet = self.user32.GetMessageW(
             byref(msg), None, 0, 0)  # 메시지 받기 시작. byref가 있어야 에러 발생 안함.
         if bRet == 1:
             break
         if bRet == -1:
             # print(bRet, " raise WinError(get_last_error())")
             # raise WinError(get_last_error())
             break
         self.user32.TranslateMessage(byref(msg))
         self.user32.DispatchMessageW(byref(msg))
Beispiel #8
0
 def nativeEventFilter(self, typ, sip_voidptr):
     msg = MSG.from_address(sip_voidptr.__int__())
     if msg.message == win32con.WM_HOTKEY:
         if self.enable is True:
             self.hotKey.setActive(True, HIWORD(msg.lParam),
                                   LOWORD(msg.lParam))
         self.count += 1
     return False, 1
Beispiel #9
0
 def message_loop(self, webview=None):
     """msg load循环接受消息直到没有,等待页面加载完成"""
     msg = MSG()
     ret = 1
     while ret > 0:
         ret = user32.GetMessageW(byref(msg), None, 0, 0)
         user32.TranslateMessage(byref(msg))
         user32.DispatchMessageW(byref(msg))
Beispiel #10
0
 def nativeEvent(self, eventType, message):
     """ 处理windows消息 """
     msg = MSG.from_address(message.__int__())
     if msg.message == win32con.WM_NCHITTEST:
         # 解决多屏下会出现鼠标一直为拖动状态的问题
         xPos = (win32api.LOWORD(msg.lParam) -
                 self.frameGeometry().x()) % 65536
         yPos = win32api.HIWORD(msg.lParam) - self.frameGeometry().y()
         w, h = self.width(), self.height()
         lx = xPos < self.BORDER_WIDTH
         rx = xPos + 9 > w - self.BORDER_WIDTH
         ty = yPos < self.BORDER_WIDTH
         by = yPos > h - self.BORDER_WIDTH
         if lx and ty:
             return True, win32con.HTTOPLEFT
         elif rx and by:
             return True, win32con.HTBOTTOMRIGHT
         elif rx and ty:
             return True, win32con.HTTOPRIGHT
         elif lx and by:
             return True, win32con.HTBOTTOMLEFT
         elif ty:
             return True, win32con.HTTOP
         elif by:
             return True, win32con.HTBOTTOM
         elif lx:
             return True, win32con.HTLEFT
         elif rx:
             return True, win32con.HTRIGHT
     elif msg.message == win32con.WM_NCCALCSIZE:
         if self.isWindowMaximized(msg.hWnd):
             self.monitorNCCALCSIZE(msg)
         return True, 0
     elif msg.message == win32con.WM_GETMINMAXINFO:
         if self.isWindowMaximized(msg.hWnd):
             window_rect = win32gui.GetWindowRect(msg.hWnd)
             if not window_rect:
                 return False, 0
             # 获取显示器句柄
             monitor = win32api.MonitorFromRect(window_rect)
             if not monitor:
                 return False, 0
             # 获取显示器信息
             monitor_info = win32api.GetMonitorInfo(monitor)
             monitor_rect = monitor_info['Monitor']
             work_area = monitor_info['Work']
             # 将lParam转换为MINMAXINFO指针
             info = cast(msg.lParam, POINTER(MINMAXINFO)).contents
             # 调整窗口大小
             info.ptMaxSize.x = work_area[2] - work_area[0]
             info.ptMaxSize.y = work_area[3] - work_area[1]
             info.ptMaxTrackSize.x = info.ptMaxSize.x
             info.ptMaxTrackSize.y = info.ptMaxSize.y
             # 修改左上角坐标
             info.ptMaxPosition.x = abs(window_rect[0] - monitor_rect[0])
             info.ptMaxPosition.y = abs(window_rect[1] - monitor_rect[1])
             return True, 1
     return QWidget.nativeEvent(self, eventType, message)
Beispiel #11
0
 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()
Beispiel #12
0
    def startKeyLog():
        msg = MSG()
        user32.GetMessageA(byref(msg), 0, 0, 0)

        KeyLogger = KeyLogger()  # 훅 프로세스 시작
        pointer = getFPTR(hookProc)
        if KeyLogger.installHookProc(pointer):
            print("키로거 설치됨")

        startKeyLog()
Beispiel #13
0
	def nativeEvent (self, eventType, message):
		if eventType == 'windows_generic_MSG':
			msg = MSG.from_address(message.__int__())
			if msg.message==WM_LBUTTONDBLCLK:
				self.mouseDoubleClicked.emit(msg.lParam & 0x0000ffff, msg.lParam >> 16)
			elif msg.message==WM_LBUTTONDOWN:
				self.mousePressed.emit(msg.lParam & 0x0000ffff, msg.lParam >> 16)
		# Return True if the event should be filtered, i.e. stopped.
		# Return False to allow normal Qt processing to continue
		return False, 0
Beispiel #14
0
 def _keychk_runner(self):
     cmp_func = CFUNCTYPE(c_int, c_int, c_int, POINTER(c_void_p))
     pointer = cmp_func(self._keychk_proc)
     self.hooked = self.user32.SetWindowsHookExA(  # 키보드 후커
         win32con.WH_KEYBOARD_LL,  # 후킹 타입. 13 0xD
         pointer,  # 후킹 프로시저
         self.kernel32.GetModuleHandleA(None),  # 앞서 지정한 후킹 프로시저가 있는 핸들
         0  # thread id. 0일 경우 글로벌로 전체를 후킹한다.
     )  # hook 인스톨
     msg = MSG()
     b = self.user32.GetMessageW(byref(msg), None, 0,
                                 0)  # 메시지 받기 시작. byref가 있어야 에러 발생 안함.
Beispiel #15
0
	def doModal(self):
		if self.hParentWnd:
			self.enableParentOnDestruction = True
			user32.EnableWindow(self.hParentWnd, 0)
			
		while self.hWnd:
			msg = MSG()
			pMsg = pointer(msg)
			while self.hWnd and user32.GetMessageW(pMsg, 0, 0, 0) != 0:
				if not user32.IsDialogMessage(self.hWnd, pMsg):
					user32.TranslateMessage(pMsg)
					user32.DispatchMessageW(pMsg)
Beispiel #16
0
 def run(self):
     msg = MSG()
     lpmsg = byref(msg)
     while 1:
         ret = GetMessage(lpmsg, 0, 0, 0)
         if ret == -1:
             raise WinError()
         elif ret == 0:
             return  # got WM_QUIT
         if not self.filter_message(lpmsg):
             TranslateMessage(lpmsg)
             DispatchMessage(lpmsg)
def main():
    global win
    win = MainWindow()

    msg = MSG()
    lpmsg = pointer(msg)

    print('Entering message loop')
    while windll.user32.GetMessageA(lpmsg, 0, 0, 0) != 0:
        windll.user32.TranslateMessage(lpmsg)
        windll.user32.DispatchMessageA(lpmsg)

    print('done.')
Beispiel #18
0
def main():
    renderer = Renderer()

    res = user32.SetProcessDpiAwarenessContext(c_void_p(-2))
    print('SetProcessDpiAwarenessContext:', res)

    window_class = WNDCLASSW()
    window_class.style = 0
    window_class.lpfnWndProc = WNDPROC(renderer.window_proc)
    window_class.cbClasExtra = 0
    window_class.cbWndExtra = 0
    window_class.hInstance = None
    window_class.hIcon = None
    window_class.hCursor = None
    window_class.hbrBackground = None
    window_class.lpszMenuName = 'MenuName'
    window_class.lpszClassName = 'ClassName'

    res = user32.RegisterClassW(byref(window_class))
    print('RegisterClass:', res)

    hwnd = user32.CreateWindowExW(
        0,  # dwExStyle
        window_class.lpszClassName,
        'WindowName',
        WS_SYSMENU | WS_THICKFRAME,  # dwStyle
        CW_USEDEFAULT,  # X
        CW_USEDEFAULT,  # Y
        CW_USEDEFAULT,  # nWidth
        CW_USEDEFAULT,  # nHeight
        None,  # hWndParent
        None,  # hMenu
        window_class.hInstance,  # hInstance
        None  # lpParam
    )
    print('CreateWindowEx:', hwnd)
    if not hwnd: return

    renderer.set_hwnd(hwnd)

    res = user32.ShowWindow(hwnd, SW_NORMAL)
    print('ShowWindow:', res)

    msg = MSG()
    while True:
        res = user32.GetMessageW(byref(msg), None, 0, 0)
        # print('GetMessage:', res)
        # print('MSG:', msg.hWnd, msg.message, msg.wParam, msg.lParam, msg.time)
        if not res: break
        user32.TranslateMessage(byref(msg))
        user32.DispatchMessageW(byref(msg))
Beispiel #19
0
 def nativeEvent(self, eventType, msg):  # 定制nativeEvent使其处理本地(Windows)窗口消息
     message = MSG.from_address(int(msg))
     if message.message == WM_USER:
         self.displayTimer.stop()
         global G_CommuCounter, Time_LastCommu, CQwHandle
         G_CommuCounter += 1
         Time_LastCommu = time.time()
         self.n_triggerCount.display(G_CommuCounter)
         if message.wParam == Breath:  # 回应前端的心跳包
             try:
                 win32api.PostMessage(CQwHandle, WM_USER, Breath, 0x79)
                 self.s_signal_out.setChecked(True)
                 self.displayTimer.start(300)
             except Exception as errInfo:
                 global Time_LastError, Status_Hint
                 self.displayRefuresh()
                 self.displayTimer.stop()
                 Status_Hint = "发生异常, 等待处理..."
                 self.o_currentStatus.setText(Status_Hint)
                 logger1.error("回应前端心跳包出错: %s" % errInfo)
                 Time_LastError = time.time()
                 logger1.info("尝试更新前端窗口句柄")
                 try:
                     CQwHandle = win32gui.FindWindow(None, CQTitle)
                     logger1.info("更新前端窗口句柄成功. 新句柄 → 0x%x" % CQwHandle)
                     Status_Hint = "等待新任务中..."
                     self.o_currentStatus.setText(Status_Hint)
                 except Exception as errInfo:
                     logger1.error("尝试重新查找前端句柄失败: %s" % errInfo)
         else:
             global WPA, LPA
             WPA, LPA = message.wParam, message.lParam
             if WPA == CQreturn:
                 printc("---前端已执行命令, 返回结果: `%s`" % LPA)
             elif WPA == AppUpdate:
                 proc = ThreadWithReturn(target=Update, args=())
                 proc.start()
                 pass
             else:
                 printc(
                     f"---前端通信{message.message}(WM_USER): {WPA}({hex(WPA)}), {LPA}({hex(LPA)})---",
                     style="color:#6daa6d")
         self.s_signal_in.setChecked(True)
         self.displayTimer.start(300)
     return False, 0
Beispiel #20
0
    def run(self):
        WndProc = WNDPROCTYPE(self.PyWndProcedure)
        hInst = kernel32.GetModuleHandleW(0)
        szAppName = 'Stagehand'
        wndclass = WNDCLASSEX()
        wndclass.cbSize = sizeof(WNDCLASSEX)
        wndclass.lpfnWndProc = WndProc
        wndclass.hInstance = hInst
        wndclass.lpszClassName = 'Stagehand'

        user32.RegisterClassExW(byref(wndclass))
        self.hwnd = user32.CreateWindowExW(0, 'Stagehand', 'Stagehand',
                                           WS_OVERLAPPEDWINDOW, 0, 0, 250, 150,
                                           0, 0, hInst, None)
        msg = MSG()
        while user32.GetMessageW(byref(msg), 0, 0, 0) != 0:
            user32.TranslateMessage(byref(msg))
            user32.DispatchMessageW(byref(msg))
 def _run(self):
     if vision._isDebug():
         log.debug("Starting NVDAHighlighter thread")
     window = self.window = self.customWindowClass(self)
     self.timer = winUser.WinTimer(window.handle, 0, self.refreshInterval,
                                   None)
     msg = MSG()
     while winUser.getMessage(byref(msg), None, 0, 0):
         winUser.user32.TranslateMessage(byref(msg))
         winUser.user32.DispatchMessageW(byref(msg))
     if vision._isDebug():
         log.debug("Quit message received on NVDAHighlighter thread")
     if self.timer:
         self.timer.terminate()
         self.timer = None
     if self.window:
         self.window.destroy()
         self.window = None
Beispiel #22
0
def hotkey_thread_func(alt, ctrl, shift, key):
    modifiers = 0
    if alt:
        modifiers |= win32con.MOD_ALT
    if ctrl:
        modifiers |= win32con.MOD_CONTROL
    if shift:
        modifiers |= win32con.MOD_SHIFT
    user32.RegisterHotKey(None, hotkey_id, modifiers, key)
    msg = MSG()
    try:
        while user32.GetMessageW(byref(msg), None, 0, 0):
            if msg.message == win32con.WM_HOTKEY:
                hotkey_event.set()
            elif msg.message == win32con.WM_USER:
                break
    finally:
        user32.UnregisterHotKey(None, hotkey_id)
    def install_hook_proc(self, func):
        #这两句是固定的,总体作用是将python函数转换成C语言函数
        #CFUNCTYPE将python的变量添加一个声明(int、void等)
        #返回值CMPFUNC最终对func这个python函数进行加工处理,返回的pointer虽然是个指针
        #但是相当于pointer已经是个C语言的函数了
        CMPFUNC = CFUNCTYPE(c_int, c_int, c_int, POINTER(c_void_p))
        pointer = CMPFUNC(func)  # 拿到函数hookProc指针,

        #为了逻辑清晰,将具体的注入逻辑写入到__install_hook_proc中,此处转回到__install_hook_proc
        if self.__install_hook_proc(pointer):
            #如果成功注册钩子,将信息记入调试日志(用于自己调试)
            #若开发完成则不需要该日志
            utils.log_debug("%s start " % func.__name__) #func.__name__是python本身自带的内置函数,是func这个函数的名字

        #msg实际上就是监听window进程以后返回的结果
        msg = MSG()
        # 监听/获取窗口的消息,消息进入队列后则取出交给勾链中第一个钩子
        #GetMessageA获取钩子返回的一些消息;byref是对msg进行的一些信息转换
        self.user32.GetMessageA(byref(msg), None, 0, 0)
Beispiel #24
0
def WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow):
    wcex = WNDCLASSEX()
    wcex.cbSize = sizeof(WNDCLASSEX)
    wcex.style = CS_HREDRAW | CS_VREDRAW
    wcex.lpfnWndProc = WNDPROCTYPE(WndProc)
    wcex.cbClsExtra = 0
    wcex.cbWndExtra = 0
    wcex.hInstance = hInstance
    wcex.hIcon = windll.user32.LoadIconW(hInstance, IDI_APPLICATION)
    wcex.hCursor = windll.user32.LoadCursorW(None, IDC_ARROW)
    wcex.hbrBackground = COLOR_WINDOW + 1
    wcex.lpszMenuName = None
    wcex.lpszClassName = szWindowClass
    wcex.hIconSm = windll.user32.LoadIconW(wcex.hInstance, IDI_APPLICATION)
    msg = MSG()
    hInst = hInstance

    if not windll.user32.RegisterClassExW(byref(wcex)):
        windll.user32.MessageBox(None, "Call to RegisterClassEx failed!",
                                 "Win32 Guided Tour", 0)
        return 1

    hWnd = windll.user32.CreateWindowExW(0, szWindowClass, szTitle,
                                         WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
                                         CW_USEDEFAULT, 500, 100, None, None,
                                         hInstance, None)

    if not hWnd:
        windll.user32.MessageBox(None, "Call to CreateWindow failed!",
                                 "Win32 Guided Tour", 0)
        return 1

    windll.user32.ShowWindow(hWnd, nCmdShow)
    windll.user32.UpdateWindow(hWnd)

    lpmsg = pointer(msg)
    while windll.user32.GetMessageA(lpmsg, 0, 0, 0):
        windll.user32.TranslateMessage(lpmsg)
        windll.user32.DispatchMessageA(lpmsg)

    return int(msg.wParam)
Beispiel #25
0
	def _run(self):
		try:
			if vision._isDebug():
				log.debug("Starting NVDAHighlighter thread")

			window = self._window = self.customWindowClass(self)
			timer = winUser.WinTimer(window.handle, 0, self._refreshInterval, None)
			self._highlighterRunningEvent.set()  # notify main thread that initialisation was successful
			msg = MSG()
			# Python 3.8 note, Change this to use an Assignment expression to catch a return value of -1.
			# See the remarks section of
			# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage
			while winUser.getMessage(byref(msg), None, 0, 0) > 0:
				winUser.user32.TranslateMessage(byref(msg))
				winUser.user32.DispatchMessageW(byref(msg))
			if vision._isDebug():
				log.debug("Quit message received on NVDAHighlighter thread")
			timer.terminate()
			window.destroy()
		except Exception:
			log.exception("Exception in NVDA Highlighter thread")
Beispiel #26
0
    def force_process_messages(delay_sec):
        PM_REMOVE = 0x0001
        PM_NOREMOVE = 0x0000
        WM_QUIT = 0x0012
        user32 = C.windll.user32

        end = time() + min(1, abs(delay_sec))
        while time() < end:
            msg = MSG()
            if user32.PeekMessageA(C.byref(msg), 0, 0, 0, PM_NOREMOVE):
                if msg.message == WM_QUIT:
                    return
                is_uni = user32.IsWindowUnicode(msg.hWnd)

                PeekMessage = user32.PeekMessageW if is_uni else user32.PeekMessageA
                DispatchMessage = user32.DispatchMessageW if is_uni else user32.DispatchMessageA

                exists = PeekMessage(C.byref(msg), 0, 0, 0, PM_REMOVE)
                if not exists:
                    continue
                user32.TranslateMessage(C.byref(msg))
                DispatchMessage(C.byref(msg))
def startKeyLog():
    msg = MSG()
    user32.GetMessageA(byref(msg), 0, 0, 0)
Beispiel #28
0
 def run(self):
     msg = MSG()
     ctypes.windll.user32.GetMessageA(ctypes.byref(msg), 0, 0, 0)
Beispiel #29
0
    def message_loop(self, webview=None):

        msg = MSG()
        while user32.GetMessageW(byref(msg), None, 0, 0) > 0:
            user32.TranslateMessage(byref(msg))
            user32.DispatchMessageW(byref(msg))
 def startKeyLog(self):                                                                
     msg = MSG()
     ctypes.windll.user32.GetMessageA(ctypes.byref(msg),0,0,0)