C#获取其他程序上的按钮的句柄
目前有个程序,标题为SMC,类为SMC。其中包含一个SMCTabWindow的子窗体,标题为SMCTabWindow,类为SMCTabWindow。SMCTabWindo...
目前有个程序,标题为SMC,类为SMC。 其中包含一个SMCTabWindow的子窗体,标题为SMCTabWindow,类为SMCTabWindow。 SMCTabWindow子窗体内包含按钮,按钮的类为Button,标题为Send,请问该如何获取这个按钮的句柄呢?
string lpszParentClass = "SMC";
string lpszParentWindow = "SMC";
string Smctabclass = "SMCTabWindow";
string Smctabname = "SMCTabWindow";
string lpszClass_Submit = "Button";
string lpszName_Submit = "Send";
IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);
IntPtr mid = new IntPtr(0);
while (true)
{
ParenthWnd = FindWindow(lpszParentClass, lpszParentWindow);
if (!ParenthWnd.Equals(IntPtr.Zero))
{
mid = FindWindowEx(ParenthWnd, new IntPtr(0), Smctabclass, Smctabname);
EdithWnd = FindWindowEx(ParenthWnd, new IntPtr(0), lpszClass_Submit, lpszName_Submit);
if (!mid.Equals(IntPtr.Zero))
{
MessageBox.Show("2");
if (!EdithWnd.Equals(IntPtr.Zero))
{
MessageBox.Show("1");
SendMessage(EdithWnd, WM_CLICK, (IntPtr)0, "0");
}
}
return;
}
}
软件截图如下
望大神指点,最好有代码,小弟自学C#,刚刚入门。 拜谢。没有悬赏分了,实在不好意思 展开
string lpszParentClass = "SMC";
string lpszParentWindow = "SMC";
string Smctabclass = "SMCTabWindow";
string Smctabname = "SMCTabWindow";
string lpszClass_Submit = "Button";
string lpszName_Submit = "Send";
IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);
IntPtr mid = new IntPtr(0);
while (true)
{
ParenthWnd = FindWindow(lpszParentClass, lpszParentWindow);
if (!ParenthWnd.Equals(IntPtr.Zero))
{
mid = FindWindowEx(ParenthWnd, new IntPtr(0), Smctabclass, Smctabname);
EdithWnd = FindWindowEx(ParenthWnd, new IntPtr(0), lpszClass_Submit, lpszName_Submit);
if (!mid.Equals(IntPtr.Zero))
{
MessageBox.Show("2");
if (!EdithWnd.Equals(IntPtr.Zero))
{
MessageBox.Show("1");
SendMessage(EdithWnd, WM_CLICK, (IntPtr)0, "0");
}
}
return;
}
}
软件截图如下
望大神指点,最好有代码,小弟自学C#,刚刚入门。 拜谢。没有悬赏分了,实在不好意思 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询