Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Is there a way to load HTML fm memory into IE Control ?


  • Please log in to reply
19 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
<html>
<body bgcolor="#FFFFFF">
Hello World 
</body>
</html>

Can some HTML ( like above, created at run time ) be loaded into AHK-IE control without being written to a .HTML file ?

:roll:

  • Guests
  • Last active:
  • Joined: --
IE_LoadHTML(pwb, html)


SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Would it work if HTML has file references relative to the working directory ?

:roll:

  • Guests
  • Last active:
  • Joined: --

Would it work if HTML has file references relative to the working directory ?

I don't know until trying it. And be aware that IE_LoadHTML() has length limit for HTML constrained by about:. If the HTML is long, better create an empty document by about:blank or alike and write to it the HTML.

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

If the HTML is long, better create an empty document by about:blank or alike and write to it the HTML.


Can you please explain this part. :roll:

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Basically,
IE_LoadURL(ie, "about:blank")
ieDoc := IE_Document(ie)
COM_Invoke(ieDoc,"write",html)
COM_Invoke(ieDoc,"close")
This also works with document objects you create:
doc := COM_CreateObject("htmlfile")
COM_Invoke(doc,"write",html)
COM_Invoke(doc,"close")
; ...access DOM properties here...
JavaScript won't work in this case, though.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Thanks Lexikos. Does this method has any limit ?
I want to try creating htm based ebook like:
eBook v1.0 :: a Collection of Basic Tutorials [ text only ] posted by SKAN
:)

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Relative paths won't work. There's no length limit, afaik.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Thanks again for the example code. It works fine :)

Relative paths won't work.


:(

The following works, but I am not comfortable. I do not know html much and I just create them with Dreamweaver 3.

#SingleInstance, Force
SetWorkingDir %A_ScriptDir%  
Gui +LastFound
hWnd := WinExist()


[color=red]img1[/color]=file://c://img.jpg

html=
(
<html>
<body bgcolor="#FFFFFF">
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <div align="center">Hello World </div>
    </td>
  </tr>
  <tr>
    <td>
      <div align="center"><img src="[color=red]%Img1%[/color]" width="160" height="160"></div>
    </td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>
<p>  </p>
</body>
</html>
)

IE_Init()
iE := IE_Add(hWnd, 5, 5, 630, 460 )
IE_LoadURL(ie, "about:blank") 
ieDoc := IE_Document(ie) 
COM_Invoke(ieDoc,"write",html) 
COM_Invoke(ieDoc,"close") 

Gui,Show, w640 h480, Load HTML fm MEM
Return

GuiEscape:
GuiClose:
 ExitApp

Can you suggest me any different but more reliable method ?

:)

Cliptos34
  • Members
  • 15 posts
  • Last active: May 26 2009 03:08 AM
  • Joined: 03 Feb 2008
Hi Skan, my preferred method is to actually use Notepad to construct HTML pages. The reason for this is because third-party developer apps such as Dreamweaver, Frontpage and others, do not adequately parse HTML code that is very compatible with a broad spectrum of Web Browsers.


The best approach is to actually make the HTML using the best way you can, by hand using w3.org standards, and then test test test across IE, FireFox and others (smaller players) like Opera, and Mac Browser.

I hope this helps and thank you for your time :)

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
You might be able to 'fake' relative paths by adding A_ScriptDirectory and the relative file path...?

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

to 'fake' relative paths


How reliable would it be ? .. As you can see in my above code, I using %img1% in html . Is there a chance of clash .. means .. will html contain other % symbols ?

BTW, did you see my implemention of your suggestions in ebook ?

:)

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
I did see that you've made those updates, but haven't had the chance to try it yet... It looked very slick though 8)

I'm very weak with HTML but as long as you are writing your own HTML code with the script, you should be OK as long as you escape any literal % characters. Mine are hard coded but here are some examples that have worked in a production environment for me:
results_table_header=%results_table_footer%
	(Ltrim
	
	<div style="text-align: left;"><big><big><span style="font-weight: bold; font-family:arial"><a href="%Master_Doc_Location%\%FileDir%\index_files.htm">%FileDir%</a></span></big></big></div>
	<table align="center" [color=red]width="100`%"[/color] border="0" cellspacing="2" cellpadding="2">
	<tbody style="font-family:arial; font-size:14">
	<tr bgcolor="%TH_c%">
	<th align="left" width="150">Document</th>
	<th align="left" "width=90`%">Title</th>
	</tr>
	)
;Blah blah blah
search_html=
(
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"http-equiv="content-type">
<title>Search - "%Searchterm%"</title>
</head>
<body style= Background="%BG_c%" alink="FF0000" link="%TXT_c%" vlink="%TXT_c%">
<div style="text-align: center;font-family:arial"><big><big><big><span style="font-weight: bold;color=%TXT_c%">Search Results<br></span></big></big></big></div>
<div style="text-align: center;font-family:arial;color=%TXT_c%"><big><small>You searched for "<span style="color: rgb(255, 0, 0);font-weight: bold;">%Searchterm%</span>"</small></big><div style="text-align: center;font-family:arial;color=%TXT_c%"><big><small>in "<span style="color: rgb(255, 0, 0);font-weight: bold;">%Restriction%</span>"</small></big><br>
<a href="%LibraryPath%\index_files.htm">Home</a></div><br>
%results_table%
</tbody>
</table>
</div>
Search executed in %Search_Time% ms.
</body>
</html>
)


Cliptos34
  • Members
  • 15 posts
  • Last active: May 26 2009 03:08 AM
  • Joined: 03 Feb 2008
Am I confused with the above code, or is it just a Jedi-Mind trick or? Just curious... I have lots of experience. :D I just want to help and feel wanted & helpful, and building in and out.

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
If you're talking about mine, it's just a couple of HTML variables I used in a much larger script and are out of context... If you were referring to SKAN's code, yes, he is a Jedi.