C#自动点击外部Process按钮
Posted 「已注销」
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C#自动点击外部Process按钮相关的知识,希望对你有一定的参考价值。
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
private void callAppBTN_Click(object sender, EventArgs e)
IntPtr hwnd_win;
IntPtr hwnd_button;
hwnd_win = FindWindow(null, "Call Extern App");
hwnd_button = FindWindowEx(hwnd_win, new IntPtr(0), null, "Test");
const int BM_CLICK = 0x00F5; //0x0201;
Message button_msg = Message.Create(hwnd_button, BM_CLICK, new IntPtr(0), new IntPtr(0));
PostMessage(button_msg.HWnd, button_msg.Msg, button_msg.WParam, button_msg.LParam);
private void tstBTN_Click(object sender, EventArgs e)
MessageBox.Show("Hello Windows!");
以上是关于C#自动点击外部Process按钮的主要内容,如果未能解决你的问题,请参考以下文章
C# winform 点击一个按钮退出窗体 并关闭相应的进程