Я пытался привести функцию к c_void_p, но при этом получал больше ошибок, таких как «Недопустимая инструкция».
Это мой код:
Код: Выделить всё
import ctypes, random
def msgBoxHook(nCode, wParam, lParam):
if nCode == 3:
hwnd = ctypes.wintypes.HWND
hwnd = wParam
msgRekt = ctypes.wintypes.RECT # >:)
ctypes.windll.user32.GetWindowRect(hwnd, ctypes.byref(msgRekt))
ctypes.windll.user32.MoveWindow(hwnd, randint(0, ctypes.windll.user32.GetSystemMetrics(0)), randint(0, ctypes.windll.user32.GetSystemMetrics(1)), msgRekt.right - msgRekt.left, msgRekt.bottom - msgRekt.top, True)
return ctypes.windll.user32.CallNextHookEx(0, nCode, wParam, lParam)
# When I try to call
ctypes.windll.user32.SetWindowsHookExA(5, msgBoxHook, 0, ctypes.windll.kernel32.GetCurrentThreadId())
# It shows:
"""
Traceback (most recent call last):
File "test.py", line 1, in
ctypes.ArgumentError: argument 2: : wrong type
"""
Реальность: как показано выше.
Подробнее здесь: https://stackoverflow.com/questions/566 ... l-user32-s