[英]How to get Child Process state(active or not) of a main window in another application using c#
我有一個客戶端應用程序,在菜單選項卡中具有一些選項卡,如下所示 選擇瀏覽標簽后,我需要執行一些操作。 我如何在我的應用程序中獲取該事件。 我想編寫自己的應用程序來執行此操作。 我以這種方式嘗試
int chars = 256;
StringBuilder buff = new StringBuilder(chars);
// Obtain the handle of the active window.
IntPtr handle = GetForegroundWindow();
if (GetWindowText(handle, buff, chars) > 0)
{
if (buff.ToString() == mainWindowName)
{
IntPtr WndToFind = FindWindowByCaption(IntPtr.zero, "Browse");
if(WndToFind != IntPtr.Zero)
{
MessageBox.Show("Inside Browse");
}
}
}
當“瀏覽”選項卡處於活動狀態時,我想顯示一些消息。 請幫我。
如果您使用的是tabcontrol,下面的代碼將知道用戶選擇了哪個選項卡頁。
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabControl1.TabPages["tabPage2"])
{
...add your code here
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.