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
not-logged-in-daonlyfreez
  • Guests
  • Last active:
  • Joined: --
As the author mentiones in the questions asked about his DLL on the homesite of the DLL, it should be not too difficult (from a programmers view) to add the contextual menu, and copy/paste etcet.

Even though the DLL apparently supports getting information about the elements on the page, the way to retreive this information seems too difficult for AutoHotkey (or for me :p ).

It is possible to workaround this with JavaScript cookie-write, but that is a quite ugly 'hack'...

Maybe some better coders around here could help adding those missing features, or we might even ask the author to help us...

The good thing about this DLL is that it is tiny. If adding the wanted extra's is not too difficult and would not lead to a bloated DLL, this still seems worth looking at.

AnnikHase
  • Members
  • 5 posts
  • Last active: Oct 15 2006 12:29 AM
  • Joined: 14 Oct 2006
very nice script =D
but i cant use the Tab keys to navigate trough the websites :/

Andrews
  • Guests
  • Last active:
  • Joined: --
Hi there, can you please tell me how to reference GUI 2 below, using the Send or Controlsend command? I had posted a similar question and think this can help me. I would like to be able to make a hotkey which sends characters to the browser on your GUI 2 :D

BEST REGARDS, Andrews

More elaborate example:

#NoEnv
SetBatchLines, -1
SetWinDelay, 0

; Load cwebpage.dll
cwebpageHandle := DllCall("LoadLibrary", "str", "cwebpage.dll")  

; Exit handler
OnExit, Cleanup

; Create menu
Menu, browserMenu, Add, Back
Menu, browserMenu, Add, Forward
Menu, browserMenu, Add, Refresh
Menu, browserMenu, Add, Stop
Menu, browserMenu, Add, Home
Menu, browserMenu, Add, Search

; Parent window
Gui, 1: Add, Button, y8 x0 w50 gBack, Back
Gui, 1: Add, Button, y8 x50 w50 gBack, Forward
Gui, 1: Add, Button, y8 x100 w50 gRefresh, Refresh
Gui, 1: Add, Button, y8 x150 w50 gStop, Stop
Gui, 1: Add, Button, y8 x200 w50 gHome, Home
Gui, 1: Add, Button, y8 x250 w50 gSearch, Search
Gui, 1: Add, Button, y370 x0 w150 gGoExample, Open example html
Gui, 1: Add, Button, y370 x150 w150 gGoAHKCHM, Open AHK chm
Gui, 1: Add, Button, y370 x300 w150 gGoAHKHome, Go to AHK homepage
Gui, 1: Show, w600 h400, Internet Explorer container in AHK with cwebpage.dll
WinGet, mainGuiHandle, ID, A

; Child window for Browser object
Gui, 2: Margin, 0, 0 
Gui, 2: +ToolWindow -Caption +Border
Gui, 2: Show, w590 h320
WinGet, browserGuiHandle, ID, A
; Set as child window to main gui
Gui, 2: +LastFound
DllCall("SetParent", "uint", WinExist(), "uint", mainGuiHandle)

; Create the Browser object
res := DLLCall("cwebpage\EmbedBrowserObject", "uint", browserGuiHandle)
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, Cleanup

; Position the Browser "control" in the Gui
WinMove, ahk_id %browserGuiHandle%, , 4, 40

; Load welcome html
Gosub, GoExample

; Monitor for right clicks on browser control
; WM_CONTEXTMENU ; 0x7B
OnMessage(0x7B, "Web_WM_CONTEXTMENU")

Return

; *** Routines:

; Browser control rightclick
Web_WM_CONTEXTMENU(wParam, lParam)
{
  Menu, browserMenu, Show
}
Return

; Browser control actions
Back:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 0)
Return

Forward:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 1)
Return

Home:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 2)
Return

Search:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 3)
Return

Refresh:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 4)
Return

Stop:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 5)
Return

; Examples

; Load welcome/example html
GoExample:
HTML2Load = 
(
<html><head><title>HTML Template</title></head><body>
Welcome to the <a href="http://www.codeproject.com/com/cwebpage.asp">
cwebpage.dll</a> browser control embedded into an AutoHotkey GUI
<ol><li>Pressing the <b>Open example html</b> button will load some example html
<li>Pressing the <b>Open AHK chm</b> button will load the startpage of the AutoHotkey chm helpfile locally on your computer.
<font color="green"><b>Cwebpage.dll can open and navigate in chm-files too!</b></font>
<li>Pressing the <b>Go to AHK homepage</b> button will load the AutoHotkey homepage online
<li>Pressing the <b>Open welcome html</b> button will reload this page</ol>
You can control the browser object with the top buttons and the context menu...

<font color="red"><b>Enjoy!</b></font>...
</body></html>
)
Gosub, LoadHTML
Return

GoAHKCHM:
URL2Load = its:%A_ProgramFiles%\AutoHotkey\AutoHotkey.chm::docs\AutoHotkey.htm
Gosub, LoadURL
Return

GoAHKHome:
URL2Load = http://www.autohotkey.com
Gosub, LoadURL
Return

; Load URL
LoadURL:
res := DLLCall("cwebpage\DisplayHTMLPage"
                  , "uint", browserGuiHandle
                  , "str", URL2Load)
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, Cleanup
URL2Load =
Return

; Load HTML
LoadHTML:
res := DLLCall("cwebpage\DisplayHTMLStr"
                  , "uint", browserGuiHandle
                  , "str", HTML2Load)
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, Cleanup
HTML2Load =
Return

; Cleanup and exit
Cleanup:
GuiEscape:
GuiClose:
DLLCall("cwebpage\UnEmbedBrowserObject", "uint", browserGuiHandle)
DllCall("FreeLibrary", "uint", cwebpageHandle)
ExitApp
Return

For your convenience, alternative download links:

cwebpage.dll
cwebpage_src.zip



not-logged-in-daonlyfreez
  • Guests
  • Last active:
  • Joined: --
Goyyah explained here, thanks, should work.

James
  • Guests
  • Last active:
  • Joined: --
; Browser control actions
Back:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 0)
Return

Forward:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 1)
Return

Home:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 2)
Return

Search:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 3)
Return

Refresh:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 4)
Return

Stop:
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 5)
Return


I like this script a lot, but these buttons don't seem to work. Am I missing something here?..... :(

not-logged-in-daonlyfreez
  • Guests
  • Last active:
  • Joined: --
Sorry, I'm out of town at the moment.

It should work is all I can say now, please keep experimenting.

James
  • Guests
  • Last active:
  • Joined: --

Sorry, I'm out of town at the moment.

It should work is all I can say now, please keep experimenting.


Cool, pls give it a whirl when you get back, I cannot get those buttons to work!.... I spent a dozen or so minutes... not sure if it is a reference or other issue :?: :) Thank you so much

Zed Gecko
  • Members
  • 149 posts
  • Last active:
  • Joined: 23 Sep 2006
And here is the little example from daonlyfreez EXTENDED TO RESIZE:


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)
return
;-----------End of Resize Part ---------

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


James
  • Guests
  • Last active:
  • Joined: --
Cool... I am trying to understand those dll calls posted by N-L-I-D, for the forward, backward buttons, etc.... Cool stuff! Still on my newbie learning curve here.... :)

moorpipe
  • Members
  • 19 posts
  • Last active: Jan 25 2007 04:05 AM
  • Joined: 04 Oct 2006
Very nice script (and browser object)!
However, if you assign html code to a variable and the code has references to external files like in:
<link type="text/css" rel="stylesheet" href="temp.css"></link>
or
<script type="text/javascript" src="test.js"></script>
the function DisplayHTMLStr doesn't seem to work.
Does anyone knows how to fix this?

Thanks!

moorpipe
  • Members
  • 19 posts
  • Last active: Jan 25 2007 04:05 AM
  • Joined: 04 Oct 2006
Nevermind! Got the answer from the cwebpage developer. You just have to fully qualify the external file references.
That's all there is to it.

Zed Gecko
  • Members
  • 149 posts
  • Last active:
  • Joined: 23 Sep 2006
I have a problem whith the embedded HTML-Control.

The HTML-Control does not accept Enter in a multi-line Textfield.
It is, for example, not possible to create a new line in the message body of a post in this forum.

Send, SendPlay, SendEvent have no effect either.
I tried with all the demo-scripts from above, too. So it´s not in my script.

Anyone know a Workaround?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
You control try pressing Control-Enter, Shift-Enter, or Alt-Enter to see if that produces a new line of text.

Zed Gecko
  • Members
  • 149 posts
  • Last active:
  • Joined: 23 Sep 2006
Nope,
none of these work.

Maybe it´s just my computers fault,
could someone confirm this behavior?

not-logged-in-daonlyfreez
  • Guests
  • Last active:
  • Joined: --
I found it, use Control + m 8)