This is some code altered from a snippit a friend showed me that clicked the start bar. I am using Windows Spy, which is a MicroSoft built application that shows all Window classes, and their children, running. This code was supposed to click the "Expand Tray" button in the bottom right, but it never gets passed finding/declaring the first Window, "taskBar'.

The odd part is, the section to find the "taskBar" window class was never altered from the original snippet, but yet loops forever.

I have debugged the program, and it indeed loops on the first process. Another strange occurance, when the program runs, the expand tray button disappears, but the tray doesn't expand.

Pass NULL or 0 to the functions FindWindow and FindWindowEx, not an empty string ("")

The Window class has a blank caption, so "" works
When you use NULL, the operating system takes it upon itself to select the most relevent result for the first query (in this case, Shell_TrayWnd)

Regardless, I've tryed it both ways, still a no-go

News Update: I have added multiple tasks inside the "while" loop, yet none are being executed, and the program is looping indefinitely. Even a simple cout << "test"; is not working. Debug goes to the first process, and then goes back to the While conditional statement.

The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings.

Which means that if you specify "" as the window title, unless the tray window has the exact same title (which may or may not be ""), it will return NULL. Of course MSDN could be wrong, but unless you've explicitly tested this scenerio, I'd tend to follow its direction. When you said you tried using NULL, you meant for the second argument right? Just in case, here is what I/he/MSDN meant:

Code:

while((taskBar = FindWindow("Shell_TrayWnd", NULL)) == NULL)

I use this personally in my own code and it works. On a related note though, I've always hated using this method and cannot understand for the life of me why a better one does not exist (most tuts I've read online use this method too). The huge glaring flaw with this is what happens if Microsoft decides to change the window class for the taskbar window in future versions. It's destined for failure.