Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with Windows PowerToys #51

Open
devnguy opened this issue Jun 15, 2022 · 2 comments
Open

Use with Windows PowerToys #51

devnguy opened this issue Jun 15, 2022 · 2 comments

Comments

@devnguy
Copy link

devnguy commented Jun 15, 2022

Hi,

I remapped my left alt key to left control and vice versa through Windows PowerToys. Now when using this project and pressing caps lock with other keys, it looks like alt is being registered instead of control.

Desired behavior: CTRL when pressed with other keys
Observed behavior: ALT when pressed with other keys

I've tried these configs, but all have the same result

remap_key=CAPSLOCK
when_alone=ESCAPE
with_other=CTRL
remap_key=CAPSLOCK
when_alone=ESCAPE
with_other=RIGHT_CTRL
remap_key=CAPSLOCK
when_alone=ESCAPE
with_other=ALT

Is this project expected to work after remapping the control key through some other program?

@ililim
Copy link
Owner

ililim commented Sep 25, 2022

Interesting. I haven't tested this configuration, so I assume that what happens depends on the order in which that different remapping softwares handle the keys. I can take a look.

@lihz
Copy link

lihz commented Dec 17, 2022

PowerToys use 0x101 as INJECTION KEY.
So, add or modify the key in dual-key-remap.c

Method 1 > add key.

#define INJECTED_KEY_ID 0xFFC3CED7
#define POWER_TOYS_INJECTED_KEY_ID 0x101

LRESULT CALLBACK keyboard_callback(int msg_code, WPARAM w_param, LPARAM l_param)
{
int block_input = 0;

// Per MS docs we should only act for HC_ACTION's
if (msg_code == HC_ACTION) {
    KBDLLHOOKSTRUCT * data = (KBDLLHOOKSTRUCT *)l_param;
    enum Direction direction = (w_param == WM_KEYDOWN || w_param == WM_SYSKEYDOWN)
        ? DOWN
        : UP;
    //int is_injected = data->dwExtraInfo == INJECTED_KEY_ID;
    int is_injected = (data->dwExtraInfo == INJECTED_KEY_ID || data->dwExtraInfo == POWER_TOYS_INJECTED_KEY_ID);

....
}

or
Method 2 > just use key of PowerToys

#define INJECTED_KEY_ID 0x101 // 0xFFC3CED7


and recompile dual-key-remap !

Limitation:
Should excute dual-key-remap.exe AFTER PowerToys running.

PS:

LRESULT CALLBACK keyboard_callback(int msg_code, WPARAM w_param, LPARAM l_param)
{
....
return (block_input) ? 1 : CallNextHookEx(g_mouse_hook, msg_code, w_param, l_param);
}
I think this line needs to be fixed with <g_keyboard_hook>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants