WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Web UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Active Web Page Url

 Keywords:  DDE DDEExecute WWW_GetWindowInfo GetActivePageUrl web page browser url active current ie iexplore chrome firefox mozilla netscape 

Totally undebugged DDE code sample that attempts to get the current url displayed in the web browser. This code is intended to work with many different browsers.
;***************************************************************************
;**
;**      GetActivePageUrl
;**
;** Purpose: Get url of active webpage using DDE
;**
;** Developer: Deana Falk 2012.03.22
;** Revisions: 1.0
;***************************************************************************


#DefineFunction GetActivePageUrl( browser )
   channel = DDEInitiate(browser, "WWW_GetWindowInfo") ;Initialize DDE
   url = DDERequest( channel, "0xFFFFFFFF" )
   DDETerminate(channel)
   Return url
#EndFunction

#DefineFunction GetActivePageUrlFromChrome( )
   AddExtender("wwctl44i.dll",0,"wwctl64i.dll")
   hWndChrome = cFindByClass('Chrome_OmniboxView')
   If hWndChrome <>0
      WM_GETTEXT = 13
      len=256 ; abritrary max len
      buf=BinaryAlloc(len)
      BinaryEodSet(buf,len)
      ret = DllCall(StrCat(DirWindows(1),"user32.dll"), long:"SendMessageA", long:hWndChrome ,long:WM_GETTEXT, long:len, lpbinary:buf)
      url = BinaryPeekStr(buf,0,ret)
   EndIf
   Return url
#EndFunction


If AppExist('iexplore')
   browser = 'iexplore'
   url = GetActivePageUrl( browser )
ElseIf AppExist('firefox')
   browser = 'firefox'
   url = GetActivePageUrl( browser )
ElseIf AppExist('netscape')
   browser = 'netscape'
   url = GetActivePageUrl( browser )
ElseIf AppExist('mosaic')
   browser = 'mosaic'
   url = GetActivePageUrl( browser )
ElseIf AppExist('netscp6')
   browser = 'netscp6'
   url = GetActivePageUrl( browser )
ElseIf AppExist('mozilla')
   browser = 'mozilla'
   url = GetActivePageUrl( browser )
ElseIf AppExist('chrome')
    ; DDE is not supported in Google Chrome
    browser = 'chrome'
    url = GetActivePageUrlFromChrome( )
Else
   Pause('','No supported browser is running')
   Exit
EndIf


Message("Active URL in ":browser, url)

Exit

Article ID:   W18410
Filename:   Get Active Web Page Url.txt
File Created: 2012:03:22:11:36:06
Last Updated: 2012:03:22:11:36:06