• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Keyboard shortcut for AEGP plugin

Explorer ,
Jan 10, 2019 Jan 10, 2019

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?

TOPICS
SDK

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jan 16, 2019 Jan 16, 2019

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

...

Votes

Translate

Translate
Community Expert ,
Jan 10, 2019 Jan 10, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 10, 2019 Jan 10, 2019

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".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2019 Jan 10, 2019

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 16, 2019 Jan 16, 2019

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

They probably use the same trick I do, listen for keys in the IdleHook.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 16, 2019 Jan 16, 2019

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???).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2019 Jan 16, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

LATEST

Great, thanks for the info!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines