title: Programmatically control Windows 7 on screen keyboard
body: <p>I have an application that is to be run on a Windows 7 tablet and needs the on screen keyboard to be docked at the bottom of the screen. Ideally I want to stop someone being able to move or change these settings. </p>
  
  <p>Using the comment posted to the stack overflow answer on here <a href="https://stackoverflow.com/questions/1770670/how-do-i-control-the-text-input-panel-programmatically-tabtip-exe-in-windows-v">How do I control the text input panel programmatically (TabTip.exe) in Windows Vista/7</a> I am able to programmatically dock the keyboard to the bottom of the screen so that's a start. I had to run with elevated permission to get it to work</p>
  
  <pre><code>[DllImport("user32.dll", SetLastError = true)]
  static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  
  [return: MarshalAs(UnmanagedType.Bool)]
  [DllImport("user32.dll", SetLastError = true)]
  public static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
  
  string onScreenKeyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
  var onScreenKeyboardProc = Process.Start(onScreenKeyboardPath);
  
  IntPtr wKB = FindWindow("IPTip_Main_Window", null);
  
  const uint WM_COMMAND = 0x111;
  // Where message is 10021 for dock bottom, 10023 for dock top and 10020 for floating
  bool x = PostMessage(wKB, WM_COMMAND, new IntPtr(10021), IntPtr.Zero);
  </code></pre>
  
  <p>I would prefer being able to control the size a bit better than that so I tried to move the window like so:</p>
  
  <pre><code>[DllImport("user32.dll")]
  static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
  
  private const uint SWP_SHOWWINDOW = 0x0040;
  bool ok = SetWindowPos(wKB, this.Handle, 0, 500, 750, 500, SWP_SHOWWINDOW);
  </code></pre>
  
  <p>ok returns true but the windows doesn't budge. If I try and do this with notepad it works perfectly. So is it an issue with this particular program?</p>