Anoter time problem with ComObject("HTMLfile")

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Emanuele_Tinari[IT]
Posts: 5
Joined: 02 Dec 2023, 13:25
Contact:

Anoter time problem with ComObject("HTMLfile")

Post by Emanuele_Tinari[IT] » 03 Dec 2023, 06:43

Hello at all. Newbie here from Italy. Thanks in advance for any help you'll give me.
I got an .html file saved in my pc where I (or users) can check or uncheck CheckBoxes.
Those give possibility to use a "filter" in a SQLite query. This .html file is something like a Settings file or a .ini file for my script.
Using search here or in Google don't seem show me nothing to resolve my question. For example, searching for "ComObject" in subsection "AutoHotkey v2" show me more than 30 pages, and "ComObject("HTMLfile")" don't retrieve any results!
Html file contain rows like this:

Code: Select all

                                    <div class="div-versione">
                                        <input type="checkbox" id="VLSG" value="VLSG" name="chk-versione" checked="True">
                                        <label for="VLSG">Vulgata latina di san Girolamo</label>
                                    </div>
                                    <div class="div-versione">
                                        <input type="checkbox" id="NV" value="NV" name="chk-versione" checked="True">
                                        <label for="NV">Nova Vulgata</label>
                                    </div>
And so on, for a total of 13 ChkBoxes. This .html file is based on Neutron G33kDude@GitHub, here and Example section #3.
My intention is not only "read" ChkBoxes status but change them ad "re-save" the .html file.
Well. To do that I need before to read html content, change checked value and then re-write html.
Unfortunately read html seems not simple. I start with:

Code: Select all

#Requires AutoHotkey v2.0
#Warn                            ; Enable warnings to assist with detecting common errors.
#SingleInstance Force            ; This suppresses the warning dialogue that a newly launched script is already running.
SetHtml(FileFoundedWithCompletePath)               ; Call Func

SetHtml(html) {
   htmlObj := ComObject("HTMLfile")
   htmlObj.open()

   test1 := htmlObj.getElementsByTagName("input[type=checkbox]")(0)
   ; Error: This value of type "String" has no property named "value".
   test2 := htmlObj.getElementsByTagName("input[type=checkbox]")(0).value
   ; Error: This value of type "String" has no property named "innerHTML". CONTINUE -->
   test3 := htmlObj.getElementsByTagName("input[type=checkbox]")(0).innerHTML

   HtmlIds := htmlObj.getElementById("VLSG")
   ; Error: This value of type "String" has no property named "Length".
   Qta := HtmlIds.Length
   ; Error: This value of type "String" has no property named "value". CONTINUE -->
   Chk_value := htmlObj.getElementById("VLSG").value
   ; Error: This value of type "String" has no property named "innerHTML". CONTINUE -->
   Chk_innerHTML := htmlObj.getElementById("VLSG").innerHTML

   HtmlNames := htmlObj.getElementsByName("Versioni")
   Qta1 := HtmlNames.Length

   HtmlTagName := htmlObj.getElementsByTagName("Input")
   Qta2 := HtmlTagName.Length

   htmlObj.close
   htmlObj := ""
}
In FileFoundedWithCompletePath I got (as shown by me) the .html file with its complete path, so the .html file is a valid file.
I must stop at this point, from develop my script, waiting for some experts here. Maybe a week since I discover AutoHotkey, download and install it is few time, but I'm happy in what I could do till now.
What I looking for is a way to retrieve all 13 (in the piece of html are shown only 2) checkboxes actual status, change its (based on user choices) and then save the new html.
All html file is long 133 lines, so I dont' think should be a problem to elaborate it in memory.
But the way to access to the html source remain.
In the pic You can see what I can examine during Debug operation in VSCode
Screenshot 2023-12-03 120327.png
Screenshot 2023-12-03 120327.png (90.72 KiB) Viewed 171 times
My develop station:
AutoHotkey v2.0.10
Editor and Debugger: Visual Studio Code v1.84.2
Sys Op: Windows_NT x64 10.0.22621 (Windows 10 upgraded to 11)
Predator Helios 300 i7 32Gb + 2SSD(1Tb+4Tb)

Thanxs.

Return to “Ask for Help (v2)”