メイン フォームにボタンを追加Form1
して、WinAPI でクリックをシミュレートできます。
[DllImport("user32.dll", EntryPoint="FindWindowExW", SetLastError=true,
CharSet=CharSet.Unicode)]
public static extern IntPtr FindWindowEx( IntPtr Ph,IntPtr Ch,
IntPtr Ph1,
String lpWindowName);
System.IntPtr hwnd = FindWindowEx(IntPtr.Zero,IntPtr.Zero,IntPtr.Zero,"Form1");
System.IntPtr ptrChild = GetWindow(this.Handle, GW_CHILD) ;
while(!ptrChild.Equals(IntPtr.Zero))
{
if(ptrChild == FindWindowEx(hwnd,IntPtr.Zero,IntPtr.Zero,"button2"))
{
SendMessage(ptrChild, WM_LBUTTONDOWN, 0, IntPtr.Zero);
SendMessage(ptrChild, WM_LBUTTONUP, 0, IntPtr.Zero);
SendMessage(ptrChild, BM_SETSTATE,1 , IntPtr.Zero);
break;
}
else
{
ptrChild = GetWindow(ptrChild, GW_HWNDNEXT) ;
}
}
メソッドに関する情報FindWindowEx
: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633500(v=vs.85).aspx