我有一個應用程序要在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