Marek Donar
11/4/2005 11:25:00 AM
Hi,
I'm trying to get URL from Internet Explorer window. I managed to get the
window (EditControl) handle, get correct URL length, but as soon as I call
sendMessage("WM_GETTEXT",...), strange things start to happen:
1) handle of main window is always found, but handles of child windows are
only found for the first time job is run
2) in infolog all entries have questionmark icon as if there was help
My test job follows - it searches for Window named "Google - Microsoft
Internet Explorer". Does anyone know where the bug is? I suspect bad use of
Binary class.
Thanks in advance
Marek Donar
static void testGetUrl2(Args _args)
{
int hWnd, urlLength, foo;
str 1000 url;
DLL winApiDLL = new DLL('USER32');
Binary binary = new Binary(url);
DLLFunction sendMessage = new DLLFunction(winApiDLL, 'SendMessageA');
#define.windowCaption ("Google - Microsoft Internet Explorer")
#define.IEFrame ("IEFrame")
#define.workerW ("WorkerW")
#define.rebar ("ReBarWindow32")
#define.comboEx ("ComboBoxEx32")
#define.combo ("ComboBox")
#define.edit ("Edit")
#define.WM_GETTEXTLENGTH(0x000E)
#define.WM_GETTEXT (0x000D)
#define.verbose (true)
;
hWnd = WinApi::findWindow(#IEFrame,#windowCaption);
info(strFmt('Main window hWnd: %1 (%2)',
hWnd,WinApi::getWindowText(hWnd)));
hWnd = WinApi::findWindowEx(hWnd,0,#WorkerW,"");
if (#verbose)
info(strFmt('WorkerW hWnd: %1', hWnd));
hWnd = WinApi::findWindowEx(hWnd,0,#rebar,"");
if (#verbose)
info(strFmt('Rebar hWnd: %1', hWnd));
hWnd = WinApi::findWindowEx(hWnd,0,#comboEx,"");
if (#verbose)
info(strFmt('ComboBoxEx hWnd: %1', hWnd));
hWnd = WinApi::findWindowEx(hWnd,0,#combo,"");
if (#verbose)
info(strFmt('ComboBox hWnd: %1', hWnd));
hWnd = WinApi::findWindowEx(hWnd,0,#edit,"");
if (#verbose)
info(strFmt('Edit hWnd: %1', hWnd));
urlLength = WinApi::sendMessage(hWnd, #WM_GETTEXTLENGTH, 0, "");
//foo = WinApi::sendMessage(hWnd, #WM_GETTEXT, urlLength, url);
sendMessage.returns(ExtTypes::DWord);
sendMessage.arg(ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::String);
foo = sendMessage.call(hWnd, #WM_GETTEXT, urlLength, binary);
info(url);
info(strFmt("URL: '%1' (%2/%3)", url, urlLength, foo));
}