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
Retrieve AddressBar of Firefox through DDE Message
Started by
Sean
, May 13 2007 11:48 AM
55 replies to this topic
#46
-
Posted 14 December 2010 - 04:23 PM
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 )?
#47
-
Posted 07 April 2011 - 08:19 PM
It does work for me with FF4 so post the code you used.
#48
-
Posted 07 April 2011 - 08:54 PM
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) }
#49
-
Posted 07 April 2011 - 09:09 PM
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.
#50
-
Posted 07 April 2011 - 09:15 PM
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.
#51
-
Posted 07 April 2011 - 09:36 PM
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)
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)
#52
-
Posted 08 April 2011 - 02:00 PM
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
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
#53
-
Posted 31 May 2011 - 06:52 PM
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.
Page title and page address are returned as CSV, which could be split up like this:
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 }
#54
-
Posted 01 July 2011 - 08:43 PM
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!)
Thanks
Ben
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
#55
-
Posted 27 January 2012 - 11:21 AM
hServer := DllCall("DdeCreateStringHandleW","UPtr",idInst,"Str",Browser,"int",1200); remove the %%:?:
#56
-
Posted 27 January 2012 - 06:59 PM