有可能是接收消息程序更新了。使用SendMessage或PostMessage替代sendkey,sendkey调试的时候容易死机,而且接收的窗口还必须在最前面。//向指定句柄发送关闭消息
[DllImport("user32.dll", EntryPoint = "PostMessage", SetLastError = true)]
extern static bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);/// <summary>
/// 向指定窗口发送字符串
/// </summary>
[DllImport("User32.dll", EntryPoint = "SendMessage")]
static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, string lParam); /// <summary>
/// 该函数将指定的消息发送到一个或多个窗口。
/// 此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。
/// 而函数PostMessage不同,将一个消息寄送到一个线程的消息队列后立即返回
/// </summary>
[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
static extern int SendMessage(IntPtr hwnd, uint wMsg, uint wParam, uint lParam);
[DllImport("user32.dll", EntryPoint = "PostMessage", SetLastError = true)]
extern static bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);/// <summary>
/// 向指定窗口发送字符串
/// </summary>
[DllImport("User32.dll", EntryPoint = "SendMessage")]
static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, string lParam); /// <summary>
/// 该函数将指定的消息发送到一个或多个窗口。
/// 此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。
/// 而函数PostMessage不同,将一个消息寄送到一个线程的消息队列后立即返回
/// </summary>
[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
static extern int SendMessage(IntPtr hwnd, uint wMsg, uint wParam, uint lParam);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货