It is currently Sat May 25, 2013 3:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 70 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: Sat May 10, 2008 4:57 am 
Offline
New User
New User

Joined: Sat May 10, 2008 4:16 am
Posts: 1
Location: Philippines
is there any c# to this code. it would really be helpful.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 19, 2008 9:23 am 
Offline
User
User

Joined: Tue May 16, 2006 6:46 am
Posts: 76
Location: Germany
Pretty good piece of code - thanks for sharing it.

Is there a way to do it without opening a window? :?:
Greetings Mike

_________________
Greetings to all the folks back home in the States...
PB4.2 Windows XP SP3


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 6:37 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 1575
Location: Berlin, Germany
On SourceForge there is a project called URLInject. Unfortunately it is abandoned, but the source code (Pascal) might be interesting for you guys anyway.

Regards, Little John

_________________
Math problems?
Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 2:43 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6561
@Sparkie: Your excellent code no longer works with the new Firefox 3. :(
Any chance you can revisit it soon and make it both 2 and 3 compatible? ;)
Or even just for Firefox 3 would be great. Thanks, and I hope you can do it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 5:19 pm 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
BigJack and PB, I'll take a look when I get home tonight. :)

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 3:07 am 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
As for the Firefox 3 issue, I'm not sure what's going wrong. get_accName (which is the Title of the page) is working fine but get_accValue (the url of the page) is stumbling for some reason. I will continue to look for a fix.

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 5:11 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6561
Just to confirm: you're using the normal Firefox 3, and not Firefox Portable or
any other non-official derivative of it?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 12:41 pm 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
That is correct PB

Quote:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 26, 2008 3:54 pm 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
See if this works for you and Firefox 3...

Code:
; Code          : Read Browser URL (IE, Firefox)
; Author(s)     : Sparkie, netmaestro
; Other credits : PB, rsts
; Rel Date      : December 21, 2006 7:41 PM
; Update        : July 26, 2008 10:49 AM
;                 -fix for Firefox 3
; Target OS     : Windows only
; Target PB     : 4.x
;...Code converted from VB to PB
;...Feel free to clean it up and use as you wish.
; ************************************************

;################
; Constants
;################
#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"
        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

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Last edited by Sparkie on Sat Aug 02, 2008 12:33 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 27, 2008 2:13 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6561
> See if this works for you and Firefox 3

Hi Sparkie, it seems to work great so far, so thanks for that! :)

One caveat: if Firefox is running BEFORE you run your code, then it doesn't get
the current URL. In the big scheme of things that won't matter to me because
my app is launched at bootup before Firefox, but if you can make it get the
URL of an already-running Firefox, then it would be 100% perfect. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 27, 2008 1:22 pm 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
Your request should be no problem PB. I'll get on it later today. :)

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 27, 2008 8:28 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Feb 24, 2004 3:43 am
Posts: 540
Location: Israel
Sparkie, damn you are good! :lol:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 02, 2008 8:18 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 6561
@Sparkie: I was looking closer at your code and saw this:

*value = AllocateMemory(#MAX_PATH *2 + 2)

It doesn't seem to be needed? (The code works fine without it).
And there's no FreeMemory command for it? Is it a leftover? :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 02, 2008 12:37 pm 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
Yes PB, it's a remnant from earlier code. I edited and removed that line. Thanks for spotting that one.

I am still working on getting the URL on startup. It turned out not to be as easy as I had hoped. :evil:

@Pantcho!!: Thanks for the kind words. :)

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2008 5:16 pm 
Offline
User
User

Joined: Tue Oct 28, 2008 1:08 pm
Posts: 42
Sparkie
Do you have code for Opera and Google Chrome?




And how can i Hook Url?
and do something when i Hook www.google.com?



tnx for help :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 70 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye