
Firefox, mozilla based browser URL
Read Browser URL (IE, Firefox,Opera,Chrome)
My Code
My Code
Code: Select all
#CHILDID_SELF = 0
#WINEVENT_OUTOFCONTEXT = 0
#WINEVENT_SKIPOWNPROCESS = $2
#EVENT_OBJECT_FOCUS = $8005
#EVENT_OBJECT_VALUECHANGE = $800E
#ROLE_SYSTEM_DOCUMENT = $F
#ROLE_SYSTEM_PANE = $10
#ROLE_SYSTEM_TEXT = $2A
;################
; Convert to BSTR
;################
; Thanks to freak for this one
Procedure.l ASCIItoBSTR(asciiString$)
Protected result = 0
CompilerIf #PB_Compiler_Unicode
result = SysAllocString_(@asciiString$)
CompilerElse
Protected *buff = AllocateMemory(Len(asciiString$)*2 + 2)
If *buff
PokeS(*buff, asciiString$, -1, #PB_Unicode)
result = SysAllocString_(*buff)
FreeMemory(*buff)
EndIf
CompilerEndIf
ProcedureReturn result
EndProcedure
;################
; Set Hook
;################
Procedure WinEventFunc(HookHandle.l, hEvent.l, hwnd.l, idObject.l, idChild.l, idEventThread.l, dwmsEventTime.l)
Protected *objectIa.IAccessible
Static previousUrl$
Select hEvent
Case #EVENT_OBJECT_FOCUS, #EVENT_OBJECT_VALUECHANGE
className$ = Space(256)
GetClassName_(hwnd, @className$, 256)
If className$ = "MozillaWindowClass" Or className$ = "Internet Explorer_Server" Or className$ = "OpWindow" Or className$ = "Chrome_AutocompleteEditView" Or className$ = "Chrome_XPFrame"
If CallFunction(0, "AccessibleObjectFromEvent", hwnd, idObject, idChild, @*objectIa, @v.VARIANT) = #S_OK
v.VARIANT\vt = #VT_I4
v\lVal = #CHILDID_SELF
If *objectIa\get_accRole(v, @v) = #S_OK
If v\lVal = #ROLE_SYSTEM_PANE Or v\lVal = #ROLE_SYSTEM_DOCUMENT Or v\lVal = #ROLE_SYSTEM_TEXT
v\vt = #VT_I4
v\lVal = #CHILDID_SELF
url$ = Space(#MAX_PATH)
bstr = ASCIItoBSTR(Space(#MAX_PATH))
If *objectIa\get_accValue(v, @bstr) = #S_OK
len = WideCharToMultiByte_(#CP_ACP, 0, bstr, -1, 0, 0, 0, 0)
url$ = Space(len)
WideCharToMultiByte_(#CP_ACP, 0, bstr, -1, @url$, len, 0, 0)
If previousUrl$ <> url$ And url$ <> ""
AddGadgetItem(1, -1, url$)
previousUrl$ = url$
EndIf
EndIf
EndIf
*objectIa\Release()
EndIf
EndIf
EndIf
EndSelect
EndProcedure
;################
; Main Window
;################
If OpenWindow(0, 0, 0, 500, 400, "Read Browser URL", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
CoInitialize_(0);
hdll = OpenLibrary(0, "Oleacc.dll")
EditorGadget(1, 10, 15, 480, 380)
;...Set event hook
eHook = SetWinEventHook_(#EVENT_OBJECT_FOCUS, #EVENT_OBJECT_VALUECHANGE, #Null, @WinEventFunc(), 0, 0, #WINEVENT_OUTOFCONTEXT | #WINEVENT_SKIPOWNPROCESS)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
;...Cleanup
CoUninitialize_()
If eHook
UnhookWinEvent_(eHook)
EndIf
If hdll
CloseLibrary(0)
EndIf
EndIf
End
And how can i Hook Url?
And How Hook www.google.com or Urls List and then do something?
And How Hook www.google.com or Urls List and then do something?
Re: Firefox, mozilla based browser URL
I'm sorry to resurrect an old thread but I'm trying to turn Besko's code in to a DLL that can have a hwnd passed to it. What am I doing wrong?
DLL Code:
Test program:
DLL Code:
Code: Select all
#CHILDID_SELF = 0
#WINEVENT_OUTOFCONTEXT = 0
#WINEVENT_SKIPOWNPROCESS = $2
#EVENT_OBJECT_FOCUS = $8005
#EVENT_OBJECT_VALUECHANGE = $800E
#ROLE_SYSTEM_DOCUMENT = $F
#ROLE_SYSTEM_PANE = $10
#ROLE_SYSTEM_TEXT = $2A
Global globurl$
;################
; Convert to BSTR
;################
; Thanks to freak for this one
Procedure.l ASCIItoBSTR(asciiString$)
Protected result = 0
CompilerIf #PB_Compiler_Unicode
result = SysAllocString_(@asciiString$)
CompilerElse
Protected *buff = AllocateMemory(Len(asciiString$)*2 + 2)
If *buff
PokeS(*buff, asciiString$, -1, #PB_Unicode)
result = SysAllocString_(*buff)
FreeMemory(*buff)
EndIf
CompilerEndIf
ProcedureReturn result
EndProcedure
;################
; Set Hook
;################
Procedure WinEventFunc(hwnd.l)
Protected *objectIa.IAccessible
Static previousUrl$
className$ = Space(256)
GetClassName_(hwnd, @className$, 256)
If className$ = "MozillaWindowClass" Or className$ = "Internet Explorer_Server" Or className$ = "OpWindow" Or className$ = "Chrome_AutocompleteEditView" Or className$ = "Chrome_XPFrame"
If CallFunction(0, "AccessibleObjectFromEvent", hwnd, idObject, idChild, @*objectIa, @v.VARIANT) = #S_OK
v.VARIANT\vt = #VT_I4
v\lVal = #CHILDID_SELF
If *objectIa\get_accRole(v, @v) = #S_OK
If v\lVal = #ROLE_SYSTEM_PANE Or v\lVal = #ROLE_SYSTEM_DOCUMENT Or v\lVal = #ROLE_SYSTEM_TEXT
v\vt = #VT_I4
v\lVal = #CHILDID_SELF
url$ = Space(#MAX_PATH)
bstr = ASCIItoBSTR(Space(#MAX_PATH))
If *objectIa\get_accValue(v, @bstr) = #S_OK
len = WideCharToMultiByte_(#CP_ACP, 0, bstr, -1, 0, 0, 0, 0)
url$ = Space(len)
WideCharToMultiByte_(#CP_ACP, 0, bstr, -1, @url$, len, 0, 0)
If url$ <> ""
globurl$ = url$
EndIf
EndIf
EndIf
*objectIa\Release()
EndIf
EndIf
EndIf
EndProcedure
;################
; Main Procedure
;################
ProcedureDLL.s getURL(hwnd.l)
CoInitialize_(0);
hdll = OpenLibrary(0, "Oleacc.dll")
;...Set event hook
WinEventFunc(hwnd)
Delay(2000)
;...Cleanup
CoUninitialize_()
If hdll
CloseLibrary(0)
EndIf
ProcedureReturn globurl$
EndProcedure
Code: Select all
result = OpenLibrary(0, "getURL.dll")
url.s = PeekS(CallFunction(0, "getURL",66556))
Debug url
CloseLibrary(0)
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re:
Doesn't work with Opera or Chrome anymore.besko wrote: Read Browser URL (IE, Firefox,Opera,Chrome)

Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: Re:
I did not try the code but Opera's window class is "OperaWindowClass" iirc.MachineCode wrote:Doesn't work with Opera or Chrome anymore.besko wrote: Read Browser URL (IE, Firefox,Opera,Chrome)Anyone know how to update it? I've tried various class names ("Chrome_OmniboxView") but they don't help.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Re:
Yeah, I tried that one too (I didn't specifically name it in my post above, sorry). It doesn't work.gnozal wrote:I did not try the code but Opera's window class is "OperaWindowClass" iirc.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: Firefox, mozilla based browser URL
Did anyone find the new class names for Chrome and Opera? How can somebody find them?
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: Firefox, mozilla based browser URL
I found them. The new classes for Chrome are "Chrome_OmniboxView" and "Chrome_WidgetWin_0".
What change should I do to take the title of the page?
What change should I do to take the title of the page?
- ultralazor
- Enthusiast
- Posts: 186
- Joined: Sun Jun 27, 2010 9:00 am
Re: Firefox, mozilla based browser URL
find out the symbol they use in their heap struct for the active DOM URI.. Works on all platforms, you just have to get past page and heap security stuff. The only reliable method with modern browsers is integration or logging thread-input..
FYI: Even the founders of Mozilla say FF and TB source are based on poorly designed and bloated code. XUL or whatever that is they use is why. Writing advanced plugins is a nightmare cause of no documentation and way too much obscure class references and scopes..
FYI: Even the founders of Mozilla say FF and TB source are based on poorly designed and bloated code. XUL or whatever that is they use is why. Writing advanced plugins is a nightmare cause of no documentation and way too much obscure class references and scopes..
so many ideas so little time..
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: Firefox, mozilla based browser URL
There is a program, KidLogger, that does this job, it is open source but I cannot find where it does the job I need. Maybe the code that does my job is not included. This program is not a plugin or anything like that, it is a simple program.
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: Firefox, mozilla based browser URL
The solution was simple, GetWindowText_() API. I know, this is not cross platform but it gets the job done!
Code: Select all
Caption.s = Space(#MAX_PATH)
GetWindowText_(hwnd,@Caption, #MAX_PATH)
- ultralazor
- Enthusiast
- Posts: 186
- Joined: Sun Jun 27, 2010 9:00 am
Re: Firefox, mozilla based browser URL
kidlogger does what cheatengine and other tools do, crawl the heap, except it probably looks for symbols. The adress is mapped different each runtime. Either that or it logs thread-input to avoid anti-virus products.
Getting window caption yields you no url.. No browsers put the url there but instead the title of the DOM if there is one.
Getting window caption yields you no url.. No browsers put the url there but instead the title of the DOM if there is one.
so many ideas so little time..
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: Firefox, mozilla based browser URL
No my friend. By taking the window caption I want the page title. For example the caption of this page is "PureBasic Forum Post a reply". That's what I want to take from GetWindowText_().ultralazor wrote:Getting window caption yields you no url.. No browsers put the url there but instead the title of the DOM if there is one.