我们有一个备份应用程序,用于备份需要手动运行的业务应用程序。我正在尝试自动化这个过程。我已经暂时使用AutoIt用于不同目的,但这对我来说是一种新问题。
应用不接受Send,ControlSend,ControlClick或MouseClick。单击键盘上的SPC并用鼠标左键单击“应用程序开始”按钮将启动备份过程,但发送SPC或ControlClick控件将不会。
这是应用摘要:
# Window
Title: 4D Fresh V.15.10.22
Class: ClaWin0400000H_1
Position: 356, 139
Size: 727, 582
Style:0x16CB0000
ExStyle: 0x00000100
Handle: 0x00180E52
#Control
Class:
Instance:
ClassnameNN:
Name:
Advanced (Class):
ID:
Text:
Position:
Size:
ControlClick Coords:
Style:
ExStyle:
Handle:
# Mouse
Position: 626, 155
Cursor ID: 0
Color: 0xFFFFFF
# StatusBar
# ToolsBar
# Visible Text
4D Fresh - Program za osvježavanje informacijskog sustava 4D Wand sa Interneta.
POZOR:
Nositelj autorskih i imovinskih prava programskog rješenja 4D Wand je tvrtka 4th Dimension d.o.o. te pravo korištenja ovog programa posjeduju isključivo slijedeći korisnici:
- korisnici koji pripadaju jamstvenom periodu (12 mjeseci)
- korisnici koji su potpisali ugovor o paušalnom održavanju i redovito podmiruju svoje obveze
Korisnici koji ne pripadaju jamstvenom periodu ili nisu potpisali ugovor o paušalnom održavanju nemaju pravo korištenja ovoga programa. Svako nelegalno korištenje ili distribucija ovog programa, povlači za sobom kaznenu i materijalnu
odgovornost prema pozitivnim propisima Republike Hrvatske.
Startno vrijeme:
Proteklo vrijeme:
Predviđeno trajanje:
Server:
0:00:00
0:00:00
0:00:00
4D Server
&Start
S&etiranje
Upu&te
I&zlaz
Zadnje uspješno snimanje 3.02.2016 u 12:01:03
Zadnje neuspješno snimanje 3.11.2015 u 7:21:05
Prije snimanja nove verzije napravite rezervne kopije podataka!!!
Pritisnite Start za početak obrade!
# Hidden Text
这是我的代码:
#include <Debug.au3>
#include <MsgBoxConstants.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
_DebugSetup("Debugw", True)
;_DebugSetup("Debugw", False, 4, "wFlash.txt", True)
WinMove("Debugw", "", 7, 100, 427, 319)
_DebugOut("Opening Fresh")
$hFreshPID = ShellExecute ("W:\4d\Wand\Fresh4D\Fresh4D.exe","", "W:\4d\Wand\Fresh4D")
If $hFreshPID == 0 Then
_DebugOut("!!! Error starting Fresh !!!")
Exit
EndIf
_DebugOut("hFreshPID: " & $hFreshPID)
_DebugOut("Waiting for 4D Fresh window ...")
WinWait("4D Fresh")
$hWnd = WinGetHandle("4D Fresh", "")
If $hWnd == 0 Or $hWnd == 0x0000000000000000 Then
_DebugOut("!!! Did not get Fresh handle !!!")
Exit
EndIf
_DebugOut("hWnd: " & $hWnd)
WinWaitActive($hWnd, "Pritisnite Start za početak obrade!")
If WinActive($hWnd) Then ; Check if Fresh is currently active.
_DebugOut("Fresh is active.")
$hWndCtrl = ControlGetHandle($hWnd, "", 16408) ; Start button ID=16408
If $hWndCtrl == 0 Then
_DebugOut("Control not found. Exiting.")
Exit
EndIf
ControlFocus($hWnd, "", $hWndCtrl)
;Send("{SPACE}")
;Send("{ASC 0061}")
;Send("{ASC 115}")
;Send("{s}")
;$ctrlClc = ControlSend ($hWnd, "", "", "{s}")
;$ctrlClc = ControlSend("[CLASS:ClaWin0400000H_1]", "", 16408, "{SPACE}")
;$ctrlClc = ControlClick ($hWnd, "", $hWndCtrl)
;$ctrlClc = ControlClick ($hWnd, "", "&Start")
$ctrlClc = ControlClick ($hWnd, "", $hWndCtrl, "", "", 38, 41)
If $ctrlClc == 0 Then
_DebugOut("Control not found. Exiting")
Exit
EndIf
Else
_DebugOut("!!!Fresh is not active.!!!")
Exit
EndIf
Exit
你可以看到我有很多测试线但只是忽略它们。
我已经测试过控件是否存在而且确实存在。我试图将焦点从一个控件更改为另一个控件(有“开始”,“设置”,“帮助”和“退出”按钮),但这不起作用。
我不知道还有什么可以尝试。
这是开始控制信息:
Control
Class: ClaButton_0400000H
Instance: 1
ClassnameNN: ClaButton_0400000H1
Name:
Advanced (Class): [CLASS:ClaButton_0400000H; INSTANCE:1]
ID: 16408
Text: &Start
Position: 7, 458
Size: 81, 62
ControlClick Coords: 56, 31
Style: 0x50034000
ExStyle: 0x00000000
Handle: 0x00660B4E
答案 0 :(得分:0)
我已用reddit用户 StarterFluid 解决了这句话:
在脚本顶部尝试#RequireAdmin,让您的脚本以管理员身份运行,然后重新编译。
(https://www.reddit.com/r/autoit/comments/2l6d6f/controlclick_not_clicking/)