private void button1_Click(object sender, EventArgs e)
{
IntPtr qipWindow = FindWindow("TMsgForm", "[339-210-048] - Окно сообщений");
if (qipWindow == IntPtr.Zero)
{
MessageBox.Show("Not found qipWindow");
return;
}
IntPtr tPanel = FindWindowEx(qipWindow, IntPtr.Zero, "TPanel", null);
if (tPanel == IntPtr.Zero)
{
MessageBox.Show("Not found tPanel");
return;
}
IntPtr TPageControlEx = IntPtr.Zero;
do
{
TPageControlEx = FindWindowEx(tPanel, IntPtr.Zero, "TPageControlEx", null);
tPanel = FindWindowEx(qipWindow, tPanel, "TPanel", null);
}
while (TPageControlEx == IntPtr.Zero && tPanel != IntPtr.Zero);
if (TPageControlEx == IntPtr.Zero)
{
MessageBox.Show("Not found TPageControlEx");
return;
}
IntPtr TTabSheet = FindWindowEx(TPageControlEx, IntPtr.Zero, "TTabSheet", null);
if (TTabSheet == IntPtr.Zero)
{
MessageBox.Show("Not found TTabSheet");
return;
}
IntPtr tPanel2 = FindWindowEx(TTabSheet, IntPtr.Zero, "TPanel", null);
if (tPanel2 == IntPtr.Zero)
{
MessageBox.Show("Not found tPanel2");
return;
}
IntPtr TRichViewEdit = IntPtr.Zero;
do
{
TRichViewEdit = FindWindowEx(tPanel2, IntPtr.Zero, "TRichViewEdit", null);
tPanel2 = FindWindowEx(TTabSheet, tPanel2, "TPanel", null);
}
while (TRichViewEdit == IntPtr.Zero && tPanel != IntPtr.Zero);
if (TRichViewEdit == IntPtr.Zero)
{
MessageBox.Show("Not found TRichViewEdit");
return;
}
IntPtr nul = IntPtr.Zero;
int retValue;
retValue = SendMessage(TRichViewEdit, WM_RBUTTONDOWN, nul, nul);
retValue = SendMessage(TRichViewEdit, WM_RBUTTONUP, nul, nul);
}
[DllImport("user32.dll", EntryPoint="FindWindow")]
private static extern IntPtr FindWindow(string _ClassName, string _WindowName);
[DllImport("user32.dll", EntryPoint="FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndPrnt, IntPtr hwndChildAfter, string _ClassName, string _WindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
const int WM_LBUTTONDOWN = 513;
const int WM_LBUTTONUP = 514;
const int WM_RBUTTONDOWN = 516;
const int WM_RBUTTONUP = 517;