-2

Hi I am working on an C# Windows App that uses key combination like CTRL+A and CTRL+Z outside the app (running in background).

I tried RegisterHotKeys tutorials but i have an issue. When pressing CTRL+A only my method is executed and Windows default action is never executed. I want to execute first windows action and only after that action to execute my method for that key.

For example:

CTRL+A

1) Select All

2) My code

Some code below:

private void mainForm_Load(object sender, EventArgs e)
        {
            ObjectsList = new List<Data>();

            thisWindow = FindWindow(null, "myform");

            RegisterHotKey(thisWindow, 1, (uint)fsKeyMod.Control, (uint)Keys.A);

        }


        private enum fsKeyMod
        {
            Control = 0x0002,
        }

        protected override void WndProc(ref Message keyPressed)
        {

            base.WndProc(ref keyPressed);

            if (keyPressed.Msg == 0x0312)
            {
                Console.WriteLine("apasat cv...");
            }

        }

I need the solution as soon as possible. Thank You!

  • Are you trying to overload global keyboard shortcuts? If that's the case, consider not doing it at all. It will result in the most user hostile UI experience imaginable. – IInspectable Dec 27 '15 at 16:35

1 Answers1

1

Even if you could fix this (with message forwarding or dispatching for example), this is certainly not recommended.

Better use a unique key-combination instead.

Danny_ds
  • 11,201
  • 1
  • 24
  • 46