Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Embed an HTML control in your own window ... [Dll]


  • Please log in to reply
112 replies to this topic
Zed Gecko
  • Members
  • 149 posts
  • Last active:
  • Joined: 23 Sep 2006
great,
you´re da man.

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Found another DLL: RichDisp.dll (~60k, Original site is down, license unclear)

Readme:

================================
FILES:
================================

>> RichDisp.DLL - Embeds either Mozilla ActiveX Control or Microsoft IE Browser Control.
NOTE: Mozilla ActiveX Control is available from:
http://www.iol.ie/~l...lla/mozilla.htm (free download only 4.5MB)

>> SimpleBrowser.EXE - Demonstrates the use of the DLL.
>> SimpleBrowser2.EXE - Demonstrates loading files from a DLL (Data.DLL) using the res:// protocol.
>> BrowserTV.EXE - Another, more cooler demonstration!
>> Data.DLL - Contains files used by SimpleBrowser2.EXE

================================
AVAILABLE FUNCTIONS:
================================

>> BOOL EmbedBrowser(HWND hwnd, int i)
Where hwnd is an handle to a control where you want the browser control to be embedded.
Where i is either 1 or 2:
> 1 Embeds Mozilla Browser Control. (Requires Mozilla ActiveX Control to be installed first)
> 2 Embeds Microsoft IE Browser Control. (Requires Microsoft Internet Expolrer to be installed first)

RETURNS true if browser control successfully embedded.

NOTE: If Mozilla Browser Control is not availble the Microsoft IE Browser Control will be embedded.

================================
AVAILABLE METHODS:
================================

>> UnEmbedBrowser()

>> ResizeBrowser(HWND hwnd)
Where hwnd is an handle to a control where the browser control is embedded.

>> DisplayPage(STRING url)
Where url is a string that contains the URL of a location to be displayed.

>> DoPageActionGoBack()
>> DoPageActionGoForward()
>> DoPageActionRefresh()
>> DoPageActionStop()


Combined with the Mozilla ActiveX control, this could provide a 'standalone browser control' for AHK. 8)

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
When using the code below, when attempting to resize the gui, the control does not change position and after the resize call, errorlevel is -4....any ideas?

FirstResize = 0 ;    Var helps to prevent the first call of "GuiSize:" to interact with the browserobject,
;                because "GuiSize:" is called upon creation of the Gui, and the browserobject isn´t there yet

hModule := DllCall("LoadLibrary", "str", "cwebpage.dll")

OnExit, Cleanup

Gui +Resize ; Make the Gui resizable
Gui, Show, w600 h400, test
WinGet, ourHWND, ID, A
res := DLLCall("cwebpage\EmbedBrowserObject", UInt, ourHWND)
;MsgBox % ErrorLevel
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, Cleanup

res := DLLCall("cwebpage\DisplayHTMLPage", UInt, ourHWND, Str, "http://www.autohotkey.com")
;MsgBox % ErrorLevel
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, Cleanup

 

return
;----------Browser resizing part -------
GuiSize:  ; Expand or shrink the BrowserObject in response to the user's resizing of the window.
if FirstResize = 0 ; this blocks the first call of "GuiSize:" upon creation of the Gui
{
   FirstResize = 1
   return
}

if A_EventInfo = 1  ; The window has been minimized.  No action needed.
   return
; Otherwise, the window has been resized or maximized. Resize the browserobject to match.

res := DLLCall("cwebpage\ResizeBrowser", UInt, ourHWND, UInt, A_GuiWidth, UInt, A_GuiHeight)
MsgBox % ErrorLevel
return
;-----------End of Resize Part ---------

Cleanup:
GuiClose:
DLLCall("cwebpage\UnEmbedBrowserObject", UInt, ourHWND)
DllCall("FreeLibrary", "UInt", hModule)
ExitApp
return


n-l-i-d
  • Guests
  • Last active:
  • Joined: --
The script works for me, I get errorlevel 0 on any resize. What IE version do you use?

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
IE 7 .... guess it partially works with IE7 anyway...

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Hmm, ok. Could you try one of the scripts from this posting then? AHKOnlineVid - cwebpage.dll script

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006

Found another DLL: RichDisp.dll



This one gives a Message box and attempts to start the guy's website (which is down)

It does resize in with IE7 though...

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Hmm, ok, forget about the RichDisp.dll, it indeed does show an annoying message box (built in), and I cannot get the rest of it to work either. :cry:

Well, apparently it is trialware anyway, and the author's page is down...

I'll stick with cwebpage.dll (for now).

@ahklerner and others with Internet Explorer 7: Could you please be as specific as possible about the incompatibilities? Thank you.

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
I was receiving errorlevel -4.....after some investigation (with dll export viewer) I determined that my copy of cwebpage.dll only exported 4 functions...none of which were ResizeBrowser....I downloaded the dll again and all was good....I did not find anything wrong( will be testing more in the next few days though)

AGU
  • Guests
  • Last active:
  • Joined: --
After getting a hint about this from majkinetor I read the thread and gave it a test. I downloaded the zip file and made some tests.

I'm running W2k SP4 IE6.0. In short words.

The 'resize' script shows the same errors as ahklerner described. The Gui resizes but not the HTML control. It always stays in the top left corner.

The upper buttons don't work. Pressing them doesn't do anything. So I compared the specified zip file to the one linked in the original article and found out that the cwebpage.dll inside the zip file here is 20kb.
The .dll in the original file on the homepage is 28kb.

When using the original file everything works. :) Buttons work and HTMLcontrol is resizing. So I would suggest to fix the link on the first page and link the correct one. Or am I missing s.th important?
_______________________
Cheers
AGU

daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
For all you that want to be able to use JavaScript to control items on a webpage: I present you the next level in my experiments. :p

Since the cwebpage.dll does not offer an easy way to get information about the elements on the webpage, I have been tinkering with a workaround.

Please try it. It's very preliminary, but shows the concept works, that is: Use cookies as a means to communicate with AHK. This is better than the JavaScript clipboard option, since that one might be disabled on the user's system.

Since I was experimenting with JavaScript to get this done, I decided to build something with it that returns the info on the webpage.

So: This script inserts the HTML/JS DOM retreived on mouseover from the webpage into the AHK Gui. It does so by injecting a JavaScript into the current page that adds a JavaScript event handler, that traverses the DOM on call, and writes values to a cookie. This cookie is read regularly by the script, and acted upon accordingly.

It turned out very nice 8)

Thanks go out to Titan for the TreeView parsing routines 8)

Remarks:

- This works on any webpage (frames might give problems, needs workaround), it does not matter that the JavaScript is local. :p

- The DOM values returned are from the actual JavaScript DOM, so - active content - means: even if the webpage changes, or is hidden behind some cryptic URL, you'd still be able to read the values... Something URLDownloadToFile could never do. This hooks into the active webpage.

- Still very slow on big pages, due to the heavy JavaScripting, and not yet optimized (values bigger than 4000 characters - the max a cookie can handle - are not handled yet for example)

Change the following part of the code if you want to load another site:

Around line 150
; --- Load default 
cw_URL2Load = [color=red]http://www.autohotkey.com/[/color]
Gosub, cw_LoadURL

Code is too much to post. Download all you need.

Load the script, wait for the webpage to be loaded (default is AHK homepage), and press the 'Start Hooking' button. Now if you hover over the webpage, the Info Window should update...

Posted Image
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

BoBo
  • Guests
  • Last active:
  • Joined: --
Internet Explorer Script Error
Line:84
Char:4
Error:Object expected
Code:0
URL:http://www.autohotkey.com

XPPro/SP2/IE6

BoBo
  • Guests
  • Last active:
  • Joined: --
The cwebpage.dll window doesn't provide a horizontal scrollbar from scratch. If maximized, that scrollbar appears but the area to display the webpage itself doesn't resize/maximze too.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Screenshot looks nice

Good work.

Thx for sharing.
Posted Image

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
@BoBo: Did you use the cwebpage.dll provided in the download?

I'm on XP SP2 with IE 6 (6.0.2900.2180.xpsp.051011-1528) too.

Internet Explorer Script Error
Line:84
Char:4
Error:Object expected
Code:0
URL:http://www.autohotkey.com


This I cannot reproduce either. Do you have any toolbars installed that influence the current webpage?

Can anybody with IE7 confirm or deny compatibility?