c# - Automating Key Presses with SendInput -
 When I try to use the  SendInput  to send a single key press, and the combined Keypresses, I did not get my program to capture the keyboard button until I was ordered to be released. With the code below I want to send the character  'a'  and  'A'  by killing  shift  first. However, I can not keep it in the  'a'  button.   
 public static zero keydown () {switchwindow (process gate process_name ("notepad") .FirstOrDefault () MainWindowHandle). INPUT [] Input = new INPUT [1]; KEYBDINPUT KB = new KEYBDINPUT (); // Set Generic Keyboard Event Inputs [0] Type = INPUT_KEYBOARD; kb.wScan = 0; // hardware scan code for key kb.time = 0; Kb.dwExtraInfo = IntPtr.Zero; Kb.dwFlags = 0; Press key to press the key. Kb.wVk = (ushort) KeyCode.SHIFT; Input [0] .ki = kb; SendInput (1, Input, Marshall Size. (Input [0]); // press 'a' key kb.wVk = (ushort) 0x41; // virtual key code for "a" key inputs [0] .ki = kb; SendInput (1, Input, Marshall Size. (Input [0]); // Release 'A' key kb.dwFlags = KEYEVENTF_KEYUP; Kb.wVk = (ushort) 0x41; // "A" key input for the virtual key code [0] .ki = kb; SendInput (1, Input, Marshall Size. (Input [0]); // Release 'Shift' key kb.dwFlags = KEYEVENTF_KEYUP; Kb.wVk = (ushort) KeyCode.SHIFT; // "A" key input for the virtual key code [0] .ki = kb; SendInput (1, Input, Marshall Size. (Input [0]); }   
Comments
Post a Comment