Menu

#36 Keyboard shortcuts

Done
nobody
Medium
Patch
2020-10-28
2020-10-15
No

Hi, I would like to add a feature: to use one keyboard shortcut to mute the mic, and a different one to unmute it. I am a bit lost with the hook module code. Could you provide me some tips to achieve this goal?

Thanks!

{Why do I need this: I am building an Arduino STM32 module to simulate an HID keyboard with buttons to mute/unmute the mic and an indicator light. The module will send keystrokes for muting or unmuting...}

Discussion

  • Mist Poryvaev

    Mist Poryvaev - 2020-10-28

    Hi.
    Currently hook module doesn't know if mic is muted or unmuted, it's just generating the system event. Hook module uses internal structure with parameters, two of them are key codes combination that are equal for mute and unmute (key1 and key2).

    struct KeyHook_Struct
    {
        WPARAM prev_code;
        UINT vkCode;
        int keys_count;
        int key1;
        int key2;
        BOOL enabled;
        int mic_mode;
    };
    

    If you plan to use different keys for mute and unmute, then you should extend this structure by adding new fields for key codes (for example key3 and key4). Then you should extend SetShortcut function and add another "if" branch for these new key codes (similar to line 49 at key_hook.cpp).

    if (((kstruct->prev_code == kstruct->key1) && (hs->vkCode == kstruct->key2) && (kstruct->keys_count == 2)) || ((hs->vkCode == kstruct->key1) && (kstruct->keys_count == 1))) 
    

    But hook module still knows nothing about mute and unmute. So you should also add second system event for second combination of keys, and processing code for this event in main app.
    Not so easy as expected, right? But not deadly hard too. Average deadly hard job.
    Have a good day =)

     
  • Mist Poryvaev

    Mist Poryvaev - 2020-10-28
    • status: New --> Done
     

Log in to post a comment.