jollyrancher82 Posted May 14, 2006 Posted May 14, 2006 I'm looking for help with a C and Win32 problem to solve, if anyone has C and extensive Win32 experience, feel free to contact me. Quote
metatron Posted May 14, 2006 Posted May 14, 2006 I would help but I have a flight out of the country tomorrow and will be busy for some time. Quote
jollyrancher82 Posted May 14, 2006 Author Posted May 14, 2006 It doesn't matter now, I solved it :) Quote
jollyrancher82 Posted May 14, 2006 Author Posted May 14, 2006 #include <windows.h> #include <stdio.h> #include <string.h> BOOL CALLBACK EnumChildProc(HWND m_hWndChild, LPARAM m_lParam); char g_pszTitlebar[] = " - Pandora - Find New Music, Listen to Custom Internet Radio Stations"; int main() {     EnumChildWindows(GetDesktopWindow(), EnumChildProc, (LPARAM) GetDesktopWindow());     return 0; } BOOL CALLBACK EnumChildProc(HWND m_hWndChild, LPARAM m_lParam) {     char m_pszTitlebarText[1024];     GetWindowText(m_hWndChild, m_pszTitlebarText, sizeof(m_pszTitlebarText) - 1);     if (strstr(m_pszTitlebarText, g_pszTitlebar) == NULL)     {         printf("False.n");     }     else     {         printf("%s", m_pszTitlebarText);         exit(0);     }         return TRUE; } Quote
Sparda Posted May 14, 2006 Posted May 14, 2006 If I didn't know any better, I would say thats C++ not C... Quote
jollyrancher82 Posted May 14, 2006 Author Posted May 14, 2006 Good job you don't know any better :P Thats C Quote
gonffen Posted May 14, 2006 Posted May 14, 2006 Hmm... that might be because C++ and C are very close... you have much to learn young skywalker.... Quote
dirty D Posted May 14, 2006 Posted May 14, 2006 if youre trying to find that window why not just use FindWindow(NULL, "window title") thats a lot less code. Quote
Sparda Posted May 14, 2006 Posted May 14, 2006 I knew that C++ was based on C, but I never realy looked into how similare they are. Quote
jollyrancher82 Posted May 14, 2006 Author Posted May 14, 2006 if youre trying to find that window why not just use FindWindow(NULL, "window title") thats a lot less code. FindWindow requires you to have the full titlebar text, now Pandora titlebar isn't the same everytime you run it, so you have to do it this way. Quote
dirty D Posted May 14, 2006 Posted May 14, 2006 or you could use FindWindowEx searching by classname with the title text NULL and iterate through all of the browser windows if there are more than one, get the title and compare it to what youre looking for. Quote
jollyrancher82 Posted May 14, 2006 Author Posted May 14, 2006 Which would end up with about the same amount of code. Quote
dirty D Posted May 14, 2006 Posted May 14, 2006 true true it would be slightly more efficient though becuse you dont have to check every window on the desktop, not that it would really make a difference. Quote
cooper Posted May 14, 2006 Posted May 14, 2006 OT, but I really feel the cleanest way to solve the problem is irieb's approach using Javascript to grab the titlebar text, and a local webserver. Then all you need to run is an Apache server (which a number of you probably already are) that supports PHP or Perl, and make a script that does what his java class is currently doing. Back on topic, this program will repeatedly search for the requested window, find it and return the title text. Wouldn't it be better to have your main program read the output of this program which would be running in its own, separate thread? This program could then locate the window once, and after a preset interval check to see if the title has changed, and only return the title text when it has in fact changed? Should be a little more efficient, and probably not add a lot of extra code to either program. Quote
jollyrancher82 Posted May 14, 2006 Author Posted May 14, 2006 Oh the code was only a temp thing for me to test the finding window code. I only search for the window in the 3tunes program once. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.