forked from pywinauto/pywinauto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_winrar_info.py
156 lines (118 loc) · 4.2 KB
/
get_winrar_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
"""Automate WinRAR evaluation copy
We hit a few dialogs and save XML dump and
screenshot from each dialog.
Specify a language at the command line:
0 Czech
1 German
2 French
More then likely you will need to modify the apppath
entry in the 't' dictionary to where you have
extracted the WinRAR executables.
"""
__revision__ = "$Revision$"
import sys
from pywinauto.application import Application
import time
folders = ['wrar351cz', 'wrar351d', 'wrar351fr']
# translations for each language
t = {
'apppath' : (
'c:\.temp\wrar351fr\winrar.exe',
'c:\.temp\wrar351d\winrar.exe',
'c:\.temp\wrar351cz\winrar.exe'
),
# Buy Licence Dialog
'Buy Licence' : (
"Acheter une licence pur winRAR",
"Bittekaufensieeine",
"Zakuptesiprosmlicenci WinRARu"),
'Close' : (
"Fermer",
"Schleissen",
"Zavrit"),
# Options->Configure menu items
"Options->Configure" : (
"Options->Configuration",
"Optionen->Einstellungen",
"Moznosti->Nastaveni"),
# Configure/Options dialog box
'Configure' : (
"Configuration",
"Einstellungen",
"Nastaveni"),
# personalise toolbar buttons button
'Buttons' : (
"Boutons",
"Schaltflachen",
"Vybrattlacitka"),
# Personalize toolbars dialog
'PeronnaliseToolbars' : (
"Peronnalisation de la barre doutils",
"Werkzeugleisteanpassen",
"Vybertlaciteknastrojovelisty"),
# create profile button
'CreateDefaultProfile' : (
u"Creerleprofilpard�fault",
"Standardfestlegen",
"Vytvoritimplicitni"),
# create profile dialog box title
'ConfigureDefaultOptions' : (
"Configurer les options de compre...",
"Standardkomprimierungs",
"Zmenaimplicitnichnast..."),
# context menu's button
"ContextMenus" : (
"Menus contextuels",
"Optionenimkontextmenu",
"Polozkykontextovehamenu"),
# context menu's dialog
"contextMenuDlg" : (
"Rubriques des menus contextuels",
"OptionenindenKontextmenus",
"Polozkykontextovehamenu"),
# file->exit menu option
"File->Exit" : (
"Fichier->Quitter",
"Datei->Beenden",
"Soubor->Konec"),
}
def get_winrar_dlgs(rar_dlg, app, lang):
rar_dlg.menu_select(t["Options->Configure"][lang])
optionsdlg = app[t['Configure'][lang]]
optionsdlg.write_to_xml("Options_%d.xml" % lang)
optionsdlg.capture_as_image().save("Options_%d.png" % lang)
optionsdlg[t['Buttons'][lang]].click()
contextMenuDlg = app[t['PeronnaliseToolbars'][lang]]
contextMenuDlg.write_to_xml("PersonaliseToolbars_%d.xml" % lang)
contextMenuDlg.capture_as_image().save("PersonaliseToolbars_%d.png" % lang)
contextMenuDlg.OK.click()
optionsdlg.TabCtrl.select(1)
optionsdlg[t['CreateDefaultProfile'][lang]].click()
defaultOptionsDlg = app[t['ConfigureDefaultOptions'][lang]]
defaultOptionsDlg.write_to_xml("DefaultOptions_%d.xml" % lang)
defaultOptionsDlg.capture_as_image().save("DefaultOptions_%d.png" % lang)
defaultOptionsDlg.OK.click()
optionsdlg.TabCtrl.select(6)
optionsdlg[t['ContextMenus'][lang]].click()
anotherMenuDlg = app[t['contextMenuDlg'][lang]]
anotherMenuDlg.write_to_xml("2ndMenuDlg_%d.xml" % lang)
anotherMenuDlg.capture_as_image().save("2ndMenuDlg_%d.png" % lang)
anotherMenuDlg.OK.click()
optionsdlg.OK.click()
# get the languages as an integer
langs = [int(arg) for arg in sys.argv[1:]]
for lang in langs:
# start the application
app = Application().start(t['apppath'][lang])
# we have to wait for the Licence Dialog to open
time.sleep(2)
# close the Buy licence dialog box
licence_dlg = app[t['Buy Licence'][lang]]
licence_dlg[t['Close'][lang]].click()
# find the WinRar main dialog
rar_dlg = app.window(title_re = ".* - WinRAR.*")
# dump and capture some dialogs
get_winrar_dlgs(rar_dlg, app, lang)
# exit WinRar
time.sleep(.5)
rar_dlg.menu_select(t['File->Exit'][lang])