Open keyboard properties dialog in a localized system

69 views Asked by At

I have the following code which opens keyboard properties dialog when ever user clicks on a button:

Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.FileName = "main.cpl";
proc.StartInfo.Arguments = "keyboard";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
proc.Start();
proc.WaitForExit();
int keyBoardWindow;
while ((keyBoardWindow = FindWindow(null, "Keyboard Properties")) == 0) ;
int isSet = SetForegroundWindow(keyBoardWindow);

This code works fine when the default language of your system is English, in case of other languages like Chinese the FindWindow method doesn't exit. May be its because the dialog window does not have the name "Keyboard Properties" anymore. What do you people suggest? How should I handle this so that I am able to open keyboard properties dialog whatever the language of the system may be.

1

There are 1 answers

0
dymanoid On BEST ANSWER

As described in MSDN, you should open the Control Panel's Keyboard properties window using this command:

control.exe keyboard

You can find another commands there, such as mouse or fonts settings.