Thread: Problem capturing the titles of one window

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    4

    Problem capturing the titles of one window

    Okay, I have this code below just to illustrate what my problem is, I want to capture the title of the active window and display that in the output. And then it would not do anything unless the user switched to another window. For that it works fine, but I also want it to log all the titles in the active window, so for example if I open firefox( my homepage is google), it would log the google part but if I continue browsing it doesn't log all the other new websites. So I'm just looking for a code that will log all the new titles regardless if you switched between those windows. You can try the code below and have two windows open and switching between them will output the titles, but if you just have one window and you're just browsing that it doesn't log the new titles, just the first one. I hope I've made it clear what I'm trying to do, maybe this is the wrong function call so I hope someone can tell me that but if it's right I'd appreciate if someone could fix it for or give me a hint or two thanks.

    Code:
    #include <iostream>
    #include <fstream>
    #include <windows.h>
    using namespace std;
     char name[MAX_PATH];
     HWND currentWin = GetForegroundWindow();
     HWND temporaryWin;
    int main(){
      while(1){
      temporaryWin = currentWin;
      currentWin = GetForegroundWindow();
      if(temporaryWin != currentWin){
        GetWindowText(currentWin, name, 256);
      cout << name << endl;}}
        return 0;
        }
    Last edited by newbie421; 06-07-2007 at 11:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. Capturing window content
    By leojose in forum Windows Programming
    Replies: 4
    Last Post: 06-30-2005, 08:30 AM
  3. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  4. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 04:49 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM