|
发表于 2020-5-10 21:45:01
|
显示全部楼层
我模拟了下,你可以参照:
class API_Func
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter,
string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
}
private void button2_Click(object sender, EventArgs e)
{
IntPtr hwnd = API_Func.FindWindow(null, "Form1");
if (hwnd != null)
{
IntPtr hbutton = API_Func.FindWindowEx(hwnd, (IntPtr)null, null, "yes");
if (hbutton == null)
return;
API_Func.PostMessage(hbutton, WM_LBUTTONDOWN, MK_LBUTTON, 0x000B0024);
API_Func.PostMessage(hbutton, WM_LBUTTONUP, MK_LBUTTON, 0x000B0024);
}
} |
|