有人帮我理解这个 ctypes python 代码吗?
Somebody help me understand this ctypes python code?
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
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