Click here to Skip to main content
15,894,337 members
Home / Discussions / C#
   

C#

 
Questionkeycode Pin
a.fatemeh26-Jun-12 1:16
a.fatemeh26-Jun-12 1:16 
QuestionHow to retrieve a list of active computers in a LAN? Pin
asdf900925-Jun-12 23:47
asdf900925-Jun-12 23:47 
AnswerRe: How to retrieve a list of active computers in a LAN? Pin
Sandeep Mewara26-Jun-12 0:49
mveSandeep Mewara26-Jun-12 0:49 
QuestionSearch String for SQL Server Pin
FredS225-Jun-12 21:40
FredS225-Jun-12 21:40 
AnswerRe: Search String for SQL Server Pin
Dave Kreskowiak26-Jun-12 2:08
mveDave Kreskowiak26-Jun-12 2:08 
GeneralRe: Search String for SQL Server Pin
FredS226-Jun-12 3:49
FredS226-Jun-12 3:49 
AnswerRe: Search String for SQL Server Pin
Abhinav S26-Jun-12 2:34
Abhinav S26-Jun-12 2:34 
QuestionNeed a multilingual virtual keyboard. Simulating key action using virtual key codes. Unable to generate accented charcacters Pin
revengeoffallen25-Jun-12 19:12
revengeoffallen25-Jun-12 19:12 
I need to make a multilingual virtual keyboard. It should have support for accented characters like â, ƒ etc.

Normally we make such characters by pressing alt key, typing a sequence on numpad (e.g. 131) and releasing alt key. It works with manual input, but i am not able to simulate such action from input simulator.

I took logic from http://inputsimulator.codeplex. I have tried SimulateModifiedKeystoke, extended key board patch given by you, tried adding some delay, tried code in http://inputsimulator.codeplex.com/discussions/235928 . But nothing seems to be fixing this.

This is what i am trying :

C#
List<VirtualKeyCode> myList = new List<VirtualKeyCode>();
            myList.Add(VirtualKeyCode.NUMPAD1);
            myList.Add(VirtualKeyCode.NUMPAD3);
            myList.Add(VirtualKeyCode.NUMPAD1);
            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.MENU, myList);


public static void SimulateModifiedKeyStroke(VirtualKeyCode modifierKey, IEnumerable<VirtualKeyCode> keyCodes)
        {
            SimulateKeyDown(modifierKey);
            if (keyCodes != null) keyCodes.ToList().ForEach(x => SimulateKeyPress(x));
            SimulateKeyUp(modifierKey);
        }

public static void SimulateKeyPress(VirtualKeyCode keyCode)
        {
            bool isExtendedKey = InputSimulator.IsExtendedKey(keyCode);

            uint KEYEVENTF_EXTENDEDKEY = 0x0001;
            uint KEYEVENTF_KEYUP = 0x0002;

            var down = new INPUT();
            down.Type = (UInt32)InputType.KEYBOARD;
            down.Data.Keyboard = new KEYBDINPUT();
            down.Data.Keyboard.Vk = (UInt16)keyCode;
            down.Data.Keyboard.Scan = 0;
            down.Data.Keyboard.Flags = 0;
            down.Data.Keyboard.Time = 0;
            down.Data.Keyboard.dwFlags = KEYEVENTF_EXTENDEDKEY;
            down.Data.Keyboard.ExtraInfo = IntPtr.Zero;

            // If this is an extended key, send the correct flag.
            if (isExtendedKey)
            {
                down.Data.Keyboard.Flags = (UInt32)KeyboardFlag.EXTENDEDKEY;
            }

            var up = new INPUT();
            up.Type = (UInt32)InputType.KEYBOARD;
            up.Data.Keyboard = new KEYBDINPUT();
            up.Data.Keyboard.Vk = (UInt16)keyCode;
            up.Data.Keyboard.Scan = 0;
            up.Data.Keyboard.Flags = (UInt32)KeyboardFlag.KEYUP;
            up.Data.Keyboard.Time = 0;
            up.Data.Keyboard.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
            up.Data.Keyboard.ExtraInfo = IntPtr.Zero;


            // If this is an extended key, send the correct flag.
            if (isExtendedKey)
            {
                up.Data.Keyboard.Flags = up.Data.Keyboard.Flags | (UInt32)KeyboardFlag.EXTENDEDKEY;
            }

            INPUT[] inputList = new INPUT[2];
            inputList[0] = down;
            inputList[1] = up;

            var numberOfSuccessfulSimulatedInputs = SendInput(2, inputList, Marshal.SizeOf(typeof(INPUT)));
            if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The key press simulation for {0} was not successful.", keyCode));
        }

AnswerRe: Need a multilingual virtual keyboard. Simulating key action using virtual key codes. Unable to generate accented charcacters Pin
Richard MacCutchan25-Jun-12 22:09
mveRichard MacCutchan25-Jun-12 22:09 
GeneralRe: Need a multilingual virtual keyboard. Simulating key action using virtual key codes. Unable to generate accented charcacters Pin
revengeoffallen26-Jun-12 1:53
revengeoffallen26-Jun-12 1:53 
GeneralRe: Need a multilingual virtual keyboard. Simulating key action using virtual key codes. Unable to generate accented charcacters Pin
Richard MacCutchan26-Jun-12 2:02
mveRichard MacCutchan26-Jun-12 2:02 
Questionxaml parser exception Pin
Mydsh25-Jun-12 18:28
Mydsh25-Jun-12 18:28 
AnswerRe: xaml parser exception Pin
Dave Kreskowiak26-Jun-12 2:00
mveDave Kreskowiak26-Jun-12 2:00 
Questionarabic to roman numerals Pin
Salomon Velazquez25-Jun-12 12:38
Salomon Velazquez25-Jun-12 12:38 
AnswerRe: arabic to roman numerals Pin
PIEBALDconsult25-Jun-12 13:31
mvePIEBALDconsult25-Jun-12 13:31 
GeneralRe: arabic to roman numerals Pin
Salomon Velazquez25-Jun-12 13:51
Salomon Velazquez25-Jun-12 13:51 
GeneralRe: arabic to roman numerals Pin
PIEBALDconsult25-Jun-12 17:04
mvePIEBALDconsult25-Jun-12 17:04 
QuestionHow To Convert This From VB.Net Pin
Kevin Marois25-Jun-12 8:26
professionalKevin Marois25-Jun-12 8:26 
AnswerRe: How To Convert This From VB.Net Pin
Richard MacCutchan25-Jun-12 8:36
mveRichard MacCutchan25-Jun-12 8:36 
GeneralRe: How To Convert This From VB.Net Pin
Kevin Marois25-Jun-12 8:38
professionalKevin Marois25-Jun-12 8:38 
AnswerRe: How To Convert This From VB.Net Pin
OriginalGriff25-Jun-12 8:43
mveOriginalGriff25-Jun-12 8:43 
GeneralRe: How To Convert This From VB.Net Pin
Kevin Marois25-Jun-12 10:12
professionalKevin Marois25-Jun-12 10:12 
AnswerRe: How To Convert This From VB.Net Pin
Karthik Harve25-Jun-12 21:46
professionalKarthik Harve25-Jun-12 21:46 
Generaldefault textbox value Pin
vins2125-Jun-12 3:34
vins2125-Jun-12 3:34 
GeneralRe: default textbox value Pin
Pete O'Hanlon25-Jun-12 3:36
mvePete O'Hanlon25-Jun-12 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.