我已经为此苦苦挣扎了很长一段时间,但无法得到任何我能理解的答案。我是 C# 的新手。
所以我正在启动一个应用程序(具体来说是 Accpac)然后我需要通过 sendkeys/sendmessage 将用户名发送到子窗口。我有子窗口的句柄,但我无法让它工作:IntPtr.(00020380),我收到错误“预期标识符”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Windows.Forms;
using System.Threading;
namespace myNamespace
{
class StartAccpac
{
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
public static void Main3()
{
//START ACCPAC
//Process.Start("C:\\Programs\\Accpac\\runtime\\accpac.exe");
IntPtr hwnd = IntPtr.Zero;
IntPtr hwndChild = IntPtr.Zero;
//Get a MAIN HANDLE
hwnd = FindWindow(null, "Open Company");
hwndChild = FindWindowEx(hwnd, IntPtr.(00020380), null, null); <---- ERROR
}
}
}