Hello. I wanted to ask for help in the next question: how to emulate Alt + NumPad * input?

I have an XML file with instructions, ala:

<Action Name="KeyDown" Key="ALT"> <Action Name="KeyDown" Key="NUMPAD1"> <Action Name="KeyUp" Key="NUMPAD1"> <Action Name="KeyDown" Key="NUMPAD2"> <Action Name="KeyUp" Key="NUMPAD2"> <Action Name="KeyUp" Key="ALT"> 

These instructions are read and, for each Action, an INPUT is created, which is sent by WinAPI:

 WinAPI.INPUT action = new WinAPI.INPUT(); action.Type = (UInt32)SendInputEventType.InputKeyboard; action.Data.Keyboard = new WinAPI.KEYBDINPUT((uint)_action, (ushort)_key); WinAPI.SendInput(1, new WinAPI.INPUT[] { action }, System.Runtime.InteropServices.Marshal.SizeOf(action)); 

Constructor KEYBDINPUT:

 public KEYBDINPUT(uint action, ushort key) { Vk = key; Scan = 0; Time = 0; Flags = action; ExtraInfo = IntPtr.Zero; } 

Key combinations: Ctrl + A, Ctrl + C, Ctrl + V, work, and Alt + NUMPAD - does not enter anything.

I tried using Scan, with the help of a scan code and the KEYEVENTF_SCANCODE flag. It turned out exactly the same.

I tried to memorize the whole combination and send it as a list, but I stopped displaying anything at all. I do not think that the problem is this, because the rest of the combinations work.

    2 answers 2

    You can also try

     SendKeys.Send("%{MULTY}"); 
    • Meaning {MULTIPLY}? - Sergey
    • Yes of course. Sorry, hurried, did not finish) - Sergio

    After repeated attempts with SendMessage and PostMessage. Returned to SendInput and I did it, after all through the Scan Code.

    Changed the KEYBDINPUT constructor so that when you press Alt, Scan and Flag are being filled:

     if (action == (uint)Test.KeyActionType.KeyDown) Flags = (uint)Test.KeyActionType.ScanCode; else Flags = (uint)Test.KeyActionType.ScanCode | (uint)Test.KeyActionType.KeyUp; Scan = (ushort)MapVirtualKey(key, 0);