Skip to content

[Question] Is there a way to suppress Combinations? #197

@MrLarryDaPuppet

Description

@MrLarryDaPuppet

Exactly what the title is asking.

After briefly reading, I can see that you can suppress mouse and key events using e.handled (like this)

private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
{
    Console.WriteLine("MouseDown: \t{0}; \t System Timestamp: \t{1}", e.Button, e.Timestamp);

    // uncommenting the following line will suppress the middle mouse button click
    // if (e.Buttons == MouseButtons.Middle) { e.Handled = true; }
}

I'm trying to use a keyboard shortcut in my tray application but testing in visual studio often opens up context menus which is a little annoying.
Is there a way to suppress the keyboard combination after it is activated? (so it doesn't trigger further combinations in the focused application)

// code I currently have; subscribe and unsubscribe are linked to form_load and form_closed events
private IKeyboardMouseEvents _globalHook;

public void Subscribe()
{
    _globalHook = Hook.GlobalEvents();

    _globalHook.OnCombination(new Dictionary<Combination, Action> {
        {Combination.FromString("Shift+Alt+D"), QuickDictionaryShortcut}
    });
}

public void Unsubscribe()
{
    _globalHook.Dispose();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions