using System;
using System.Drawing;
using System.Diagnostic;
using System.IO;
using System.Runtime.InteropServices;
class
Win32
{
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern bool SetWindowPos(
int hWnd, // window
handle
int hWndInsertAfter, // placement-order
handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags
public const int HWND_BOTTOM = 0x0001;
public const int HWND_TOP = 0x0000;
public const int SWP_NOSIZE = 0x0001;
public const int SWP_NOMOVE = 0x0002;
public const int SWP_NOZORDER = 0x0004;
public const int SWP_NOREDRAW = 0x0008;
public const int SWP_NOACTIVATE = 0x0010;
public const int SWP_FRAMECHANGED = 0x0020;
public const int SWP_SHOWWINDOW = 0x0040;
public const int SWP_HIDEWINDOW = 0x0080;
public const int SWP_NOCOPYBITS = 0x0100;
public const int SWP_NOOWNERZORDER = 0x0200;
public const int SWP_NOSENDCHANGING = 0x0400;
}
namespace MyApplication
{
class OnScreenKeyboard
{
public static void Show()
{
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System);
process.StartInfo.FileName += "\\osk.exe";
process.StartInfo.Arguments = "";
process.StartInfo.WorkingDirectory = Environment.GetFolderPathEnvironment.SpecialFolder.LocalApplicationData);
process.Start(); // Start Onscreen Keyboard
// calculate size:
Rectangle screen = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
Int32 width = (Int32)Math.Round((Double)(screen.Width / 5 * 4));
Int32 height = (Int32)Math.Round((Double)(screen.Height / 3));
Int32 left = (Int32)Math.Round((Double)(screen.Width / 5 /2));
Int32 top = 2* height;
process.WaitForInputIdle();
Win32.SetWindowPos((int)process.MainWindowHandle,
Win32.HWND_BOTTOM,
left, top, width, height,
Win32.SWP_SHOWWINDOW |
Win32.SWP_NOZORDER);
}
}
}