I'm trying to automate an installer to make it (mostly) silent, but I don't always know what language the system will be configured for and the installer supports a large number of languages. The installer is particularly insidious because the control names appear to be somewhat randomly assigned and the positions of some are not consistent from one install attempt to the next (even on the same machine with the same language). I can't identify which page I am on by looking for key text because the language will be unknown. I can't even identify the window because all attempts at finding the window by matching title and/or content containing the software name have failed. (I assume the name of the software must be in unicode/special characters that won't copy out of Windows Spy.)
All controls for all pages of the install are returned by a
winget, ActiveControlList, ControlList, ahk_id %id% run on any page.
Nevertheless, I have managed to work out how to get all the way through the install using AHK to supply {enter} commands for the default install like this:
Code: Select all
WinGet, id, ID, ahk_class TWizardForm
WinActivate, ahk_id %id%
winget, ActiveControlList, ControlList, ahk_id %id%
Loop, Parse, ActiveControlList, `n
{
ControlGet, CanSee, Visible ,, %A_LoopField%, ahk_class TWizardForm
ControlGet, CanWork, Enabled ,, %A_LoopField%, ahk_class TWizardForm
ControlGet, Check, Checked ,, %A_LoopField%, ahk_class TWizardForm
ControlGetText, RText, %A_LoopField%, ahk_class TWizardForm
If (CanSee
and CanWork
and (RText <> "")
and InStr(A_LoopField,"radio",false)
and !Check)
{
ControlClick, %A_LoopField%, ahk_id %id%
Break
;MsgBox, 4,, "%A_LoopField%" is Checked=%Check%. "%RText%" Continue?
;IfMsgBox, No
; break
}
}
sleep, 100
WinActivate, ahk_id %id%
Send, {enter}
sleep, 100
WinActivate, ahk_id %id%
Send, {enter}
sleep, 100
WinActivate, ahk_id %id%
Send, {enter}
sleep, 100
WinActivate, ahk_id %id%
Send, {enter}
This gets me through the installation and only the last screen to close or finish is left. The problem is that is not immediate. It might take some time and it may be in any language and and the button names are not consistent from one run to the next. The processes are the same as the installer, so I can't watch for those. I'm not sure how to tell when the install is complete with AHK.
Does anyone have any suggestions?