1
#
include <Array.au3>
2
#
include <Date.au3>
3
4
Global $FilePath
=
@ScriptDir
&
"
\dialog.ini
"
5
6
DealDialog()
7
8
Func DealDialog()
9
Local $dialog_type,$win_list_array,$title_list,$list,$title_array
10
11
$dialog_type
=
GetDialogType()
12
13
$win_list_array
=
GetWinList()
14
15
;_ArrayDisplay($win_list_array,
"
$win_list_array
"
)
16
17
For $j
=
1
to UBound($dialog_type)
-
1
18
19
For $i
=
1
to UBound($win_list_array)
-
1
20
$list
=
IniRead($FilePath,$dialog_type[$j],
"
title
"
,
""
)
21
22
If ($list
<>
''
) Then
23
$title_array
=
StringSplit($list ,
'
|
'
,
1
)
24
25
If (_ArrayFindAll($title_array,$win_list_array[$i])
<>
-
1
) Then
26
WinActivate($win_list_array[$i],
''
)
27
28
Switch $dialog_type[$j]
29
Case
'
Alter
'
30
;处理Alter和Confirm对话框
31
$button_index
=
_ArrayFindAll(StringSplit(WinGetClassList($win_list_array[$i]),Chr(
10
),
1
),
'
Button
'
)
32
33
$content
=
ControlGetText($win_list_array[$i],
''
,
'
Static2
'
)
34
SetClipBoard($content)
35
36
Switch UBound($button_index)
37
Case
1
38
Send(
'
{ENTER}
'
)
39
Case
2
40
ControlClick($win_list_array[$i],
''
,
'
Button1
'
)
41
EndSwitch
42
43
Exit
44
Case
'
Choosefile
'
45
ControlSetText($win_list_array[$i],
''
,
'
Edit1
'
,ClipGet())
46
ControlClick($win_list_array[$i],
''
,
'
Button2
'
)
47
Exit
48
Case
'
Prompt
'
49
ControlSetText($win_list_array[$i],
''
,
'
Edit1
'
,ClipGet())
50
ControlClick($win_list_array[$i],
''
,
'
Button1
'
)
51
Exit
52
Case
'
Security
'
53
$content
=
ControlGetText($win_list_array[$i],
''
,
'
Static2
'
)
54
SetClipBoard($content)
55
ControlClick($win_list_array[$i],
''
,
'
Button1
'
)
56
Exit
57
Case
'
DownloadFile
'
58
$save_win_title
=
StringSplit(IniRead($FilePath,
'
SaveasFile
'
,
"
title
"
,
""
) ,
'
|
'
,
1
)
59
60
For $k
=
1
to UBound($save_win_title)
-
1
61
If(WinExists($save_win_title[$k])
<>
1
) Then
62
;Send(
'
!S
'
)
63
ControlClick($win_list_array[$i],
''
,
'
Button2
'
)
64
EndIf
65
Next
66
67
Exit
68
Case
'
SaveasFile
'
69
ControlSetText($win_list_array[$i],
''
,
'
Edit1
'
,ClipGet())
70
ControlClick($win_list_array[$i],
''
,
'
Button2
'
)
71
Exit
72
EndSwitch
73
74
EndIf
75
EndIf
76
Next
77
Next
78
EndFunc
79
80
Func SetClipBoard($content)
81
ClipPut($content)
82
EndFunc
83
84
Func GetDialogType()
85
$name
=
IniReadSectionNames($FilePath)
86
87
If @error Then
88
Exit;
89
Else
90
Return $name
91
EndIf
92
EndFunc
93
94
Func GetWinList()
95
Dim $array[
1
]
96
97
$win_list
=
WinList()
98
99
For $i
=
1
to $win_list[0][0]
100
; 只显示带有标题的可见窗口
101
If $win_list[$i][0]
<>
""
AND IsVisible($win_list[$i][
1
]) Then
102
_ArrayAdd($array,$win_list[$i][0])
103
EndIf
104
Next
105
106
Return $array
107
EndFunc
108
109
Func IsVisible($handle)
110
If BitAnd( WinGetState($handle),
2
) Then
111
Return
1
112
Else
113
Return 0
114
EndIf
115
116
EndFunc
117