使用下一个answer我试图以编程方式重新定位Citrix窗口,不知何故窗口不移动。
我假设保存Citrix窗口的进程名称是我启动Citrix之后在Process.GetProcesses()
中添加的下一个进程之一:Receiver,wfica32,pnamain,concentr,wfcrun32。
窗户不动的任何帮助?
IntPtr hWnd = IntPtr.Zero;
var p1 = Process.GetProcesses().Where(p => p.Id != 0 && p.ProcessName == _processToRepositionWindowName).FirstOrDefault();
if (p1 != null && p1.MainWindowHandle != IntPtr.Zero)
{
hWnd = p1.MainWindowHandle;
//tried both options
//hWnd = p1.Handle;
}
else
{
hWnd = FindWindow(_processToRepositionWindowName, null);
if(hWnd == IntPtr.Zero)
{
hWnd = FindWindow(null, _processToRepositionWindowName);
}
}
if (hWnd != IntPtr.Zero)
{
var i = SetWindowPos(hWnd, IntPtr.Zero, windowXLocation, windowYLocation, 0, 0, SWP_NOSIZE | SWP_NOZORDER | 0x0040);
}
我有几次同样的问题(而且不仅仅是Citrix windows ...)。
您需要在调用SetWindowPos之前发送EnterSizeMove消息。理想情况下,您需要使用ExitSizeMove消息关闭(尽管我已经跳过了最后一步)。
我用Java编写代码,但问题在于任何语言都是一样的:
User32.instance.SendMessageA(hwnd, User32.WM_ENTERSIZEMOVE, 0, 0);
User32.instance.SetWindowPos(hwnd, hwndTopMost, x, y, 0, 0, flags);
User32.instance.SendMessageA(hwnd, User32.WM_EXITSIZEMOVE, 0, 0);
我从AutoHotKey论坛来到this解决方案。