Skip to main content
Inspiring
January 10, 2019
Answered

Keyboard shortcut for AEGP plugin

  • January 10, 2019
  • 1 reply
  • 2315 views

Hi,

I have this plugin with it's own UI that I want to open only by using a key combination. I want to chose what this key combination and yes, it may conflict with AE, but that's another story. I have read this thread, and it doesn't seem to fix exactly what I want, so for the time being I'm using the IdleHook to detect if any key combo was pressed. The problem with this approach is that there is a bit of a lag between the press and the actual execution caused by the periodicity of the calls to IdleHook.

Is there a way to detect a keyboard press that "fires" immediately? Or any way to hack into the AE's window handle?

This topic has been closed for replies.
Correct answer octaviosa

Sorry if I overlooked something, I was reading through the thread you linked and got the impression you could only listen for commands that had pre-existing keyboard shortcuts?

c. if you're a simple menu command AEGP, you can leech off of existing shortcuts. find out the command number for "turn off video for all other layers" (ctrl + alt + shift + V), and register it in the command hook. when you get that call you decide whether the user meant for your action to take place, or the improbable command for turning all other layers off (who uses that???).


Yes, you can only listen to existing commands in the command hook. What I'm doing right now is to look for keystrokes in the idle hook, which has nothing to do with commands.

The idle hook get's called by AE automatically every 100ms I believe. What I'm doing is using the windows API to check for pressed keys like this:

SHORT keyDown = ((GetKeyState(VK_LCONTROL) & 0x8000) | (GetKeyState(VK_RCONTROL) & 0x8000)) && !(GetKeyState(VK_RMENU) & 0x8000);

if (keyDown != 0)

     "Control Key pressed!"

As I mentioned, this works fine, except for a small delay sometimes between the press and the action caused by the periodicity of the call to the Idle function.

1 reply

Community Expert
January 10, 2019

off the top of my head...

if you use a key combination that AE already uses, then you can use

"command hook" for that specific operation. you'll get an immediate

notification, and i think even the chance to override AE's handing of that

operation.

octaviosaAuthor
Inspiring
January 10, 2019

Thanks for the quick reply Shachar, however, I want the user to choose exactly what's the combination he prefers, which unfortunately rules out the possibility of using the "command hook".

Community Expert
January 10, 2019

well, you can edit AE's prefs file (After Effects Default.txt) to kidnap an

existing command and change it's shortcut to whatever you want.

for example you can change "select all" from ctrlA to ctrlshiftaltB,

and then intercept the "select all" command using command hook.

you'll probably want to kidnap some esoteric command and not "select all"...

the user might need to restart AE after changing the shotcuts file, and i

have no idea what will happen if two operations will accidentally be given

the same shortcut.

be ware. here be monsters...