Evo da vam docaram kao od prilike to treba da izgleda. sve sto treba da dodate je da
nadjete pravu klasu mozile u kojoj je text koji zelite da kopirate u buffer.
Code:
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>
#include <stdio.h>
#define TEXT_LENGTH 1024
using namespace std;
BOOL ListProcessModules(DWORD);
int main()
{
char text[TEXT_LENGTH+1];
HWND hWnd = NULL;
DWORD pid = NULL;
while(1)
{
hWnd = GetForegroundWindow();
GetWindowThreadProcessId( hWnd, &pid );
if(ListProcessModules(pid))break;
Sleep(500);
}
SendMessage( hWnd, WM_GETTEXT, TEXT_LENGTH, (LPARAM)text );
if(strlen(text)>0)
printf(text);
return 0;
}
BOOL ListProcessModules( DWORD dwPID )
{
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32 me32;
// Take a snapshot of all modules in the specified process.
hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
if( hModuleSnap == INVALID_HANDLE_VALUE )
{
return( FALSE );
}
// Set the size of the structure before using it.
me32.dwSize = sizeof( MODULEENTRY32 );
// Retrieve information about the first module,
// and exit if unsuccessful
if( !Module32First( hModuleSnap, &me32 ) )
{
CloseHandle( hModuleSnap ); // clean the snapshot object
return( FALSE );
}
// Now walk the module list of the process,
// and display information about each module
if(!strcmp(me32.szModule,"firefox.exe"))
{
CloseHandle( hModuleSnap );
return true;
}
CloseHandle( hModuleSnap );
return( false );
}
Necujni Izvestavac