示例#1
0
    def _stop(self):
        """Stop mmkey monitoring. Can be called multiple times.

        Might raise WindowsError.
        """

        if self._hhook is not None:
            if winapi.UnhookWindowsHookEx(self._hhook) == 0:
                raise winapi.WinError()
            self._hhook = None
            self._kb_proc_ptr = None
示例#2
0
    def _start(self):
        """Start mmkey monitoring.

        Might raise WindowsError.
        """

        kb_proc_ptr = winapi.LowLevelKeyboardProc(self._kb_proc)
        hhook = winapi.SetWindowsHookExW(winapi.WH_KEYBOARD_LL, kb_proc_ptr,
                                         None, 0)
        if not hhook:
            raise winapi.WinError()
        self._kb_proc_ptr = kb_proc_ptr
        self._hhook = hhook