★☆GetHTMLFragment()★☆

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

★☆GetHTMLFragment()★☆

27 Feb 2017, 13:39

Working on a HTML Clipboard Saver script that allows you to copy any text etc from a browser window and save it as a local HTML file.
I'm currently at the stage where I can successfully grab the HTML Markup on Win7 and XP,
but I was wondering if I can could get confirmation that it works on different systems, browsers etc.

Can someone please test the GetHTMLFragment() function ( multiple browsers, CHM's etc preferred )

Simple Instructions:
  • - Copy and save the entire Gist below
    - Run it
    - Open or activate a page with text in a browser of your choice
    - Select some or all of the page
    - Copy the selection
    - Press F1 to display the result
GetHTMLFragment()
If it works, you should see a message box with some HTML Markup in it.
If not, please post your result

Thanks for any cooperation
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: HTML Clipboard Saver ★☆★NEED TESTERS★☆★

27 Feb 2017, 14:33

I do not know it clearly though.
It looks like that works properly.
I'm with Win 8.1 64 and Firefox.
Tested local Med search site(http://www.kmle.co.kr/).
notepad
result


Regards
Last edited by IMEime on 27 Feb 2017, 14:35, edited 2 times in total.
Crashm87
Posts: 48
Joined: 25 Jul 2016, 13:12

Re: HTML Clipboard Saver ★☆★NEED TESTERS★☆★

27 Feb 2017, 14:34

This is workin successfully on Windows 10, using Chrome and IE 11. It copies the entire HTML code for the page, and displays in Msgbox. I cannot read the entire HTML, or access OK Button in the message box because the HTML is so long
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: HTML Clipboard Saver ★☆★NEED TESTERS★☆★

27 Feb 2017, 15:25

@IMEime ty
Crashm87 wrote:... I cannot read the entire HTML, or access OK Button in the message box because the HTML is so long
ahh yes ..
I've updated the script to display a limited amount of characters tytyty
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: HTML Clipboard Saver ★☆★NEED TESTERS★☆★

27 Feb 2017, 16:29

much simplified version of WinClip() :thumbsup:

Crashm87
Posts: 48
Joined: 25 Jul 2016, 13:12

Re: HTML Clipboard Saver ★☆★NEED TESTERS★☆★

27 Feb 2017, 16:52

TLM wrote:@IMEime ty
Crashm87 wrote:... I cannot read the entire HTML, or access OK Button in the message box because the HTML is so long
ahh yes ..
I've updated the script to display a limited amount of characters tytyty
much more managable now.
Spoiler
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: HTML Clipboard Saver ★☆★NEED TESTERS★☆★

27 Feb 2017, 21:20

- Updated to return a HTML Fragment Object instead of a String.
- Fixed issue with the static HTMLFile Com Object concatenating fragment data.
- Moved topic from Ask For Helk to Scripts and Functions

Thanks again for all the input, I'm open to more if anyone runs into any anomalous issues.
stealzy
Posts: 91
Joined: 01 Nov 2015, 13:43

Re: ★☆GetHTMLFragment()★☆

28 Feb 2017, 07:40

Firefox 47, Win7. Select "Simple Instructions:" line on this topic page:

Code: Select all

<HTML><HEAD></HEAD>
<BODY>Version:0.9 StartHTML:00000201 EndHTML:00000291 StartFragment:00000235 EndFragment:00000255 SourceURL:https://autohotkey.com/boards/viewtopic.php?f=6&t=28608&sid=984
....
ML:00000291 StartFragment:00000235 EndFragment:00000255 SourceURL:https://autohotkey.com/boards/viewtopic.php?f=6&t=28608&sid=984df43736884d48d6f3ec7dbd721c1a Simple Instructions:</BODY></HTML>
Select 2 line — "Simple Instructions:" and next "- Copy and save the entire Gist below":

Code: Select all

<HTML><HEAD></HEAD>
<BODY>
<UL>- Copy and save the entire Gist below</UL></BODY></HTML>
....
<HTML><HEAD></HEAD>
<BODY>
<UL>- Copy and save the entire Gist below</UL></BODY></HTML>
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: ★☆GetHTMLFragment()★☆

28 Feb 2017, 10:43

- Changed the needle that removes the fragment ident ( let me know if you still get them )
eg: Version:0.9 StartHTML:00000201 EndHTML:00000291 StartFragment:00000235 EndFragment:00000255 SourceURL:https://autohotkey.com/boards/viewtopic ... 08&sid=984.........................
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: ★☆GetHTMLFragment()★☆

01 Mar 2017, 00:39

While I know it's probably redundant ...
- added a CheckClipboard() function to 1st see if a fragment exist ( I may remove this )
burque505
Posts: 1736
Joined: 22 Jan 2017, 19:37

Re: ★☆GetHTMLFragment()★☆

01 Mar 2017, 11:42

PaleMoon 27.1.1, 32-bit. Works, but I had to change

Code: Select all

For Needle, Replace in { "(>)v\w{6}:[\d\.]+.*?--st.*?->" : "$1", "<!--(s|e).*?-->" : "" } ) ;  "(y>).*?(<\w)" : "$1$2", "<!--(s|e).*?-->" : "" }
to

Code: Select all

For Needle, Replace in ({ "(>)v\w{6}:[\d\.]+.*?--st.*?->" : "$1", "<!--(s|e).*?-->" : "" } ) ;  "(y>).*?(<\w)" : "$1$2", "<!--(s|e).*?-->" : "" }
after the script failed with an "unexpected ")".

Looking forward to more.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: ★☆GetHTMLFragment()★☆

01 Mar 2017, 12:27

Thanks for catching that hold over cruft burque505 .. Updated the original script
XeroByte
Posts: 26
Joined: 17 Sep 2014, 01:30

Re: ★☆GetHTMLFragment()★☆

04 Mar 2017, 08:30

There is a dependent function that is not included in your posted code. Where can I find GetSourceURL()

Thanks
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: ★☆GetHTMLFragment()★☆

04 Mar 2017, 09:51

My bad I posted it as a separate gist.

Code: Select all

GetSourceURL( str )
{
	FragIdent := RegExReplace( str, "i).*<b.*?>(.*?<!--s\w{11}t-->).*", "$1" )

	For Each, Ident in StrSplit( FragIdent, " " )
		if InStr( Ident, mStr := "SourceURL:" )
			SourceURL := SubStr( Ident, StrLen( mStr )+1 )

	Return SourceURL	
}
I've also added it to the original gist
bendy303
Posts: 13
Joined: 05 Dec 2014, 00:33

Re: ★☆GetHTMLFragment()★☆

18 Oct 2017, 16:50

can't get it working...

1) I copy html from browser
2) press F1 and get message "Please Copy Some HTML"
3) test it by pasting onto word - HTML is in fact in clipboard. Something wrong with the code...

am using AutoHotKey Unicode 64bit 1.1.26.1

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 254 guests