打开记事本到屏幕上的特定位置,并达到所需的大小?

我需要将nNtepad打开到特定大小并在屏幕上的特定位置。

我怎么能用C#做到这一点?

我很感激代码示例。

你可以按下MoveWindow。 像这样:

using System; using System.Diagnostics; using System.Runtime.InteropServices; class Program { static void Main(string[] args) { var prc = Process.Start("notepad.exe"); prc.WaitForInputIdle(); bool ok = MoveWindow(prc.MainWindowHandle, 0, 0, 300, 200, false); if (!ok) throw new System.ComponentModel.Win32Exception(); } [DllImport("user32.dll", SetLastError = true)] private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint); } 

要打开它,你可以使用Process.Start或ShellExecute API调用,将其应用程序窗口设置为一定的大小和位置,我将调用API SetWindowsPos。

我会开始记事本,然后将其移动到所需的位置。 您可以使用FindWindow(非托管代码)找到记事本的hwd,然后向窗口发送一些move / resize事件。您将需要使用一些非托管代码,可能是Windows钩子也许您可以在这里找到代码http://pinvoke.net /

看一下这里从您的应用程序访问命令行。 代码看起来像:

 System.Diagnostics.Process.Start("Notepad"); 

我不相信你有能力在屏幕上准确定位你想要的位置

看看这个问题,我认为你会做你需要的。