public static void CommandWithClick(string wndClass, int width, int height, double xFactor, double yFactor) { WndFinder wf = new WndFinder(); IntPtr hWnd = wf.GetWindow(wndClass); if (hWnd != IntPtr.Zero) { SetWindowPos(hWnd, /*HWND_TOPMOST*/ (IntPtr)(-1), 0, 0, width, height, SetWindowPosFlags.ShowWindow); int x = (int)(width * xFactor); int y = (int)(height * yFactor); MouseLeftClick(x, y); } }