![Waving :wave:](./images/smilies/icon_wave.gif)
Using below and getElementsByID I am able to fill in edit boxes, but to my surprise the ID is always changing.
Could you please help me with automating the filling of the edit boxes inside chrome.
Code: Select all
<div class="BoxLayout---box_body">
<div class="ContentLayout---content_layout ContentLayout---padding_less">
<div class="FieldLayout---field_layout appian-context-last-in-list">
<div class="FieldLayout---accessibilityhidden"><label class="FieldLayout---field_label" for="66fe0286b46ae2658ea2a935f72fb0ee"></label></div>
<div class="FieldLayout---input_below">
<div><input id="66fe0286b46ae2658ea2a935f72fb0ee" type="text" class="TextInput---text TextInput---align_start" aria-labelledby="66fe0286b46ae2658ea2a935f72fb0ee" placeholder="" value=""></div></div></div></div></div>
<div class="BoxLayout---box_body">
<div class="ContentLayout---content_layout ContentLayout---padding_less">
<div class="FieldLayout---field_layout appian-context-last-in-list">
<div class="FieldLayout---accessibilityhidden"><label class="FieldLayout---field_label" for="65b309ab5f12747a374869e382de4ace"></label></div>
<div class="FieldLayout---input_below">
<div><input id="65b309ab5f12747a374869e382de4ace" type="text" class="TextInput---text TextInput---align_start" aria-labelledby="65b309ab5f12747a374869e382de4ace" placeholder="" value=""></div></div></div></div></div></div></div></div></div>
Code: Select all
F2::
js := "void(document.getElementsByID('479511c552626f98c6c2fa346efa7aef').value='123456)"
ChromeRunJs(js)
Return
;__________________________________________________________________________________________________________________
ChromeRunJs(ByRef js) {
static addrBar
if !addrBar || !WinExist("ahk_id " addrBar.hWnd) {
if !addrBar := FindAddressBar() {
throw "FindAddressBar failed."
}
}
addrBar.accObj.accValue(0) := " " . js
addrBar.accObj.accSelect(0x1, 0)
ControlSend,, {Enter}
Sleep 100
}
FindAddressBar(WinTitle := "ahk_exe chrome.exe", oAcc := "", accPath := "") {
if !oAcc {
if hWnd := WinExist(WinTitle) {
oAcc := Acc_ObjectFromWindow(hWnd)
while oAcc.accRole(0) != 9 { ; ROLE_SYSTEM_WINDOW := 9
oAcc := Acc_Parent(oAcc)
}
} else {
throw WinTitle " not found."
}
}
for i, child in Acc_Children(oAcc) {
nRole := child.accRole(0)
if (nRole = 42) { ; ROLE_SYSTEM_TEXT := 42
if (child.accName(0) ~= "i)address|地址") {
accPath := LTrim(accPath "." i, ".")
return {accObj: child, accPath: accPath, hWnd: hWnd}
}
}
/*
ROLE_SYSTEM_APPLICATION := 14
ROLE_SYSTEM_PANE := 16
ROLE_SYSTEM_GROUPING := 20
ROLE_SYSTEM_TOOLBAR := 22
ROLE_SYSTEM_COMBOBOX := 46
*/
static oGroup := {14:1, 16:1, 20:1, 22:1, 46:1}
if oGroup.HasKey(nRole) {
if result := FindAddressBar(, child, accPath "." i) {
return result
}
}
}
}
#Include, Acc.ahk