def exitAutoHotKey(autohotpy,event):
"""
exit the program when you press ESC
"""
autohotpy.stop()
def leftButton(autohotpy,event):
"""
This function simulates a left click
"""
stroke = InterceptionMouseStroke()
stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN
autohotpy.sendToDefaultMouse(stroke)
stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_UP
autohotpy.sendToDefaultMouse(stroke)
def rightButton(autohotpy,event):
"""
This function simulates a right click
"""
stroke = InterceptionMouseStroke() # I highly suggest you to open InterceptionWrapper to read which attributes this class has
#To simulate a mouse click we manually have to press down, and release the buttons we want.
stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN
autohotpy.sendToDefaultMouse(stroke)
stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_UP
autohotpy.sendToDefaultMouse(stroke)
if __name__=="__main__":
auto = AutoHotPy()
auto.registerExit(auto.ESC,exitAutoHotKey) # Registering an end key is mandatory to be able tos top the program gracefully
# lets switch right and left mouse buttons!
auto.registerForMouseButton(InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,rightButton)
auto.registerForMouseButton(InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,leftButton)
auto.start()