import ctypes
import os
import win32gui, win32con
from ctypes import wintypes
from multiprocessing import Process
__all__ = ['register', 'unregister', 'process']
byref = ctypes.byref
user32 = ctypes.windll.user32
HOTKEY = []
HOTKEY_ACTIONS = []
def register(mod, vk, callback):
HOTKEY_ACTIONS.append(callback)
id = len(HOTKEY_ACTIONS) - 1
HOTKEY.append((mod, vk, id))
return id
def unregister(id):
user32.UnregisterHotKey(None, id)
class process(Process):
def __init__(self):
Process.__init__(self)
def run(self):
global HOTKEY
global HOTKEY_ACTIONS
for (mod, vk, id) in HOTKEY:
user32.RegisterHotKey (None, id, mod, vk)
msg = ctypes.wintypes.MSG()
while user32.GetMessageA(byref(msg), None, 0, 0) != 0:
if msg.message == win32con.WM_HOTKEY:
action = HOTKEY_ACTIONS[msg.wParam]
if action:
action()
user32.TranslateMessage(byref(msg))
user32.DispatchMessageA(byref(msg))
1. 파이썬 멀티 프로세싱하다가 좀비 프로세스 생기는거 처리방법
2. 코드가 이상한거 같은데 스타일 가이드 지적좀
댓글 0