How to generate keyboard keypress events through Python to control PP presentation?

14,051

You can try PyQt or wxPython

Here is a link for how to handle key press with PyQt - http://www.saltycrane.com/blog/2008/01/how-to-capture-tab-key-press-event-with/

and for wxPython - http://www.wxpython.org/docs/api/wx.KeyEvent-class.html and http://zetcode.com/wxpython/events/

Share:
14,051
AJJ
Author by

AJJ

Updated on June 04, 2022

Comments

  • AJJ
    AJJ about 2 years

    I need to programmatically control powerpoint/pdf presentations (the 4 direction keystrokes need to work at the minimum to go to the previous and next slides).

    What library/module/framework can I use with Python to do this on OS X?

    I've seen a lot of discussion on doing this in Windows and C# (or OS X and Quartz), but nothing particularly with Python. A cross-platform library / framework would be even better.

    Overall, I would like to programmatically control my presentation with Python on OS X (as part of a hobby project, and probably also useful in my own short presentations).

  • AJJ
    AJJ almost 13 years
    Thanks, but aren't these modules for collecting keypress events? Please let me know if I am wrong. I want to generate events, so as to move the presentation to the next slide, through code.
  • AJJ
    AJJ almost 13 years
    Just to clarify, e.g., I want to move to the next slide after a timer of 1 minute runs down. So I want to write a command that generates the 'forward key' event on the presentation window after 1 minute.
  • arunkumar
    arunkumar almost 13 years
    Sorry I assumed you were creating the presentation program in Python. One suggestion and I know this is not in Python, but have you looked at AppleScript ? As for a cross platform Python library to send keyboard events to the operating system , the only thing I came across is this using wxPython - wxpython-users.1045709.n5.nabble.com/…
  • AJJ
    AJJ almost 13 years
    Thanks! Applescript looks promising. Seems like there isn't a good way to achieve this with Python itself.
  • arunkumar
    arunkumar almost 13 years
    I doubt if there is a cross platform library for doing things like this. wxPython, Qt and similar GUI libraries probably have features like this but aren't built really for this purpose. You could use OS dependent libraries such as pyobjc.sourceforge.net for OS X and python.net/crew/skippy/win32 for Win32, but this would fall under slightly advanced programming.
  • Ned Deily
    Ned Deily almost 13 years
    py-appscript lets you do Applescripting in Python: appscript.sourceforge.net/py-appscript/index.html
  • AJJ
    AJJ almost 13 years
    Thanks, that bridge should be very useful!
  • Sal
    Sal about 4 years
    Would this be able to work with an inactive/minimized window?