How to modify html in MSHTML

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sanmaodo
Posts: 45
Joined: 28 Aug 2020, 01:39

How to modify html in MSHTML

13 Jun 2023, 09:20

How to modify image height in <Style> ? please help.

Code: Select all

html=
(
<!DOCTYPE html>
<html>
  <head>
  <style>
    img:hover { background-color: #888888; }
    img { height: 200px; width: auto; PADDING: 10px;} 
  </style>
  </head>
  <body>
     <div>
        <IMG id=1 src="https://www.autohotkey.com/assets/images/features-bootstrap.png">
        <IMG id=2 src="https://www.autohotkey.com/assets/images/features-why.png">
     </div>
  </body>
</html>
)
Gui, Add, ActiveX, w400 h300 vimg, MSHTML:
img.Write(html)
img.Close()

; Modify the HTML
; Style := "img:hover { background-color: #888888;}"
;         . "img{ height: 400px; width: auto; PADDING: 10px;}"
; img.GetElementsByTagName("style")[0].outerHTML := Style

Gui, Show
; MsgBox, % img.documentElement.outerHTML
Return

GuiClose:
ExitApp
Rohwedder
Posts: 7750
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to modify html in MSHTML

13 Jun 2023, 09:38

Hallo,
well, I suppose by changing the 200 to img { height: 200px
sanmaodo
Posts: 45
Joined: 28 Aug 2020, 01:39

Re: How to modify html in MSHTML

14 Jun 2023, 04:11

hi, Rohwedder
I can read the contents of <Style>, but not write.

Code: Select all

MsgBox, % img.GetElementsByTagName("style")[0].InnerHtml
I want to change the heigth to 400.
Rohwedder
Posts: 7750
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to modify html in MSHTML

14 Jun 2023, 11:08

I see you don't want to use ActiveX components for your Autohotkey Guis, just cannibalize existing websites!
Sorry, but I have too little knowledge about this.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: How to modify html in MSHTML

14 Jun 2023, 13:27

The script below resizes the GUI images to 400 (they stretch, which isn't very elegant), I don't know if that's what you want or I just misunderstood the question.

Code: Select all

html=
(
<!DOCTYPE html>
<html>
  <head>
  <style>
    img:hover { background-color: #888888; }
    img { height: 400px; width: 400px; PADDING: 10px;} 
  </style>
  </head>
  <body>
     <div>
        <IMG id=1 src="https://www.autohotkey.com/assets/images/features-bootstrap.png">
        <IMG id=2 src="https://www.autohotkey.com/assets/images/features-why.png">
     </div>
  </body>
</html>
)
Gui, Add, ActiveX, w800 h400 vimg, MSHTML:

img.Write(html)
img.Close()

; Modify the HTML
; Style := "img:hover { background-color: #888888;}"
;         . "img{ height: 400px; width: auto; PADDING: 10px;}"
; img.GetElementsByTagName("style")[0].outerHTML := Style

Gui, Show
; MsgBox, % img.documentElement.outerHTML
Return

GuiClose:
ExitApp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], marypoppins_1, mikeyww, peter_ahk and 116 guests