Simulate keypress

I would like to lauch an AHK script from an Anki function. I guess this would be done by simulating a keypress. Is that possible?

You can simulate a key press with something like this:

def keyPress(key: Qt.Key, modifier: Qt.KeyboardModifier = Qt.KeyboardModifier.NoModifier) -> None:
    QCoreApplication.sendEvent(mw.app.focusObject(), QKeyEvent(QKeyEvent.Type.KeyPress, key, modifier))
    QCoreApplication.sendEvent(mw.app.focusObject(), QKeyEvent(QKeyEvent.Type.KeyRelease, key, modifier))

A command line trigger might be easier (not cross platform, but neither is AHK)

1 Like

Great, thanks