hello,
i’m trying to write a simple script that, when activated, fires a keyboard shortcut. i leafed through the krita scripting school pages and associated action dictionary, but haven’t seen anything that helps.
Hi, I’m not sure if this is possible. However, it is a bit counter productive. You typically invoke an action associated with the key instead of simulating a key press. Every key shortcut has a corresponding action.
It would allow for manipulation of outside apps from krita. Say you want to add a button to krita’s upcoming “Workflow Buttons” docker that activates pureRef and makes that window stay on top while you draw. A script that fires a keyboard shortcut would allow for that very easily. Another example would be a button on that same docker that toggles the precision mode in your wacom tablet.
This sounds like a simple job for global shortcuts which the operating system should handle or something like AutoHotkey. Normally there is a good reason an application should not send key events to another one and that is security, some operating systems won’t even allow this to happen, and some applications won’t accept virtual key presses.
Yep, I’m not sure if this is doable, if anything it will be error prone and sound like a security risk. I’m with Takiro on this one, it’s better if each of these other apps supported a global shortcut.
I had a similar “problem” recently, actually. I play videos in VLC as I draw, and constant focus switching to play/pause is a bit annoying. Sometimes I press a key that was meant for Krita and it rewinds my video, which is so disruptive ![]()
@YRH yeah, can be pretty annoying constantly switching apps, but i hadn’t considered the potential security risk. ah well. thanks for the replies YRH and Takiro.
You can do it with QT keyPress and keyRelease events, here a functional example of how to do it, the startkey/winkey is not used in there but it should be doable.
But I think you don’t need a key simulator for this, what I would do is start the executable with subprocess python module. The tricky part is the always on top depending on the window manager you use.
good luck
@josepabloespinoza oh that’s very neat. thanks, ill have a look through the stroke listener plugin and see if i cant figure some things out.