delmardale
13th February 2004 18:12 UTC
Need to get URL from all open Browser Windows
I am trying to configure a setup that will figured out where it was downloaded from, so it can then go out and download files based on your setup selections. This will be installed at various servers around the world, so URL's can't be hardcoded. The webpage automatically downloads and launches the setup when you go to the page. So I plan to look at URL's of open browser windows to get the server. Anyway I've got the code so far using the System plugin to get the URL from an IE window. However I need a way to loop through all open IE windows. It appears there is a windows API function called EnumWindows which should then callback to the application function. However I can't figure out how to do this in NSIS. Below is code go get the URL from an IE window.
Could someone show me or point me to some examples of how to perform this callback. Or tell me another way I can get the window handles of open IE windows.
Once I tackle IE, then I'll work on Mozilla/Netscape.
FindWindow $hWndIE "IEFrame"
IntCmp $hWndIE 0 done
MessageBox MB_OK "found IE window"
FindWindow $hWndIEChild "WorkerW" "" $hWndIE
FindWindow $hWndIEChild "ReBarWindow32" "" $hWndIEChild
FindWindow $hWndIEChild "ComboBoxEx32" "" $hWndIEChild
System::Call 'user32::SendMessage(i,i,i,t) i($hWndIEChild, ${WM_GETTEXT},255,.r0)'
StrCpy $URLString "$0"
MessageBox MB_OK "$URLString"
Joost Verburg
13th February 2004 18:23 UTC
This is really an unreliable method. I recommend you to let it send a command line parameter.
delmardale
13th February 2004 18:44 UTC
Can not do command line, because somehow the URL to download from must be passed. End user can not be expected to know it. Also this setup launches automatically when downloaded from the site. So it's a pretty safe bet that the browser window is still open to the URL. My plan is if it can't find it, it will then prompt the end user for URL
kichik
13th February 2004 18:47 UTC
You can never be sure what is open and what is not open. You can also not be sure Internet Explorer will be used. I sugggest you append the URL to the installer on the server side, read it from the end of the file on the client side and use it or prompt if not found.
delmardale
13th February 2004 18:55 UTC
Not a bad idea. That will just require appending the server name to the end of the file at each of our 130 sites, annoying but doable. Won't the exe get corrupted though. also have any sample code?
Regarding the browser issue. As of right now we only support IE.
kichik
13th February 2004 18:58 UTC
You don't have to manually append the URL. Use a PHP script which will output the EXE and then the server's address. It won't corrupt the installer as long as you don't use NSIS_CONFIG_CRC_ANAL.
rainwater
14th February 2004 04:03 UTC
If you want the open browser windows in Internet Explorer you will have to use DDE. If you don't know what DDE is, then I wouldn't even try it. Its not too bad, but would probably require a plugin. It works on any browsers that support the DDE calls. Probably IE and Opera and maybe a few others.
You would make these DDE requests:
WWW_ListWindows (to get the window)
WWW_GetWindowInfo (to get the window url)
delmardale
18th February 2004 21:04 UTC
Appending data to end of setup and reading it
I've decided to go with kichik's approach of appending server information to the end of the setup dynamically with some sort of CGI script. Anybody got a code sample of how to get my NSIS setup to read this data off the end of the file?