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.
As described in MSDN, you should open the Control Panel's Keyboard properties window using this command:
You can find another commands there, such as mouse or fonts settings.