How to Read URL in Netscape
Keywords: URL dllHwnd("Netscape -")
Question:
How can I read the location line in Netscape. I tried using the control manager extender and was
unsuccessful. It does not respond to EditText, LBText or CBText.
Answer:
What error do you get when you try to use the Control Manager? I looked at your question and threw
together a script that accomplished a few things with the Netscape command line in a few minutes and I
don't even know what I'm doing. Here is what worked for me, yours might be different depending on the
output from the analysis script.
debug(1)
AddExtender("wwctl34I.dll")
openwnd=DllHwnd("Netscape")
editwnd1=cWndByID(openwnd,146)
editwnd2=cWndByID(editwnd1,25000)
window=cGetCBText(editwnd2)
line=cGetEditText(editwnd2)
message('Current line contents',line)
message('Current window contents',window)
cSetedittext(editwnd2, "http://www.windowware.com")
line=cGetEditText(editwnd2)
message('Success',strcat('Current line contents set to ',line))
Read URL (non-Control Manager Method):
If reading the current URL is what is desired, the following code seems to work for me (I got it from
somewhere in the Winbatch site or BBS but don't recall where--kudos to the originator!)
dllname=strcat(DirWindows(1),"user32.dll")
user=dllLoad(dllname)
ns=dllHwnd("Netscape -")
n1=DLLCall(user, long:"GetWindow", long:ns, long:5)
n1=DLLCall(user, long:"GetWindow", long:n1, long:2)
n1=DLLCall(user, long:"GetWindow", long:n1, long:2)
n1=DLLCall(user, long:"GetWindow", long:n1, long:2)
n2=DLLCall(user, long:"GetWindow", long:n1, long:5)
n3=DLLCall(user, long:"GetWindow", long:n2, long:5)
bl=256 ; abritrary max len
buf=binaryAlloc(bl)
binaryEODset(buf,bl)
url=BinaryPeekStr(buf,0,DLLCall(user, long:"SendMessageA", long:n3, long:13, long:bl, lpbinary:buf))
dllFree(user)
binaryFree(buf)
item = askline (url, "Describe", url)
handle = IniWritePvt (`Settings`, item, url, "c:\urls\indices.ini")
exit
I haven't played with the code to see what else it discovers. The code as displayed, puts the current URL
into the variable url, and I am asked for a description of the url (item). I keep urls I gather in an INI file
that I later add to an indexed HTML file that servs as my home page.
Article ID: W12511
Filename: How to Read URL in Netscape.txt