1. Try using DumpAll() on the website and see whether the output contains something resembling the hidden element (eg an element with the name "isWriteOff"). UIA is mostly meant for visible UI elements so a hidden one might not be detectable though, in which case you'd probably need to inject Javascript to interact with it.
2. That looks like Javascript? In that case you could use UIA_Browser.ahk JSExecute method, or I have a more optimized one for Chrome (which could be modified for other browsers as well):
Code: Select all
#Requires Autohotkey v2.0
#SingleInstance
#Include UIA.ahk
F1::{
ChromeExecuteJS('alert("Hello")')
}
F2::{
ChromeExecuteJS('document.parentWindow.execScript("function confirm(){return true}")')
}
ChromeExecuteJS(js, WinTitle := "Google Chrome ahk_exe chrome.exe") {
if !(hWnd := WinExist(WinTitle))
throw TargetError("No matching window found", -1)
ChromeNavigate("javascript:" js, WinTitle)
}
ChromeNavigate(url?, WinTitle := "Google Chrome ahk_exe chrome.exe") {
static cache := Map()
if !(hWnd := WinExist(WinTitle))
throw TargetError("No matching Chrome window found", -1)
ActivateChromiumAccessibility(hWnd)
if !cache.Has(hWnd) {
try cache[hWnd] := UIA.ElementFromHandle(hWnd).FindElement({Type:"Edit", index:-1})
catch
throw TargetError("Failed to get the address bar element", -1)
for k in [cache*]
if !WinExist(k)
cache.Delete(k)
}
if !IsSet(url)
return
try cache[hWnd].Value := url " "
catch
Error("Failed to set the URL value", -1)
prevDelay := A_KeyDelay, prevDuration := A_KeyDuration
SetKeyDelay -1, 1
ControlSend("{LCtrl up}{LAlt up}{LShift up}{RCtrl up}{RAlt up}{RShift up}{Enter}", , hWnd)
SetKeyDelay prevDelay, prevDuration
}
ActivateChromiumAccessibility(WinTitle := "Google Chrome ahk_exe chrome.exe") {
static SWP_NOREDRAW := 0x0008, SWP_NOSIZE := 0x0001, SWP_NOMOVE := 0x0002, SWP_NOACTIVATE := 0x0010
hWnd := IsInteger(WinTitle) ? WinTitle : WinExist(WinTitle)
if !IsWindowVisible() || !(cHwnd := TryGetChromiumHwnd()) {
list := WinGetList(), index := 0
for i, win in list
if win = hWnd {
index := i
break
}
active := WinExist("A")
tp := WinGetTransparent(hWnd)
prevDelay := A_WinDelay
SetWinDelay -1
WinSetTransparent(0, hWnd)
; Bring to front
DllCall("SetWindowPos", "ptr", hWnd, "ptr", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW)
WinActivate(hWnd)
WinActivate(active)
end := A_TickCount + 100
while (A_TickCount < end && !(cHwnd := TryGetChromiumHwnd()))
Sleep -1
if index > 1
DllCall("SetWindowPos", "ptr", hWnd, "ptr", list[index-1], "int", 0, "int", 0, "int", 0, "int", 0, "int", SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOACTIVATE)
WinSetTransparent(tp, hWnd)
SetWinDelay prevDelay
}
return chWnd
TryGetChromiumHwnd() {
try return ControlGetHwnd("Chrome_RenderWidgetHostHWND1", hWnd)
return 0
}
IsWindowVisible() {
WinGetPosEx(hWnd, &x, &y, &w, &h)
l := Max(0, x), t := Max(0, y), r := Min(x+w-1, A_ScreenWidth), b := Min(y+h-1, A_ScreenHeight)
if !(hWnd = UIA.WindowFromPoint(l, t) || hWnd = UIA.WindowFromPoint(r, t) || hWnd = UIA.WindowFromPoint(l, b) || hWnd = UIA.WindowFromPoint(r, b))
return 0
return 1
}
; https://www.autohotkey.com/boards/viewtopic.php?t=114183&p=508461
WinGetPosEx(hWindow, &X := "", &Y := "", &W := "", &H := "") {
static S_OK := 0x0, DWMWA_EXTENDED_FRAME_BOUNDS := 9
RECTPlus := Buffer(24,0)
try {
DWMRC := DllCall("dwmapi\DwmGetWindowAttribute",
"Ptr", hWindow, ;-- hwnd
"UInt", DWMWA_EXTENDED_FRAME_BOUNDS, ;-- dwAttribute
"Ptr", RECTPlus, ;-- pvAttribute
"UInt", 16, ;-- cbAttribute
"UInt")
} catch
return False
X := NumGet(RECTPlus, 0, "Int"), Y := NumGet(RECTPlus, 4, "Int")
, R := NumGet(RECTPlus, 8, "Int"), B := NumGet(RECTPlus, 12, "Int")
, W := R - X, H := B - Y
}
}