Copy link to clipboard
Copied
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?
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 me
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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".
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
Hi All
The videocopilot plugin FX console has a custom shortcut to launch it (control + space) and I believe they use an AEGP to achieve this, any idea how they listen for custom keyboard shortcuts as opposed to hijacking pre-existing ones?
Copy link to clipboard
Copied
They probably use the same trick I do, listen for keys in the IdleHook.
Copy link to clipboard
Copied
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???).
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Great, thanks for the info!