Package pyhook :: Module HookManager :: Class HookManager
[hide private]
[frames] | no frames]

Class HookManager

source code

object --+
         |
        HookManager

Registers and manages callbacks for low level mouse and keyboard events.

Instance Methods [hide private]
 
__init__(self)
Initializes an instance by setting up an empty set of handlers.
source code
 
__del__(self)
Unhook all registered hooks.
source code
 
HookMouse(self)
Begins watching for mouse events.
source code
 
HookKeyboard(self)
Begins watching for keyboard events.
source code
 
UnhookMouse(self)
Stops watching for mouse events.
source code
 
UnhookKeyboard(self)
Stops watching for keyboard events.
source code
 
MouseSwitch(self, msg, x, y, data, flags, time, hwnd, window_name)
Passes a mouse event on to the appropriate handler if one is registered.
source code
 
KeyboardSwitch(self, msg, vk_code, scan_code, ascii, flags, time, hwnd, win_name)
Passes a keyboard event on to the appropriate handler if one is registered.
source code
 
SubscribeMouseMove(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseLeftUp(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseLeftDown(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseLeftDbl(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseRightUp(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseRightDown(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseRightDbl(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseMiddleUp(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseMiddleDown(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseMiddleDbl(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseWheel(self, func)
Registers the given function as the callback for this mouse event type.
source code
 
SubscribeMouseAll(self, func)
Registers the given function as the callback for all mouse events.
source code
 
SubscribeMouseAllButtons(self, func)
Registers the given function as the callback for all mouse button events.
source code
 
SubscribeMouseAllButtonsDown(self, func)
Registers the given function as the callback for all mouse button down events.
source code
 
SubscribeMouseAllButtonsUp(self, func)
Registers the given function as the callback for all mouse button up events.
source code
 
SubscribeMouseAllButtonsDbl(self, func)
Registers the given function as the callback for all mouse button double click events.
source code
 
SubscribeKeyDown(self, func)
Registers the given function as the callback for this keyboard event type.
source code
 
SubscribeKeyUp(self, func)
Registers the given function as the callback for this keyboard event type.
source code
 
SubscribeKeyChar(self, func)
Registers the given function as the callback for this keyboard event type.
source code
 
SubscribeKeyAll(self, func)
Registers the given function as the callback for all keyboard events.
source code
 
connect(self, switch, id, func)
Registers a callback to the given function for the event with the given ID in the provided dictionary.
source code
 
disconnect(self, switch, id)
Unregisters a callback for the event with the given ID in the provided dictionary.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  MouseAll = property(fset= SubscribeMouseAll)
  MouseAllButtons = property(fset= SubscribeMouseAllButtons)
  MouseAllButtonsUp = property(fset= SubscribeMouseAllButtonsUp)
  MouseAllButtonsDown = property(fset= SubscribeMouseAllButtonsD...
  MouseAllButtonsDbl = property(fset= SubscribeMouseAllButtonsDbl)
  MouseWheel = property(fset= SubscribeMouseWheel)
  MouseMove = property(fset= SubscribeMouseMove)
  MouseLeftUp = property(fset= SubscribeMouseLeftUp)
  MouseLeftDown = property(fset= SubscribeMouseLeftDown)
  MouseLeftDbl = property(fset= SubscribeMouseLeftDbl)
  MouseRightUp = property(fset= SubscribeMouseRightUp)
  MouseRightDown = property(fset= SubscribeMouseRightDown)
  MouseRightDbl = property(fset= SubscribeMouseRightDbl)
  MouseMiddleUp = property(fset= SubscribeMouseMiddleUp)
  MouseMiddleDown = property(fset= SubscribeMouseMiddleDown)
  MouseMiddleDbl = property(fset= SubscribeMouseMiddleDbl)
  KeyUp = property(fset= SubscribeKeyUp)
  KeyDown = property(fset= SubscribeKeyDown)
  KeyChar = property(fset= SubscribeKeyChar)
  KeyAll = property(fset= SubscribeKeyAll)
Instance Variables [hide private]
boolean key_hook
Is a keyboard hook set?
dictionary keyboard_funcs
Callbacks for keyboard events
dictionary mouse_funcs
Callbacks for mouse events
boolean mouse_hook
Is a mouse hook set?
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Initializes an instance by setting up an empty set of handlers.

Overrides: object.__init__

MouseSwitch(self, msg, x, y, data, flags, time, hwnd, window_name)

source code 

Passes a mouse event on to the appropriate handler if one is registered.

Parameters:
  • msg (integer) - Message value
  • x (integer) - x-coordinate of the mouse event
  • y (integer) - y-coordinate of the mouse event
  • data (integer) - Data associated with the mouse event (scroll information)
  • flags (integer) - Flags associated with the mouse event (injected or not)
  • time (integer) - Seconds since the epoch when the even current
  • hwnd (integer) - Window handle of the foreground window at the time of the event

KeyboardSwitch(self, msg, vk_code, scan_code, ascii, flags, time, hwnd, win_name)

source code 

Passes a keyboard event on to the appropriate handler if one is registered.

Parameters:
  • msg (integer) - Message value
  • vk_code (integer) - The virtual keycode of the key
  • scan_code (integer) - The scan code of the key
  • ascii (integer) - ASCII numeric value for the key if available
  • flags (integer) - Flags associated with the key event (injected or not, extended key, etc.)
  • time (integer) - Time since the epoch of the key event
  • hwnd (integer) - Window handle of the foreground window at the time of the event

SubscribeMouseMove(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseMove property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseLeftUp(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseLeftUp property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseLeftDown(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseLeftDown property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseLeftDbl(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseLeftDbl property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseRightUp(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseRightUp property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseRightDown(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseRightDown property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseRightDbl(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseRightDbl property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseMiddleUp(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseMiddleUp property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseMiddleDown(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseMiddleDown property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseMiddleDbl(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseMiddleDbl property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseWheel(self, func)

source code 

Registers the given function as the callback for this mouse event type. Use the MouseWheel property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseAll(self, func)

source code 

Registers the given function as the callback for all mouse events. Use the MouseAll property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseAllButtons(self, func)

source code 

Registers the given function as the callback for all mouse button events. Use the MouseButtonAll property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseAllButtonsDown(self, func)

source code 

Registers the given function as the callback for all mouse button down events. Use the MouseAllButtonsDown property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseAllButtonsUp(self, func)

source code 

Registers the given function as the callback for all mouse button up events. Use the MouseAllButtonsUp property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeMouseAllButtonsDbl(self, func)

source code 

Registers the given function as the callback for all mouse button double click events. Use the MouseAllButtonsDbl property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeKeyDown(self, func)

source code 

Registers the given function as the callback for this keyboard event type. Use the KeyDown property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeKeyUp(self, func)

source code 

Registers the given function as the callback for this keyboard event type. Use the KeyUp property as a shortcut.

Parameters:
  • func (callable) - Callback function

SubscribeKeyChar(self, func)

source code 

Registers the given function as the callback for this keyboard event type. Use the KeyChar property as a shortcut.

Note: this is currently non-functional, no WM_*CHAR messages are processed by the keyboard hook.

Parameters:
  • func (callable) - Callback function

SubscribeKeyAll(self, func)

source code 

Registers the given function as the callback for all keyboard events. Use the KeyAll property as a shortcut.

Parameters:
  • func (callable) - Callback function

connect(self, switch, id, func)

source code 

Registers a callback to the given function for the event with the given ID in the provided dictionary. Internal use only.

Parameters:
  • switch (dictionary) - Collection of callbacks
  • id (integer) - Event type
  • func (callable) - Callback function

disconnect(self, switch, id)

source code 

Unregisters a callback for the event with the given ID in the provided dictionary. Internal use only.

Parameters:
  • switch (dictionary) - Collection of callbacks
  • id (integer) - Event type

Class Variable Details [hide private]

MouseAllButtonsDown

Value:
property(fset= SubscribeMouseAllButtonsDown)