strange behaviour when using special key ALT

Oct 5, 2009 at 12:25 PM

Hi!

I have some trouble when I use the command Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.ALT). When the command is executed the ALT key is not pressed, it is CONTROL.

I commented out the if statement in keyboard.cs (see below) and now alt is working ok. But I guess that the orginal code had some purpose, the question is what?

        private void SendKeyUp(short b, bool specialKey)

        {

            if (!keysHeld.Contains(b)) throw new InputDeviceException("Cannot press the key " + b + " as its already pressed");

            keysHeld.Remove(b);

            KeyboardInput.KeyUpDown keyUpDown = KeyboardInput.KeyUpDown.KEYEVENTF_KEYUP;

          // if (specialKey) keyUpDown |= KeyboardInput.KeyUpDown.KEYEVENTF_EXTENDEDKEY; <-Makes ALT becomeCTRL.

            SendInput(GetInputFor(b, keyUpDown));

        }

 

        private void SendKeyDown(short b, bool specialKey)

        {

            if (keysHeld.Contains(b)) throw new InputDeviceException("Cannot press the key " + b + " as its already pressed");

            keysHeld.Add(b);

            KeyboardInput.KeyUpDown keyUpDown = KeyboardInput.KeyUpDown.KEYEVENTF_KEYDOWN;

           // if (specialKey) keyUpDown |= KeyboardInput.KeyUpDown.KEYEVENTF_EXTENDEDKEY; <-Makes ALT become CTRL.

            SendInput(GetInputFor(b, keyUpDown));

        }

Note! The HoldKey command does not work when holding ALT+CTRL. ALT will be held instead of CTRL. (ALT+ALT)...

 

Regards Ann-Louise

 

 

 

Coordinator
Oct 17, 2009 at 11:50 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.