Keyboard Enlargement

Illustration

I got new monitor for my Windows Media Center machine and I stumbled upon curious issue.

I control this machine via on-screen keyboard and on new monitor it’s window was too small and of course there was no way of resizing it. That is, there was no GUI way of resizing it. I could always try to resize it programatically with a little help of SetWindowsPos function.

It was as simple as running on-screen keyboard, getting monitor it is on (in order to calculate size, it is not really a must) and then resizing it to desired size:

var process = new Process();
process.StartInfo.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "osk.exe");
process.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
process.Start();

process.WaitForInputIdle();

var win32Rect = new NativeMethods.tagRECT();
NativeMethods.GetWindowRect(process.MainWindowHandle, out win32Rect);
var originalRect = new Rectangle(win32Rect.left, win32Rect.top, win32Rect.right - win32Rect.left + 1, win32Rect.bottom - win32Rect.top + 1);

var screen = Screen.FromRectangle(originalRect);
var newWidth = (int)(screen.WorkingArea.Width / 2.5);
var newHeight = (int)(newWidth / 2.5);

NativeMethods.SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, newWidth, newHeight, NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOZORDER);

As far as size is concerned I opted for 40% of screen width (width / 2.5) and 40% of that was to be assigned as height. Exact numbers are not really important but those were ones that I liked the most. It was enough to run this program only once since Microsoft’s On-screen Keyboard will remember previous size upon exit.

If you need bigger on-screen keyboard for Windows XP, try it.