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
Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
As firefox uses non-standard controls, there are few elegant ways to retrieve the URL from the address bar.
So, I tried to get it using DDE (Message) and managed it to work.

I tested it only with Firefox 2.0.0.3 in XPSP2.
But, it should work with IE and Opera too, as they also support DDE(ML).

DOWNLOAD DDE.ahk.

Arnoud
  • Members
  • 15 posts
  • Last active: Oct 22 2007 02:17 PM
  • Joined: 23 Mar 2007
Works on Opera 9.20 WinXP SP2

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Works in Win 2000 SP4

FireFox 2.0.0.3
Opera 9.20


Thanks ..

Any way to copy the Statusbar text to Clipboard ?
I have a script to automate image downloads in Google Image search
In IE, I hover the mouse over the link and press a hotkey. The URL will be fetched from the statusbar and processed before being added to my download manager. It would be nice If I can do it firefox.

:)

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
It only gives the URL of the last open Firefox window. Is there anyway to get all URLs of windows belonging to the same process?

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Any way to copy the Statusbar text to Clipboard ?

I don't think there is a (dde) topic related with the statusbar. You may take a look at this page.
<!-- m -->http://support.micro...com/kb/q160957/<!-- m -->

Looks like not all topics here are supported by firefox.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

It only gives the URL of the last open Firefox window. Is there anyway to get all URLs of windows belonging to the same process?

I think it's the last 'active' one to be precise.
The best way I can think of atm is that cycling through the opened firefox windows, then activating each and retrieving the URL.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I don't think there is a (dde) topic related with the statusbar. You may take a look at this page.
<!-- m -->http://support.micro...com/kb/q160957/<!-- m -->


Thanks for the Link. :)

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
This one has been frustrating me for MONTHS!!

thanks!



here is my NOT WORKING & I DON'T KNOW WHY code (from <!-- m -->http://www.autohotke...topic17326.html<!-- m --> )

; trying to figure out the DLLCALL equivalence...
;
; 

LPDWORD := "UIntP"
PFNCALLBACK := "UInt"     ; or should that be Int ?
DWORD  := "UInt"
HSZ := "UInt"   ; is that right ?
UINTc := "UShort"  ;   Can this be right ?  is it UInt ?? Int ??
NULL := "Int"
LPTSTR := "str"
INTc :=  "short"   ; maybe Int ???    SEE BELOW FOR MS DEFS...


APPCLASS_STANDARD :=  0
CP_WINANSI   := 1004
CF_TEXT := 1
XTYP_EXECUTE  = 0x0050 
XTYP_POKE   = 0x0090
XTYP_REQUEST    = 0x00B0

VarSetCapacity(ddeServer, 256,0)
VarSetCapacity(ddeDataE, 256,0)
VarSetCapacity(ddeData,33000)
VarSetCapacity(ReturnV1,33000)

ddeServer =  excel
ddeTopic =
ddeData = [formula(\"SWI-Prolog\",\"r1c1\")]


pidInst := 0


if ( DllCall("DdeInitialize"
   , LPDWORD,  pidInst
   , PFNCALLBACK, 0
   , DWORD, APPCLASS_STANDARD
   , DWORD, 0 ) )
   
   msgbox ERROR with DDEInitialze !

   
HddeServer := DllCall("DdeCreateStringHandle"
         , DWORD,  pidInst
         , LPTSTR,  ddeServer
         , INTc,  CP_WINANSI )
         
HddeTopic := DllCall("DdeCreateStringHandle"
         , DWORD,  pidInst
         , LPTSTR,  ddeTopic
         , INTc,  CP_WINANSI )

ddeDataE =
HddeDataE := DllCall("DdeCreateStringHandle"
         , DWORD,  pidInst
         , LPTSTR,  ddeDataE
         , INTc,  CP_WINANSI )


HddeConversation := DllCall("DdeConnect"
            , DWORD,  pidInst
            , HSZ, HddeServer
            , HSZ, HddeTopic
            , Null, 0 )


ddeData =  [formula(\"SWI-Prolog\",\"r1c1\")]
BddeData := StrLen(ddeData) + 1
ddeResult  = 0


;
; THIS IS NOT SEEMING TO WORK
;
ReturnV1 := DllCall("DdeClientTransaction"
         , STR, ddeData
         , DWORD, BddeData
         , Uintc,  HddeConversation
         , DWORD , HddeDataE
         , UINTc, CF_TEXT  ; NOTE: should be ZERO with execute
         , UINTc, XTYP_EXECUTE
         , DWORD, 1000
         , LPDWORD, ddeResult ) ;
         

compare := 0x4000 + 0
msgbox 32,, % DllCall("DdeGetLastError",      DWORD,  idInst)  " :"  compare
   
   
exitapp



likely you can figure out what i've missed out on ??


also had an idea about the callback....


made a very simple machine code 'do nothing' and return ... and put it into a string... then used the strings address as callback address...

but seems this all was unnecessary....

only SERVER seems to need callback...


would very much like your help to figure out...


a full fledged DDE tool would be nice for AHK...
Joyce Jamce

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

here is my NOT WORKING & I DON'T KNOW WHY code


Looks like some of the variables are defined wrongly.

XCLASS_DATA  := 0x2000
XCLASS_FLAGS := 0x4000
XTYP_EXECUTE := 0x0050 | XCLASS_FLAGS
XTYP_POKE    := 0x0090 | XCLASS_FLAGS
XTYP_REQUEST := 0x00B0 | XCLASS_DATA

BTW, as far as I can see, there is no argument with (U)INTc types there, but it won't affect the result in this case.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
I updated the script.
Now, there exist two versions: DDEMessage & DDEML.
And, it'll finally work with iexplore too.

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
@Sean,

somehow, the 'psychology' of DDE is evading my grasp...



poke, and Execute (for eg. word & excell control...) seem easy enough... but... just not working for me...

likely you can do better!


<!-- m -->http://msdn2.microso...y/ms648995.aspx<!-- m -->



my... UGGGGG... not seeming to want to work for me code!!!

Command :="[command goes here]"

CommandL := strlen(Command) +1
HCommand := DllCall("GlobalAlloc"
	, UINT, 0x0000 ;  0x0040 ??
	, UINT, CommandL) ; ie. size
	

if HCommand
	DllCall("MoveMemory"
		, UINT,  HCommand
		, UINT, &Command 
		, UINT, CommandL )
Else
	msgbox "error no HCommand handle from teh global allocation"


PostMessage, WM_DDE_EXECUTE, ClientHwnd, HCommand,, ahk_id %ServerHwnd%


and... please...

what am I missing here ???

my dll execute is a flop too!!!! uggggggg!!



DLL_Execute(Item, nTimeOut = 10000, nFormat = 0)   
{
		Global idInst, hConv,ddeResult

 Return DllCall("DdeClientTransaction" , "UintP", Item, "Uint", strlen(Item) + 1 , "Uint" ,  hConv, "Uint", 0, "Uint", nFormat ,"Uint ", 0x2050, "Uint", nTimeOut, "Uint" , ddeResult  ) 

}

Joyce Jamce

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

poke, and Execute (for eg. word & excell control...)

With Execute or Poke, unlike in Request, you can't neglect the first/second arguments in DdeClientTransaction.

DllCall("DdeClientTransaction", "Uint", &Command, "Uint", StrLen(Command)+1, "Uint", hConv, "Uint", hItem, "Uint", 1, "Uint", XTYP_EXECUTE, "Uint", 10000, "UintP", nResult)
BTW, I don't think you have to do GlobalAlloc yourself with DDE, but, I must admit I haven't tried myself.
If it really needs GlobalAlloc or alike, you may better use DdeCreateDataHandle instead (:at least with Poke).

hData := DllCall("DdeCreateDataHandle", ...)
DllCall("DdeClientTransaction", "Uint", hData, "Uint", -1, "Uint", hConv, "Uint", hItem, "Uint", 1, "Uint", XTYP_POKE, "Uint", 10000, "UintP", nResult)


Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
re:

DllCall("DdeClientTransaction", "Uint", &Command, "Uint", StrLen(Command)+1, "Uint", hConv, "Uint", hItem, "Uint", 1, "Uint", XTYP_EXECUTE, "Uint", 10000, "UintP", nResult)



i think on the execute... the

"Uint", hConv, "Uint", hItem, "Uint", 1,



is ignored...


i think... so.... actually accord MS...


DllCall("DdeClientTransaction", "Uint", &Command, "Uint", StrLen(Command)+1, "Uint", hConv, "Uint", 0, "Uint", 0, "Uint", XTYP_EXECUTE, "Uint", 10000, "UintP", nResult)


perhaps ??




ps: Sean... thanks... thanks... and more thanks... for the help, vision & enlightenment.... this is something that has alluded me in AHK for MONTHS!!!!!
Joyce Jamce

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

BTW, I don't think you have to do GlobalAlloc yourself with DDE

OK, I overlooked you used DDE Messages.
Then, it requires GlobalAlloc according to the documentation.

At a glance with your code with GlobalAlloc, looks like you allocate it as GMEM_FIXED (0x0000), but may better use GMEM_MOVEABLE (0x0002) instead.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

"Uint", hConv, "Uint", hItem, "Uint", 1,

is ignored...
DllCall("DdeClientTransaction", "Uint", &Command, "Uint", StrLen(Command)+1, "Uint", hConv, "Uint", 0, "Uint", 0, "Uint", XTYP_EXECUTE, "Uint", 10000, "UintP", nResult)

You're right. hItem & nFormat should be set to 0 with Execute.