# Path: pywinauto/windows/win32defines.py
# VK_PACKET     = 231
# 
# Path: pywinauto/windows/win32structures.py
# class KBDLLHOOKSTRUCT(Structure):
# 
#     """Wrap KBDLLHOOKSTRUCT structure"""
# 
#     _fields_ = [
#         ('vkCode', DWORD),
#         ('scanCode', DWORD),
#         ('flags', DWORD),
#         ('time', DWORD),
#         ('dwExtraInfo', DWORD),
#     ]
# 
# Path: pywinauto/windows/win32structures.py
# class MSLLHOOKSTRUCT(Structure):
# 
#     """Wrap MSLLHOOKSTRUCT structure"""
# 
#     _fields_ = [
#         ('pt', POINT),
#         ('mouseData', DWORD),
#         ('flags', DWORD),
#         ('time', DWORD),
#         ('dwExtraInfo', DWORD),
#     ]
# 
# Path: pywinauto/windows/win32structures.py
# LRESULT = wintypes.LPARAM


import six
import atexit
import sys
import time
import win32con
import win32api
from ctypes import wintypes
from ctypes import windll
from ctypes import CFUNCTYPE
from ctypes import c_int
from ctypes import byref
from ctypes import pointer
from .win32defines import VK_PACKET
from ..actionlogger import ActionLogger
from . import win32functions
from .win32structures import KBDLLHOOKSTRUCT
from .win32structures import MSLLHOOKSTRUCT
from .win32structures import LRESULT
 * WH_KEYBOARD_LL

More detailed documentation about Windows hooks can be found in MSDN:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms632589.aspx

This module can be used as a stand alone or along with pywinauto.
The fork of this code (at some moment) was used in
standalone library pyhooked 0.8 maintained by Ethan Smith.
"""





HOOKCB = CFUNCTYPE(LRESULT, c_int, wintypes.WPARAM, wintypes.LPARAM)

windll.kernel32.GetModuleHandleA.restype = wintypes.HMODULE
windll.kernel32.GetModuleHandleA.argtypes = [wintypes.LPCSTR]
windll.user32.SetWindowsHookExA.restype = wintypes.HHOOK
windll.user32.SetWindowsHookExA.argtypes = [c_int, HOOKCB, wintypes.HINSTANCE, wintypes.DWORD]
windll.user32.SetWindowsHookExW.restype = wintypes.HHOOK
windll.user32.SetWindowsHookExW.argtypes = [c_int, HOOKCB, wintypes.HINSTANCE, wintypes.DWORD]

# LRESULT WINAPI CallNextHookEx(
#   _In_opt_ HHOOK  hhk,
#   _In_     int    nCode,
#   _In_     WPARAM wParam,
#   _In_     LPARAM lParam
# );
windll.user32.CallNextHookEx.argtypes = [wintypes.HHOOK, c_int, wintypes.WPARAM, wintypes.LPARAM]

# Path: pywinauto/windows/win32defines.py
# VK_PACKET     = 231
# 
# Path: pywinauto/windows/win32structures.py
# class KBDLLHOOKSTRUCT(Structure):
# 
#     """Wrap KBDLLHOOKSTRUCT structure"""
# 
#     _fields_ = [
#         ('vkCode', DWORD),
#         ('scanCode', DWORD),
#         ('flags', DWORD),
#         ('time', DWORD),
#         ('dwExtraInfo', DWORD),
#     ]
# 
# Path: pywinauto/windows/win32structures.py
# class MSLLHOOKSTRUCT(Structure):
# 
#     """Wrap MSLLHOOKSTRUCT structure"""
# 
#     _fields_ = [
#         ('pt', POINT),
#         ('mouseData', DWORD),
#         ('flags', DWORD),
#         ('time', DWORD),
#         ('dwExtraInfo', DWORD),
#     ]
# 
# Path: pywinauto/windows/win32structures.py
# LRESULT = wintypes.LPARAM


# Path: pywinauto/windows/win32_hooks.py
import six
import atexit
import sys
import time
import win32con
import win32api
from ctypes import wintypes
from ctypes import windll
from ctypes import CFUNCTYPE
from ctypes import c_int
from ctypes import byref
from ctypes import pointer
from .win32defines import VK_PACKET
from ..actionlogger import ActionLogger
from . import win32functions
from .win32structures import KBDLLHOOKSTRUCT
from .win32structures import MSLLHOOKSTRUCT
from .win32structures import LRESULT

 * WH_KEYBOARD_LL

More detailed documentation about Windows hooks can be found in MSDN:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms632589.aspx

This module can be used as a stand alone or along with pywinauto.
The fork of this code (at some moment) was used in
standalone library pyhooked 0.8 maintained by Ethan Smith.
"""





HOOKCB = CFUNCTYPE(LRESULT, c_int, wintypes.WPARAM, wintypes.LPARAM)

windll.kernel32.GetModuleHandleA.restype = wintypes.HMODULE
windll.kernel32.GetModuleHandleA.argtypes = [wintypes.LPCSTR]
windll.user32.SetWindowsHookExA.restype = wintypes.HHOOK
windll.user32.SetWindowsHookExA.argtypes = [c_int, HOOKCB, wintypes.HINSTANCE, wintypes.DWORD]
windll.user32.SetWindowsHookExW.restype = wintypes.HHOOK
windll.user32.SetWindowsHookExW.argtypes = [c_int, HOOKCB, wintypes.HINSTANCE, wintypes.DWORD]

# LRESULT WINAPI CallNextHookEx(
#   _In_opt_ HHOOK  hhk,
#   _In_     int    nCode,
#   _In_     WPARAM wParam,
#   _In_     LPARAM lParam
# );
windll.user32.CallNextHookEx.argtypes = [wintypes.HHOOK, c_int, wintypes.WPARAM, wintypes.LPARAM]

windll.user32.CallNextHookEx.restypes = LRESULT