private void textBox1_Click(object sender, EventArgs e)
{ //Control.MousePosition
Point p = System.Windows.Forms.Cursor.Position;
run(p.X - , p.Y + );
}
[DllImportAttribute("user32.dll", EntryPoint = "MoveWindow")]
public static extern bool MoveWindow(System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
/// <summary>
/// 根据类名和窗口名获取句柄
/// </summary>
/// <param name="lpClassName"></param>
/// <param name="lpWindowName"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); private static void run(int x, int y)
{
Process process = Process.Start("SoftBoard.exe");
IntPtr windowHandle;
do
{
windowHandle = FindWindow(null, "MainWindow");
} while (windowHandle == IntPtr.Zero);
MoveWindow(windowHandle, x, y, , , true); }
Process process = Process.Start("SoftBoard.exe");
process.WaitForInputIdle();
IntPtr str = process.MainWindowHandle;
MoveWindow(str, x, y, , , true);
句柄有时候找不到,用循环比较靠谱