[RESOLVED] Trying to close a bubble window that pops up from a tray icon
I am configuring the windows supplicant for 802.1x. While doing so, it pops up a bubble notification from a tray icon that says something like "Click to provide additional information..." I wish to suppress this so I do not get this bubble notification. I figured I could enumerate through all the windows and send that window a WM_CLOSE.
Anyway if I enumerate through child windows of the desktop I never see this window (code follows). However if I use a dev studio 2008 tool, spy and I use the find window and drag the cursor thing over the window, it finds it.
So what am I doing wrong and/or is there a better way to go about doing this.
Code:
#define SEARCH_TEXT_XP2000 "Click here to enter your user name and password for the network"
#define SEARCH_TEXT_VISTA "Click to provide additional information and connect"
//#define SEARCH_TEXT_VISTA "additional information"
// Size of the smaller of the above strings
#define SEARCH_TEXT_LEN sizeof(SEARCH_TEXT_VISTA)
// Window Clicker section. There are some windows
BOOL CALLBACK EnumFunc(HWND hwnd, LPARAM lParam)
{
int Len;
char Buffer[1025];
bool *DidClick = (bool *)lParam;
Buffer[0] = 0;
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
if (Len >= SEARCH_TEXT_LEN)
{
CString MatchBuff;
MatchBuff = Buffer;
printf("%s\n", MatchBuff.GetString() );
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
SendMessage(hwnd, WM_CLOSE , NULL, NULL);
// SendMessage(hwnd, WM_LBUTTONUP , NULL, NULL);
*DidClick = true;
return FALSE;
}
}
return TRUE;
}
void WaitForClick(void)
{
bool DidClick = false;
while ( false == DidClick)
{
printf(" ------------ \n");
EnumChildWindows(GetDesktopWindow(), EnumFunc, (LPARAM)&DidClick);
Sleep(500);
printf(" ------- \n");
}
}
I also printed out the windows to the console and verified that I do not see that window anywhere.
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
I am configuring the windows supplicant for 802.1x. While doing so, it pops up a bubble notification from a tray icon that says something like "Click to provide additional information..." I wish to suppress this so I do not get this bubble notification. I figured I could enumerate through all the windows and send that window a WM_CLOSE.
Anyway if I enumerate through child windows of the desktop I never see this window (code follows).
It only means that this window is NOT a child of the desktop window.
Quote:
Originally Posted by
DeepT
However if I use a dev studio 2008 tool, spy and I use the find window and drag the cursor thing over the window, it finds it.
Well, then look at the parent of this window in the Spy++, then at the parent of the parent and so on until you find out the desktop window...
Re: Trying to close a bubble window that pops up from a tray icon
It's parent window is just a handle with no caption or anything. That window has no parent. I thought all windows were children of the desktop window. So how do I find that window?
Re: Trying to close a bubble window that pops up from a tray icon
But this window always has some window class! It is what need!
Re: Trying to close a bubble window that pops up from a tray icon
It is tooltips_class32. How does this help me? I am apparently not as smart or knowledgeable as you think I am.
I have tried this additional code, which I would think should find every window, but it doesn't.
Code:
#define SEARCH_TEXT_XP2000 "Click here to enter your user name and password for the network"
#define SEARCH_TEXT_VISTA "Click to provide additional information and connect"
//#define SEARCH_TEXT_VISTA "additional information"
// Size of the smaller of the above strings
#define SEARCH_TEXT_LEN sizeof(SEARCH_TEXT_VISTA)
// Window Clicker section. There are some windows
BOOL CALLBACK EnumChildFunc(HWND hwnd, LPARAM lParam)
{
int Len;
char Buffer[1025];
bool *DidClick = (bool *)lParam;
Buffer[0] = 0;
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
if (Len >= SEARCH_TEXT_LEN)
{
CString MatchBuff;
MatchBuff = Buffer;
printf("%s\n", MatchBuff.GetString() );
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
SendMessage(hwnd, WM_CLOSE , NULL, NULL);
// SendMessage(hwnd, WM_LBUTTONUP , NULL, NULL);
*DidClick = true;
return FALSE;
}
}
return TRUE;
}
BOOL CALLBACK EnumAllFunc(HWND hwnd, LPARAM lParam)
{
EnumChildWindows(hwnd, EnumChildFunc, (LPARAM)lParam);
return TRUE;
}
void WaitForClick(void)
{
bool DidClick = false;
while ( false == DidClick)
{
printf(" ------------ \n");
EnumWindows( EnumAllFunc, (LPARAM)&DidClick);
Sleep(500);
printf(" ------- \n");
}
}
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
It's parent window is just a handle with no caption or anything. That window has no parent. I thought all windows were children of the desktop window. So how do I find that window?
Use EnumWindows instead of EnumChildWindows.
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
It is tooltips_class32. How does this help me?
You have to use Spy++ to obtain the whole windows hierarchy from your window and up to desktop one; for each window from this hierarchy you will need to know the window classes to use them then in your enumerations...
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
It is tooltips_class32. How does this help me? I am apparently not as smart or knowledgeable as you think I am.
I have tried this additional code, which I would think should find every window, but it doesn't.
You don't need to use EnumChildWindows at all if you are looking for a window which isn't a child.
Try this - your original code from the first post with one line altered (highlighted in red):
Code:
#define SEARCH_TEXT_XP2000 "Click here to enter your user name and password for the network"
#define SEARCH_TEXT_VISTA "Click to provide additional information and connect"
//#define SEARCH_TEXT_VISTA "additional information"
// Size of the smaller of the above strings
#define SEARCH_TEXT_LEN sizeof(SEARCH_TEXT_VISTA)
// Window Clicker section. There are some windows
BOOL CALLBACK EnumFunc(HWND hwnd, LPARAM lParam)
{
int Len;
char Buffer[1025];
bool *DidClick = (bool *)lParam;
Buffer[0] = 0;
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
if (Len >= SEARCH_TEXT_LEN)
{
CString MatchBuff;
MatchBuff = Buffer;
printf("%s\n", MatchBuff.GetString() );
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
SendMessage(hwnd, WM_CLOSE , NULL, NULL);
// SendMessage(hwnd, WM_LBUTTONUP , NULL, NULL);
*DidClick = true;
return FALSE;
}
}
return TRUE;
}
void WaitForClick(void)
{
bool DidClick = false;
while ( false == DidClick)
{
printf(" ------------ \n");
EnumWindows( EnumFunc, (LPARAM)&DidClick);
Sleep(500);
printf(" ------- \n");
}
}
Re: Trying to close a bubble window that pops up from a tray icon
Peter_B: This works no better...
Code:
BOOL CALLBACK EnumAllFunc(HWND hwnd, LPARAM lParam)
{
int Len;
char Buffer[1025];
bool *DidClick = (bool *)lParam;
Buffer[0] = 0;
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
if (Len >= SEARCH_TEXT_LEN)
{
CString MatchBuff;
MatchBuff = Buffer;
printf("%s\n", MatchBuff.GetString() );
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
SendMessage(hwnd, WM_CLOSE , NULL, NULL);
// SendMessage(hwnd, WM_LBUTTONUP , NULL, NULL);
*DidClick = true;
return FALSE;
}
}
}
void WaitForClick(void)
{
bool DidClick = false;
while ( false == DidClick)
{
printf(" ------------ \n");
EnumWindows( EnumAllFunc, (LPARAM)&DidClick);
Sleep(500);
printf(" ------- \n");
}
}
VictorN: I still do not understand what you mean. Why do I need to know the windows class for my enumerations? None of those API calls use a windows class. Is there an API call that uses the windows class that I do not know of?
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
VictorN: I still do not understand what you mean. Why do I need to know the windows class for my enumerations?
Just because, as you wrote:
Quote:
Originally Posted by
DeepT
It's parent window is just a handle with no caption or anything. That window has no parent. I thought all windows were children of the desktop window. So how do I find that window?
Quote:
Originally Posted by
DeepT
... None of those API calls use a windows class. Is there an API call that uses the windows class that I do not know of?
Then read MSDN about window functions and window class...
About Windows
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
Peter_B: This works no better...
The problem isn't actually anything to do with not finding the window now. It is to do with your string matching code not working.
Look at these #defines:
Code:
#define SEARCH_TEXT_VISTA "Click"
#define SEARCH_TEXT_LEN sizeof(SEARCH_TEXT_VISTA)
(I've shortened the string for clarity)
Now, SEARCH_TEXT_LEN will be 6 as it includes the null terminator.
But the result of this
Code:
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
for a window with text "Click" will be that Len = 5, as the return value for WM_GETTEXT is the number of characters copied, not including the terminating null character.
Therefore, even if you find the correct window, this line:
Code:
if (Len >= SEARCH_TEXT_LEN)
will not work.
Re: Trying to close a bubble window that pops up from a tray icon
Thanks peter_b, that could be a problem and I could have missed that window title however with this change to that function:
Code:
CString Output;
// Window Clicker section. There are some windows
BOOL CALLBACK EnumChildFunc(HWND hwnd, LPARAM lParam)
{
int Len;
char Buffer[1025];
bool *DidClick = (bool *)lParam;
Buffer[0] = 0;
if ( true == *DidClick )
{
return FALSE;
}
else
{
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
CString MatchBuff;
MatchBuff = Buffer;
if ( Len > 2 )
{
printf("%s\n", MatchBuff.GetString() );
Output += MatchBuff + "\n";
}
// if (Len >= SEARCH_TEXT_LEN)
{
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
SendMessage(hwnd, WM_CLOSE , NULL, NULL);
// SendMessage(hwnd, WM_LBUTTONUP , NULL, NULL);
*DidClick = true;
return FALSE;
}
}
return TRUE;
}
}
I am saving all the window titles in the CString output. Now after one full iteration of that loop I should have the window name in the Output string, right? It has like 8000 window names in it when I run it. I pasted that string into a text editor and searched for all instances of the word "click" or "additional". That window name is not found, even though I make sure the pop-up window title is still visible during the whole enumeration. I even cut and past the text I got from the spy program just to be sure.
For whatever reason this window will not show up. Any ideas? Maybe these tool-tip pop-up windows are special and do not show up during a normal enumeration?
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
Thanks peter_b, that could be a problem and I could have missed that window title however with this change to that function:
...
For whatever reason this window will not show up. Any ideas? Maybe these tool-tip pop-up windows are special and do not show up during a normal enumeration?
Is this using EnumChildWindows or EnumWindows?
Re: Trying to close a bubble window that pops up from a tray icon
Quote:
Originally Posted by
DeepT
For whatever reason this window will not show up. Any ideas?
Can you still find it with Spy++?
If Yes / have you found out the window hierarchy from this window up to all its parents?
Re: Trying to close a bubble window that pops up from a tray icon
Peter_b: EnumChildWindows, sorry about that. Here is the complete code I used:
Code:
#define SEARCH_TEXT_XP2000 "Click here to enter your user name and password for the network"
#define SEARCH_TEXT_VISTA "Click to provide additional information and connect"
//#define SEARCH_TEXT_VISTA "additional information"
// Size of the smaller of the above strings
#define SEARCH_TEXT_LEN sizeof(SEARCH_TEXT_VISTA)
CString Output;
// Window Clicker section. There are some windows
BOOL CALLBACK EnumChildFunc(HWND hwnd, LPARAM lParam)
{
int Len;
char Buffer[1025];
bool *DidClick = (bool *)lParam;
Buffer[0] = 0;
if ( true == *DidClick )
{
return FALSE;
}
else
{
Len = (int)SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)Buffer);
CString MatchBuff;
MatchBuff = Buffer;
if ( Len > 2 )
{
printf("%s\n", MatchBuff.GetString() );
Output += MatchBuff + "\n";
}
// if (Len >= SEARCH_TEXT_LEN)
{
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
SendMessage(hwnd, WM_CLOSE , NULL, NULL);
// SendMessage(hwnd, WM_LBUTTONUP , NULL, NULL);
*DidClick = true;
return FALSE;
}
}
return TRUE;
}
}
BOOL CALLBACK EnumAllFunc(HWND hwnd, LPARAM lParam)
{
EnumChildWindows(hwnd, EnumChildFunc, (LPARAM)lParam);
return TRUE;
}
void WaitForClick(void)
{
bool DidClick = false;
while ( false == DidClick)
{
printf(" ------------ \n");
EnumWindows( EnumAllFunc, (LPARAM)&DidClick);
Sleep(500);
printf(" ------- \n");
}
}
VictorN: The spy thing has given me some weird, seemingly conflicting info on this window, Ill try and describe it:
You know the normal window list interface that lists all the windows in a tree view? Under this view, it shows this window as a child of the desktop window, however when you select it using the find window where you drag the icon, it says it's parent is the shell tray or the "Shell_TrayWnd" class.
Again under the graphic / tree view this window is not under this shell tray window, but when you go through the dialog and ask it for the parent, the parent is said to be the shell tray window.
Another slight difference in nomenclature is that the Spy program lists this string as the "Window Caption". Is this the same as the windows text I get as used with "WM_GETTEXT" message? If not, what message should I use to get the caption?