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'.
using namespace std;
int main(int argc, char* argv)
int i = 1;
while ((taskBar = FindWindow("Shell_TrayWnd",""))==NULL)//First argument is the CLASS NAME, Second is the CAPTION of the window
while ((sysTray = FindWindowEx(taskBar,0,"TrayNotifyWnd",""))==NULL)
while ((expandTray = FindWindowEx(sysTray,0,"Button",""))==NULL)
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.