Я написал UDF, который выполняет мои приказы, передавая всю информацию, необходимую для поиска элемента управления или окна. Пример использования. CheckClickCtrl ('[CLASS:#32770]', 'ApplicationX - Мастер InstallShield', '[CLASS:Button; INSTANCE:1]', , '&Next >' 5000, 0)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Timers.au3>
#include <GUIConstantsEx.au3>
#include "log4a.au3"
#Region ;**** Logging ****
; Enable logging and don't write to stderr
_log4a_SetEnable()
; Write to stderr, set min level to warn, customize message format
_log4a_SetErrorStream()
_log4a_SetMinLevel($LOG4A_LEVEL_TRACE)
; If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled
_log4a_SetFormat("${date} | ${host} | ${level} | ${message}")
#EndRegion ;**** Logging ****
Const $TD_BTN_NEXT = '&Next >'
Const $TD_BTN_INSTALL = '&Install'
Const $TD_BTN_CANCEL = 'Cancel'
Const $TD_BTN_FINISH = 'Finish'
Const $TD_BTN_UNINSTALL = '&Uninstall'
Const $TD_BTN_CLOSE = 'Close'
Const $TD_BTN_YES = '&Yes'
Const $formclass = "[CLASS:#32770]"
Const $Edit = "[CLASS:Edit; INSTANCE:1]"
Const $button1 = "[CLASS:Button; INSTANCE:1]"
Const $button2 = "[CLASS:Button; INSTANCE:2]"
Const $button3 = "[CLASS:Button; INSTANCE:3]"
Const $button4 = "[CLASS:Button; INSTANCE:4]"
Const $7zWindowInst = '7-Zip 15.14 (x64) Setup'
Const $7zWindowUnInst = '7-Zip 15.14 (x64) Uninstall'
unInst7z()
;~ inst7z()
Func inst7z()
_log4a_Info('inst7z:Begin')
CheckClickCtrl($formclass, $7zWindowInst, $button2, $TD_BTN_INSTALL, 0, 0)
CheckClickCtrl($formclass, $7zWindowInst, $button2, $TD_BTN_CLOSE, 0, 0)
_log4a_Info('inst7z():End')
EndFunc ;==>inst7z
Func unInst7z()
_log4a_Info('unInst7z:Begin')
CheckClickCtrl($formclass, $7zWindowUnInst, $button1, $TD_BTN_UNINSTALL, 0, 0)
CheckClickCtrl($formclass, $7zWindowUnInst, $button1, $TD_BTN_CLOSE, 0, 0)
_log4a_Info('unInst7z():End')
EndFunc ;==>unInst7z
Func CheckClickCtrl($formclass, $text, $ctrl, $ctrltxt, $timeout, $delayafter)
_log4a_Info("CheckClickCtrl():Begin")
_log4a_Info("Waiting for: " & $formclass & " " & $text & " " & $ctrl & " " & $ctrltxt)
_log4a_Info("Timeout: " & $timeout)
Local $time_run = _Timer_Init()
While (1)
If WinExists($formclass) Then
Local $hCtrl = ControlGetHandle($text, '', $ctrl)
If $hCtrl Then
If ($timeout > 0) Then
_log4a_Trace(_Timer_Diff($time_run))
If (_Timer_Diff($time_run) > $timeout) Then
_log4a_Info("ExitLoop:Timeout - " & $ctrl)
ExitLoop
EndIf
EndIf
Local $hCtrlHandle = ControlGetText($text, '', $ctrl)
_log4a_Info("Control Text : " & $hCtrlHandle)
_log4a_Info("Control Text Search : " & $ctrltxt)
If ($hCtrlHandle == $ctrltxt) Then
; we got the handle, so the button is there
; now do whatever you need to do
_log4a_Info($formclass)
_log4a_Info($ctrl)
ControlClick($formclass, "", $ctrl)
If ($delayafter > 0) Then
Sleep($delayafter)
EndIf
_log4a_Trace("ExitLoop:Normal - " & $ctrl)
ExitLoop
EndIf
EndIf
EndIf
WEnd
_log4a_Info("CheckClickCtrl():End")
EndFunc ;==>CheckClickCtrl
Результаты приведены ниже:
Результаты установки:
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | inst7zinst7z:Begin
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():Begin
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Waiting for: [CLASS:#32770] 7-Zip 15.14 (x64) Setup [CLASS:Button; INSTANCE:2] &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Timeout: 0
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | [CLASS:#32770]
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | [CLASS:Button; INSTANCE:2]
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Trace | ExitLoop:Normal - [CLASS:Button; INSTANCE:2]
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():End
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():Begin
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Waiting for: [CLASS:#32770] 7-Zip 15.14 (x64) Setup [CLASS:Button; INSTANCE:2] Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Timeout: 0
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : &Install
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | [CLASS:#32770]
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | [CLASS:Button; INSTANCE:2]
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Trace | ExitLoop:Normal - [CLASS:Button; INSTANCE:2]
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():End
10\02\2017 14:32:30 | WIN-4VR4FSF2H8Q | Info | inst7z():End
+>14:32:30 AutoIt3.exe ended.rc:0
+>14:32:30 AutoIt3Wrapper Finish
Uninstall results:
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | unInst7zinst7z:Begin
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():Begin
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Waiting for: [CLASS:#32770] 7-Zip 15.14 (x64) Uninstall [CLASS:Button; INSTANCE:1] &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Timeout: 0
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text : &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text Search : &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | [CLASS:#32770]
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | [CLASS:Button; INSTANCE:1]
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Trace | ExitLoop:Normal - [CLASS:Button; INSTANCE:1]
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():End
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():Begin
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Waiting for: [CLASS:#32770] 7-Zip 15.14 (x64) Uninstall [CLASS:Button; INSTANCE:1] Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Timeout: 0
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text : &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text : &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text : &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text : &Uninstall
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text : Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | Control Text Search : Close
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | [CLASS:#32770]
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | [CLASS:Button; INSTANCE:1]
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Trace | ExitLoop:Normal - [CLASS:Button; INSTANCE:1]
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | CheckClickCtrl():End
10\02\2017 14:35:00 | WIN-4VR4FSF2H8Q | Info | inst7z():End
+>14:35:00 AutoIt3.exe ended.rc:0
+>14:35:00 AutoIt3Wrapper Finished.
>Exit code: 0 Time: 0.7732
person
Peter Martin
schedule
02.10.2017
$button = ControlGetHandle(...)
, чтобы проверить, правильно ли вы обращаетесь к элементу управления. Стоит проверить, работает лиControlFocus("Free HTML to PDF Converter", "", $button)
с возвращенным дескриптором. И поскольку NAME-Attribute специфичен для .Net, вы должны попытаться заменить его. - person Samoth   schedule 23.09.2013