Windows Develop Bookmark and Share   
 index > Windows Forms General > Activate MouseKeys on Windows
 

Activate MouseKeys on Windows

Hi All!

I am trying to activate MouseKeys on windows. The key combination using the keyboard are: Left Shift, Left Alt and NumLock.
I am using Visual Studio 2005 Proffesional Edition and C#.
The next code should be activate the MouseKeys, but not. I do not know what I am doing wrong.

Code Snippet

private const byte VK_NUMLOCK = 0x90;

private const byte VK_LSHIFT = 0xA0;
private const byte VK_LMENU = 0xA4;
private const byte KEYEVENTF_EXTENDEDKEY = 0x01;
private const byte KEYEVENTF_KEYUP = 0x02;


[DllImport("user32.dll")]

public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(int vkey);


private void button1_Click(object sender, EventArgs e)

{
keybd_event(VK_LSHIFT, 0x2A, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_LMENU, 0x38, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, 0);


if ((GetAsyncKeyState(VK_LMENU) < 0) & (GetAsyncKeyState(VK_LSHIFT) < 0) & (GetAsyncKeyState(VK_NUMLOCK) < 0))

{

MessageBox.Show("Three keys o.k.");
}

keybd_event(VK_NUMLOCK, 0xC5, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(VK_LMENU, 0xB8, KEYEVENTF_KEYUP, 0);
keybd_event(VK_LSHIFT, 0xAA, KEYEVENTF_KEYUP, 0);
}


Thanks for your help.


petinboy  Thursday, March 06, 2008 5:27 PM
Hi all!
Thanks to Juan Carlos Ruiz Pacheco for resolve my problem.
The next code works fine and it is very simple. I was in a mistake.

Code Snippet

ProcessStartInfo pi = new ProcessStartInfo("sethc.exe","241");

Process.Start(pi);


Thanks.
petinboy  Monday, March 10, 2008 11:42 AM
Hi all!
Thanks to Juan Carlos Ruiz Pacheco for resolve my problem.
The next code works fine and it is very simple. I was in a mistake.

Code Snippet

ProcessStartInfo pi = new ProcessStartInfo("sethc.exe","241");

Process.Start(pi);


Thanks.
petinboy  Monday, March 10, 2008 11:42 AM

You can use google to search for other answers

Custom Search

More Threads

• Controls array in design view
• ListView - how to add arrows in column header for sorting descending and ascending?
• Object Creation/Cloning
• Finding the Previous screen in windows appln
• Null datetimepicker values
• Any recommended books for smart client software factory and/or click once deployment architectures?
• Manually wrap a string
• .NET: How do I Keep Multiple Forms Active Simultaneously in a Standard Application?
• Control.Enter eventhandler ??
• picasa2: is it made with windows forms?