python - 有人帮我理解这个 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
如果有人可以帮助我理解这些线条,那么我可以更好地理解这个过程。
解决方案
这些是 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
推荐阅读
- c++ - 不可复制类型的 std::initializer_list 替代方案
- javascript - 完成承诺后渲染 [ React Native ]
- python - Python Flask XSS 中和(Veracode 警报)
- java - 参数化 Spring Value 注释字符串
- webview - 信使 webview 的 URL 是否需要是 HTTPS?
- react-native - 如何通过嵌套映射函数获取 no_images/images
- ios - RxSwift,MVVM:与子视图控制器的通信
- android - 如何使用 FloatingActionButton 创建 BottomNavigationView
- javascript - 如何从控制台获取 Linkedin 会话 cookie
- javascript - 为什么 window.open 在桌面 PWA 中显示空白屏幕(看起来很模糊)?