gmamaladze / globalmousekeyhook

This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
MIT License
1.04k stars 257 forks source link

Key Combination Triggered inside of assignment method #141

Open ghost opened 3 years ago

ghost commented 3 years ago

from article: https://github.com/gmamaladze/globalmousekeyhook/blob/vNext/keycomb.md

Example:

        //1. Define key combinations (we're going to use Ctrl+Q)
        var pasteAddress = Combination.FromString("Control+Q");

        //2. Define actions
        Action actionPasteAddress = PasteAddressInWindow;

        //3. Assign actions to key combinations
        var assignment = new Dictionary<Combination, Action>
        {
            {pasteAddress, actionPasteAddress}
        };

        //4. Install listener
        Hook.AppEvents().OnCombination(assignment);

    void PasteAddressInWindow()
    {
        SendKeys.SendWait("Q");

    }

So when SendKeys.SendWait("Q"); is called, the software still thinks CONTROL is being held at this point. Im not sure why. This triggers an endless loop.

After I terminate the program, Windows thinks I still have CONTROL held in, so I have to restart my system for it to reset.