Aquí les dejo el codigo:
Código
#include "stdafx.h" #include <iostream> #include <Windows.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { TCHAR title[500]; ZeroMemory(title, sizeof(title)); HWND wnd = GetForegroundWindow(); while (true) { HWND current = GetForegroundWindow(); if (current!=wnd) { wnd = current; GetWindowText(wnd, title, 400); cout << "Text: " << title << endl; } Sleep(50); } return 0; }
Estoy haciendo pruebas con el Visual Studio 2012 pero al ejecutar el programa este siempre me devuelve un valor sin sentido EJ: 01AB8D9 lo cual supongo que debe ser basura... Si alguien puede explicarme que estoy haciendo mal estaria muy agradecido!!