I am trying to reposition the TabTib keyboard without success the SetWindowPos function returns "True" but the keyboard is not moving. I am using C# on windows 7.
` [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string ClassName, string WindowName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}
Rectangle KeyboardRect;
IntPtr TabTipHandle;
IntPtr GetWindowHandle()
{
return FindWindow("IPTip_Main_Window",null);
}
bool MoveKeyBoard(IntPtr hWnd, int ToX, int ToY)
{
return SetWindowPos(hWnd, this.Handle, ToX, ToY, KeyboardRect.Width, KeyaboardRect.Height, 0x0045);
}
void StartKeyboard()
{
Process.Start(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe");
TabTipHandle = GetWindowHandle();
KeyboardRect = GetKeyboardRect(TabTipHandle);
textBox1.Text = KeyaboardRect.Top.ToString() + ", " + KeyboardRect .Left.ToString() + ", " + KeyboardRect .Width.ToString() + ", " + KeyboardRect .Height.ToString();
MoveKeyBoard(TabTipHandle, 100, 100);
KeyboardRect = GetKeyboardRect(TabTipHandle);
textBox2.Text = KeyaboardRect.Top.ToString() + ", " + KeyboardRect .Left.ToString() + ", " + KeyboardRect .Width.ToString() + ", " + KeyboardRect .Height.ToString();
}
void button1_Click(object sender, EventArgs e)
{
StartKeyboard();
}
void button2_Click(object sender, EventArgs e)
{
MoveKeyBoard(TabTipHandle, 200, 100);
KeyboardRect = GetKeyboardRect(TabTipHandle);
textBox2.Text = KeyboardRect .Top.ToString() + ", " + KeyboardRect .Left.ToString() + ", " + KeyboardRect .Width.ToString() + ", " + KeyboardRect .Height.ToString();
}
`
spyxx.exe
program to ensure that the handle returned byFindWindow
is the correct one – γηράσκω δ' αεί πολλά διδασκόμε