N
Hallo,
Wie der Titel schon sagt, möchte ich den Text eines "Internet Explorer_Server"-class Window auslesen.
Für ein normales Edit-Window geht das ganz einfach:
string GetWinText( HWND wnd )
{
string text;
WPARAM length = SendMessage( wnd, WM_GETTEXTLENGTH, 0, 0 );
if( length > 0 )
{
char *buffy = new char [length+1];
LRESULT got = SendMessage( wnd, WM_GETTEXT, length+1, (LPARAM)buffy );
if( (LRESULT)length == got ) { text = buffy; }
delete [] buffy;
}
return text;
}
string TextByPosition(long Pos_X, long Pos_Y)
{
string PosString;
POINT PosPoint;
PosPoint.x=Pos_X;
PosPoint.y=Pos_Y;
HWND hWindow=WindowFromPoint(PosPoint);
PosString=GetWinText(hWindow);
CloseHandle(hWindow);
return(PosString);
}
Genau das gleiche möchte ich jetzt auch für "Internet Explorer_Server" machen.
Ich hab dazu schon fertige Visual Basic.NET (http://www.vbforums.com/showthread.php?t=357460) und Visual C++ (http://www.codeproject.com/KB/cpp/yahoochattext.aspx?display=PrintAll bzw. http://support.microsoft.com/kb/249232) codes gesehen; ich will das aber mit C++ machen.
Ich benütze den ganz normalen dev-cpp g++.exe compiler;
Hab jetzt schon die ganze Nacht rumprobiert, ohne großen Erfolg.
Meine Funktion sieht momentan so aus:
void IEDOMFromhWnd(HWND hWindow)
{
LPPOINT spDoc;
HINSTANCE hst = LoadLibrary("OLEACC.DLL");
if (hst==0) { cout << "Load Library-problem" << endl; }
LRESULT lRes;
HRESULT hr = S_OK;
if (hWindow!=0)
{
UINT lMsg=RegisterWindowMessage("WM_HTML_GETOBJECT");
LRESULT rvSMT=SendMessageTimeout(hWindow, lMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes);
if (rvSMT==0)
{
cout << "Error: SendMessageTimeout()-problem" << endl;
}
else
{
// LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT) GetProcAddress(hst, "ObjectFromLresult");
// hr=ObjectFromLresult(lRes, IID_IHTMLDocument, 0, ???);
}
}
//return(rv);
}
Ich habe keine Ahung wie ich weitermachen soll; konkret verstehe ich nicht, was "LPFNOBJECTFROMLRESULT" soll (das gibt es bei C++ nicht) oder welchen 4. Parameter ich beim ObjectFromLresult()-Aufruf angebe - um das Window-Objekt zu bekommen, von dem ich dann den Text haben will...
Bin schon sehr verzweifelt
Bin jeder Antwort sehr sehr dankbar!!!
schöne Grüße,
Mario