首页 > 解决方案 > 有人帮我理解这个 ctypes python 代码吗?

问题描述

hotkey_ = enable_shortcut       # Check to break the while loop

def proper_fctn():
    if hotkey_:
        if not user32.RegisterHotKey(None, shortcut_id, modifier, vk):
            pass
        try:
            msg = wintypes.MSG()
            while user32.GetMessageA(byref(msg), None, 0, 0) != 0:
                if msg.message == win32con.WM_HOTKEY:
                    if not hotkey_:
                        break
                    fctn_to_run()
                user32.TranslateMessage(byref(msg))
                user32.DispatchMessageA(byref(msg))
        except:
            pass

如果有人可以帮助我理解这些线条,那么我可以更好地理解这个过程。

标签: pythonpython-3.xctypes

解决方案


这些是 Win32 API。所有这些都在 Microsoft 的 MSDN 文档中有详细记录。您基本上已经编写了一个带有标准主循环的 Windows 应用程序。

Google 会将您直接带到他们的文档。

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf -winuser-getmessage


推荐阅读