Forum: Poser Python Scripting


Subject: assign a keyboard shortcut to a script

sergio777 opened this issue on Apr 12, 2021 ยท 4 posts


adp001 posted Fri, 23 April 2021 at 8:48 AM

I'm a bit late with this, but maybe someone wants to play with it:

def my_script():
    print("My script started because F1 was pressed.")


def new_handler(event):
    keycode = event.GetKeyCode()
    if keycode == wx.WXK_F1:
        my_script()
    event.Skip()


root = poser.WxApp()
root.Bind(wx.EVT_KEY_DOWN, new_handler)

Run the script and press "F1".

Note: You have to unbind the function before you activate it a second time! If you do not, the first installed eventhandler stays active until you close Poser.