Internet Explorer get/set zoom/text size

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Internet Explorer get/set zoom/text size

01 Jan 2017, 17:20

ZOOM:
I've basically got this all working with one query.
I'm able to get and set the zoom via ExecWB, and retrieve the value (e.g. 0 gives 10%, -1 gives 1000%).
And have a workaround method to get the zoom without ExecWB.
But have been unable to get the zoom via ExecWB (when you don't also set the zoom),
because it seems to require a null in one of the parameters,
and if it's possible it would be useful to understand how to do that.

TEXT SIZE:
A bigger problem is getting the text size.
I haven't managed to get this to work:
vTextSize := 0
;vTextSize := 4
oWB.ExecWB(19, 2, vTextSize, 0)

Code: Select all

;==================================================

#IfWinActive, ahk_class IEFrame ;internet explorer
^y:: ;internet explorer - get/set zoom
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
vLogicalXDPI := oWB.document.parentWindow.screen.logicalXDPI
vDeviceXDPI := oWB.document.parentWindow.screen.deviceXDPI
vZoom := Round(vDeviceXDPI / vLogicalXDPI * 100)

;JEE_InputBoxVPD(vZoom2, "zoom %:", vZoom)
InputBox, vZoom2, , % "zoom %:", , , , , , , , %vZoom%
;if (vZoom2 = "n")
;vZoom2 := 100
;if vZoom2 in 0,1,2,3,4,5,6,7,8,9
;vZoom2 := "1" vZoom2 "0"
if ErrorLevel OR (vZoom2 = vZoom)
{
oWB := ""
Return
}

oZoomNew := ComVar()
oWB.ExecWB(63, 2, vZoom2, oZoomNew.ref)
oWB := ""
MsgBox % oZoomNew[]
Return
#IfWinActive

;==================================================

; ComVar: Creates an object which can be used to pass a value ByRef.
;   ComVar[] retrieves the value.
;   ComVar[] := Val sets the value.
;   ComVar.ref retrieves a ByRef object for passing to a COM function.
ComVar(Type:=0xC)
{
    static base := { __Get: "ComVarGet", __Set: "ComVarSet", __Delete: "ComVarDel" }
    ; Create an array of 1 VARIANT.  This method allows built-in code to take
    ; care of all conversions between VARIANT and AutoHotkey internal types.
    arr := ComObjArray(Type, 1)
    ; Lock the array and retrieve a pointer to the VARIANT.
    DllCall("oleaut32\SafeArrayAccessData", "ptr", ComObjValue(arr), "ptr*", arr_data)
    ; Store the array and an object which can be used to pass the VARIANT ByRef.
    return { ref: ComObject(0x4000|Type, arr_data), _: arr, base: base }
}
ComVarGet(cv, p*) { ; Called when script accesses an unknown field.
    if !p.Length  ; No name/parameters, i.e. cv[]
        return cv._[0]
}
ComVarSet(cv, v, p*) { ; Called when script sets an unknown field.
    if !p.Length  ; No name/parameters, i.e. cv[]:=v
        return cv._[0] := v
}
ComVarDel(cv) { ; Called when the object is being freed.
    ; This must be done to allow the internal array to be freed.
    DllCall("oleaut32\SafeArrayUnaccessData", "ptr", ComObjValue(cv._))
}

;==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Internet Explorer get/set zoom/text size

18 Aug 2017, 12:04

A script to get the zoom percentage in Internet Explorer/HTML Help.

Code: Select all

;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869

q:: ;internet explorer - get zoom percent
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
vLogicalXDPI := oWB.document.parentWindow.screen.logicalXDPI
vDeviceXDPI := oWB.document.parentWindow.screen.deviceXDPI
vZoom := Round(vDeviceXDPI / vLogicalXDPI * 100)
oWB := ""
MsgBox, % vZoom
return
A script to set the zoom percentage (and text size) in Internet Explorer/HTML Help.

Code: Select all

;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869

q:: ;internet explorer - set zoom percent (and text size)
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
;OLECMDID_OPTICAL_ZOOM := 63 ;(zoom % e.g. 100, 135)
;OLECMDID_ZOOM := 19 ;(text size 0/1/2/3/4)
vZoom := 130, vTextSize := 2
oWB.ExecWB(63, 2, vZoom, 0)
oWB.ExecWB(19, 2, vTextSize, 0)
oWB := ""
return
A related script:
Internet Explorer get element under cursor (show borders, show text) (any zoom percentage) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=29458
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, RussF and 400 guests