[sikuli]-事件监听器

Listening to Global Hotkeys

Sikuli can listen to global hotkeys that you register with Env.addHotkey and call the corresponding handler (sikuli functions) when the user presses the hotkeys.

New in version X1.0-rc3.

Env. addHotkey ( keymodifiershandler )

Register the specified key + modifiers as a global hotkey. When the hotkey is pressed, the specified function handler will be called.

Parameters: Returns:
  • key – a character or a constant value defined in Key.
  • modifiers – Key modifiers, which can be one or multiple constants defined in KeyModifier.

True if success.

1def openAppleMenu(event):
2   click()
3
4# When the user pressed Ctrl+Alt+F1, click the top-left apple icon.
Env.addHotkey(Key.F1, KeyModifier.ALT+KeyModifier.CTRL, openAppleMenu)

New in version X1.0-rc3.

Env. removeHotkey ( keymodifiers )

Unregister the registered global hotkey key + modifiers.

Parameters: Returns:
  • key – a character or a constant value defined in Key.
  • modifiers – Key modifiers, which can be one or multiple constants defined in KeyModifier.

True if success.

 

你可能感兴趣的:(sikuli)