我有一个应用程序要在Windows 7平板电脑上运行,并且需要将屏幕键盘停靠在屏幕底部。理想情况下,我想阻止某人能够移动或更改这些设置。在屏幕键盘上以编程方式控制Windows 7
使用评论张贴到堆栈溢出答案在这里How do I control the text input panel programmatically (TabTip.exe) in Windows Vista/7我能够编程停靠在屏幕底部的键盘,所以这是一个开始。我不得不使用提升的权限运行,以得到它的工作
[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);
我宁愿能控制大小有点比这更好的,所以我想移动窗口,像这样:
[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);
确定返回true,但窗口不会改变。如果我试着用记事本来做这件事,那就完美了。那么这是否是这个特定程序的问题?
相关:http://stackoverflow.com/questions/1770670/how-do-i-control-the-text-input-panel -programmatically-tabtip-exe-in-windows-v – sshow
可以肯定的是:你是在谈论无法调整大小的黑色“新风格”键盘,或者是具有“正常”窗口边界的屏幕键盘上的旧键盘吗?调整大小? – Traubenfuchs
@Traubenfuchs我正在谈论新式键盘。但是我也看过了较老的osk.exe,我无法说服那个人移动。想知道是否要在Windows 7 x64上尝试这样做。但也许这需要更多的调查。 – Firedragon