Chrome Get Zoom %
Chrome Get Zoom %
I would like to know how can I get the zoom in a given tab of Chrome in order to use the right picture with FindClick function.
Thanks
Thanks
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Chrome Get Zoom %
What is your goal? UI automation might be a good choice but would need to know what you are trying to do, if it's to reset, the other reply is perfect
Re: Chrome Get Zoom %
In javascript:
Code: Select all
window.devicePixelRatio * 100
Re: Chrome Get Zoom %
Probably creating a set of images that could be used to use ImageSearch under different zoom factors?…but would need to know what you are trying to do
Re: Chrome Get Zoom %
My goal is to search for a picture, but the picture changes depending on the zoom level, my idea would be to have different pictures (zoom %), and depending on the zoom use the corresponding picture, unless you have a better idea.AHKStudent wrote: ↑28 Sep 2022, 22:46
What is your goal? UI automation might be a good choice but would need to know what you are trying to do, if it's to reset, the other reply is perfect
Thanks
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Chrome Get Zoom %
are you looking to click that picture? there might be a way to do that without image search by using javascript in the browser address barmartipe1 wrote: ↑09 Oct 2022, 19:18My goal is to search for a picture, but the picture changes depending on the zoom level, my idea would be to have different pictures (zoom %), and depending on the zoom use the corresponding picture, unless you have a better idea.AHKStudent wrote: ↑28 Sep 2022, 22:46
What is your goal? UI automation might be a good choice but would need to know what you are trying to do, if it's to reset, the other reply is perfect
Thanks
Re: Chrome Get Zoom %
Solution using UIAutomation:
Code: Select all
#Include <UIA_Interface>
wExe := "ahk_exe chrome.exe"
UIA := UIA_Interface()
WinActivate, %wExe%
WinWaitActive, %wExe%
chrome := UIA.ElementFromHandle(wExe)
URLEditElement := chrome.FindFirstWithOptions(, "Type=Edit", 2)
maybeZoom := UIA.CreateTreeWalker("Type=Button").GetNextSiblingElement(URLEditElement)
if maybeZoom && RegExMatch(maybeZoom.Name, " (\d+)%$", zoom) && (zoomPercent := zoom1)
MsgBox, % "Current zoom percent is " zoomPercent "%"
Else
MsgBox, % "Zoom button wasn't found, it's probably 100%"
ExitApp