ComObject("HTMLfile") for extracting HTML Source from clipboard Topic is solved
Re: ComObject("HTMLfile") for extracting HTML Source from clipboard
Thanks! Seemed to work fine beforehand anyway due to the null termination.
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: ComObject("HTMLfile") for extracting HTML Source from clipboard
teadrinker wrote: ↑03 Apr 2023, 14:02Yep, in AHK v1 StrPut() returns the size in characters, not bytes, hence the confusion.
That is really good to know. I pondered for quite a bit if it was supposed to be "* 2" or "* 2 + 8".
I am still learning and not confident on getting everything just right with DllCall, StrPut, offsets, buffers, etc. In the future that will be one less thing to worry about.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
-
- Posts: 4400
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: ComObject("HTMLfile") for extracting HTML Source from clipboard
Anyone who is involved in programming "is still learning".FanaticGuru wrote: ↑I am still learning
Re: ComObject("HTMLfile") for extracting HTML Source from clipboard
Thank you for ExtractHtmlData() function )))teadrinker wrote: ↑19 Mar 2023, 12:25Don't use chatGPT for AHK, it doesn't make sense. Perhaps you need this:Code: Select all
F11:: { if CopySelectedText() { if html := ExtractHtmlData() url := RegExReplace(html, 's)(?<=href=")[^"]+(*SKIP)(*F)|.') MsgBox 'text: ' . A_Clipboard . '`nurl: ' . url } CopySelectedText() { ClipSaved := ClipboardAll() A_Clipboard := '' Send '^c' ClipWait 1 if (A_Clipboard = '') { A_Clipboard := ClipSaved MsgBox 'Failed to copy data' return } return true } ExtractHtmlData() { static CF_HTML := DllCall('RegisterClipboardFormat', 'Str', 'HTML Format') DllCall('OpenClipboard', 'Ptr', A_ScriptHwnd) format := 0 Loop { format := DllCall('EnumClipboardFormats', 'UInt', format) } until format = CF_HTML || format = 0 if format != CF_HTML { DllCall('CloseClipboard') return } hData := DllCall('GetClipboardData', 'UInt', CF_HTML, 'Ptr') pData := DllCall('GlobalLock', 'Ptr', hData, 'Ptr') html := StrGet(pData, 'UTF-8') DllCall('GlobalUnlock', 'Ptr', hData) DllCall('CloseClipboard') return html } }