Jump to content

Looking for a C Coder


jollyrancher82

Recommended Posts

#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;

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...