Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Retrieve AddressBar of Firefox through DDE Message


  • Please log in to reply
55 replies to this topic
dumbdave
  • Guests
  • Last active:
  • Joined: --
Sorry in advance for a dumb question. When I try this out of the box, I get a MsgBox with only Chinese characters in it, not the URL I was expecting. I am running this on a Windows 7, English language box. Any ideas why? I ran the same script on an XP box and it worked fine. Is it a Windows 7 issue? Do I have some library installed with Chinese characters or something?

Thanks,
-Dave

eon
  • Guests
  • Last active:
  • Joined: --
This script seems to not work in Firefox 4. Any updated way to grab the URL of the current page through DDE or any other way without using mouse/keyboard actions (control+L , control+C )?

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
It does work for me with FF4 so post the code you used.

eon
  • Guests
  • Last active:
  • Joined: --
ff_dde:



/*

XCLASS_DATA  := 0x2000

XCLASS_FLAGS := 0x4000

XTYP_EXECUTE := 0x0050 | XCLASS_FLAGS

XTYP_POKE    := 0x0090 | XCLASS_FLAGS

XTYP_REQUEST := 0x00B0 | XCLASS_DATA

*/



sServer := "firefox"

sTopic  := "WWW_GetWindowInfo"

sItem   := "0xFFFFFFFF"



idInst  := DdeInitialize()



hServer := DdeCreateStringHandle(idInst, sServer)

hTopic  := DdeCreateStringHandle(idInst, sTopic )

hItem   := DdeCreateStringHandle(idInst, sItem  )



hConv := DdeConnect(idInst, hServer, hTopic)

hData := DdeClientTransaction(0x20B0, hConv, hItem)   ; XTYP_REQUEST

sData := DdeAccessData(hData)



DdeFreeStringHandle(idInst, hServer)

DdeFreeStringHandle(idInst, hTopic )

DdeFreeStringHandle(idInst, hItem  )



DdeUnaccessData(hData)

DdeFreeDataHandle(hData)

DdeDisconnect(hConv)

DdeUninitialize(idInst)



;-----------------------------------

Loop,   Parse,   sData, CSV 

   If   A_Index = 1 

      sURL   := A_LoopField 

   Else If   A_Index = 2 

      sTitle   := A_LoopField 



msgbox, %sURL%`n%sTitle%

return

;-----------------------------------



DdeInitialize(pCallback = 0, nFlags = 0)

{

   DllCall("DdeInitialize", "UintP", idInst, "Uint", pCallback, "Uint", nFlags, "Uint", 0)

   Return idInst

}



DdeUninitialize(idInst)

{

   Return DllCall("DdeUninitialize", "Uint", idInst)

}



DdeConnect(idInst, hServer, hTopic, pCC = 0)

{

   Return DllCall("DdeConnect", "Uint", idInst, "Uint", hServer, "Uint", hTopic, "Uint", pCC)

}



DdeDisconnect(hConv)

{

   Return DllCall("DdeDisconnect", "Uint", hConv)

}



DdeAccessData(hData)

{

   Return DllCall("DdeAccessData", "Uint", hData, "Uint", 0, "str")

}



DdeUnaccessData(hData)

{

   Return DllCall("DdeUnaccessData", "Uint", hData)

}



DdeFreeDataHandle(hData)

{

   Return DllCall("DdeFreeDataHandle", "Uint", hData)

}



DdeCreateStringHandle(idInst, sString, nCodePage = 1004)         ; CP_WINANSI = 1004

{

   Return DllCall("DdeCreateStringHandle", "Uint", idInst, "Uint", &sString, "int", nCodePage)

}



DdeFreeStringHandle(idInst, hString)

{

   Return DllCall("DdeFreeStringHandle", "Uint", idInst, "Uint", hString)

}



DdeClientTransaction(nType, hConv, hItem, sData = "", nFormat = 1, nTimeOut = 10000)   ; CF_TEXT = 1

{

   Return DllCall("DdeClientTransaction", "Uint", sData = "" ? 0 : &sData, "Uint", sData = "" ? 0 : StrLen(sData)+1, "Uint", hConv, "Uint", hItem, "Uint", nFormat, "Uint", nType, "Uint", nTimeOut, "UintP", nResult)

}



SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Works for me, you are probably using the Unicode version of AHK_L aren't you? If so the DLLCalls will probably fail see <!-- m -->https://ahknet.autoh... ... Compat.htm<!-- m --> (DLLCall) for info.

eon
  • Guests
  • Last active:
  • Joined: --
Yes, using latest AHK_L unicode. Any ideas on how to fix the DLLCall stuff? I see that one line of code mentions ANSI in the comment. But I don't understand the code enough to be able to fix it.

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Me neither :-( Perhaps someone will see this and post an updated version for AutoHotkey_L Unicode.

There are other alternatives:
1) MozRepl
<!-- m -->http://www.autohotke...pic.php?t=46974<!-- m -->
2) reading sessionstore.js
<!-- m -->http://www.autohotke... ... 115#316115<!-- m -->
3) sending keyboard shortcuts to focus on location bar and copy url (ctrl-l, ctrl-a, ctrl-c)

Wanand
  • Members
  • 1 posts
  • Last active: Jun 01 2011 08:47 PM
  • Joined: 26 May 2011
I got it working using DDEmessage. How ever if i have multiple IE applications, I may get the inactive window or get response from multiple windows.

Is there some way to start DDE with just the active window of IE. I believe we can get the window handle of Active winodw using command

WinGet whndl A

Please help me figure this out

maraskan_user
  • Members
  • 52 posts
  • Last active: Dec 08 2014 11:18 PM
  • Joined: 20 Jun 2008
This Code works with AHK_L. Be aware though, that the returned clipboard format is CF_TEXT, not CF_UNICODETEXT, since I couldn't get that to work.

FF_RetrievePageName()
   {
   DllCall("DdeInitializeW","UPtrP",idInst,"Uint",0,"Uint",0,"Uint",0)

   ; CP_WINANSI = 1004   CP_WINUNICODE = 1200
   hServer := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str","firefox","int",1200)
   hTopic  := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str","WWW_GetWindowInfo","int",1200)
   hItem   := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str","0xFFFFFFFF","int",1200)

   hConv := DllCall("DdeConnect","UPtr",idInst,"UPtr",hServer,"UPtr",hTopic,"Uint",0)
   ; CF_TEXT = 1      CF_UNICODETEXT = 13
   hData := DllCall("DdeClientTransaction","Uint",0,"Uint",0,"UPtr",hConv,"UPtr",hItem,"UInt",1,"Uint",0x20B0,"Uint",10000,"UPtrP",nResult)
   sData := DllCall("DdeAccessData","Uint",hData,"Uint",0,"str")

   DllCall("DdeFreeStringHandle","UPtr",idInst,"UPtr",hServer)
   DllCall("DdeFreeStringHandle","UPtr",idInst,"UPtr",hTopic)
   DllCall("DdeFreeStringHandle","UPtr",idInst,"UPtr",hItem)
   DllCall("DdeUnaccessData","UPtr",hData)
   DllCall("DdeFreeDataHandle","UPtr",hData)
   DllCall("DdeDisconnect","UPtr",hConv)
   DllCall("DdeUninitialize","UPtr",idInst)
   result:=StrGet(&sData,"cp0")
   return result
   }


Page title and page address are returned as CSV, which could be split up like this:

sData:=FF_RetrievePageName()
Loop,Parse,sData,CSV
   {
   If A_Index = 1
      sURL := A_LoopField
   Else If A_Index = 2
      sTitle := A_LoopField
   }



fedtegreve
  • Members
  • 80 posts
  • Last active: Jan 28 2014 02:26 PM
  • Joined: 18 Mar 2010
My confusion if over - I think :-)
I had a script made in AHK, then I installed AHK_L because of "something", then suddently my old script didn't work - because of AHK_L differs from AHK - off cause!

Well, I tried the above script, and it works for both explorer and firefox, when I change the DllCall, but is it possible to call the function regardsless with browser I use?
Something like this: (But this don't work!)
....
B=firefox
result:=FF_RetrievePageName(B)
return

FF_RetrievePageName(Browser)
   {
   DllCall("DdeInitializeW","UPtrP",idInst,"Uint",0,"Uint",0,"Uint",0)

   ; CP_WINANSI = 1004   CP_WINUNICODE = 1200
;   hServer := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str","iexplore","int",1200)
   hServer := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str",%Browser%,"int",1200)
   hTopic  := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str","WWW_GetWindowInfo","int",1200)
   hItem   := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str","0xFFFFFFFF","int",1200)
....

Thanks
Ben

  • Guests
  • Last active:
  • Joined: --
hServer := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str",Browser,"int",1200); remove the %%
:?: