forked from brltty/brltty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrlttycnf.ahk
255 lines (206 loc) · 8.32 KB
/
brlttycnf.ahk
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
Version = 0.5
;----------------------------------------------------------------------------------------------------------------------------------------
; Platform: Windows XP/Vista
; Author: Michel Such
; AutoHotkey Version: 1.0.47
; Version : Alpha release 1
;
; Script Function:
; Facility to configure Braille device and communication port
; for Windows version of BRLTTY
#SingleInstance
#NoTrayIcon
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CnfFile = %A_ScriptDir%\etc\brltty.conf ; Configuration file for BRLTTY
Gosub SetLanguage
IfNotExist, %CnfFile%
{
Msgbox, 0, %ScriptName%, %CnfFileNotFoundMsg%
ExitApp
}
Gosub SelectPortAndDisplay
Return
SelectPortAndDisplay:
; Fill a listbox for port selection
ComPorts = USB:|COM1|COM2|COM3|COM4|COM5|COM6|COM7|COM8|COM9|COM10|
ComPorts = %ComPorts%COM11|COM12|COM13|COM14|COM15|COM16|
; Fill a listbox for terminal selection
; getting data from brltty.conf
Loop, read, %CnfFile%
{
IfInString A_LoopReadLine, #braille-driver
{
Term := SubStr(A_LoopReadLine, 17)
StringReplace, Term, Term, #, -, 1
TermList = %TermList%%Term%|
}
}
; Draw and display the window
Gui, Font, S12 CDefault, Arial
Gui, Add, Text, x6 y6 w800 h160, %HelpText%
Gui, Add, Text, x6 y166 w400 h20, %SelectBrailleDisplayText%
Gui, Add, ListBox, vTerminal x6 y190 w400 h150 hscroll vscroll , %TermList%
Gui, Add, Text, x412 y166 w400 h20, %SelectBraillePortText%
Gui, Add, ListBox, vComPort x412 y190 w400 h150 hscroll vscroll , %ComPorts%
Gui, Add, Button, vSend gValidate x640 y352 w100 h24 +Default, %OKBtn%
Gui, Add, Button, vCancel gGuiClose x750 y352 w100 h24, %CancelBtn%
Gui, Show, AutoSize Center, %ScriptName%
;Use Escape to immediately leave the program
Escape::
Gosub GuiClose
return
return
;--------------------------------------------------------------------------------------------
; Functions
;------------------------------------------------------------------------------------------
Validate:
GuiControlGet, Terminal
if Terminal =
{
Msgbox 0, %ScriptName%, %NeedToChooseAFileMsg%
ControlFocus, %SelectBrailleDisplayText%, %ScriptName%
Return
}
GuiControlGet, ComPort
if ComPort =
{
Msgbox 0, %ScriptName%, %NeedToChooseAPortMsg%
ControlFocus, %SelectBraillePortText%, %ScriptName%
Return
}
SetTimer, ChangeButtonNames, 50
Msgbox 1, %ScriptName%, %YouHaveSelectedMsg% %Terminal%`n%ConnectedToPortMsg% %ComPort%
IfMsgBox OK
{
IfInString ComPort, COM
{
FileAppend braille-device serial:%ComPort%`n, %CnfFile%
}
Else
{
FileAppend braille-device %ComPort%`n, %CnfFile%
}
StringReplace Terminal, Terminal, -, #
FileAppend braille-driver %Terminal%`n, %CnfFile%
; Restart BRLTTY if the -r parameter was passed
If 1 = -r
{
SplitPath, ComSpec,, SysDir
; Stop BrlAPI and BRLTTY if started
RunWait, %SysDir%\net.exe stop BrlApi
RunWait, %A_ScriptDir%\bin\brltty.exe -R
; Restart BRLTTY and BrlAPI
RunWait, %A_ScriptDir%\bin\brltty.exe -I
RunWait, %SysDir%\net.exe start BrlApi
}
Gosub GuiClose
}
ControlFocus, %SelectBrailleDisplayText%, %ScriptName%
return
;----------------------------------------------------------------------------------------------------------------------------------------
;End the program
GuiClose:
Gui, cancel
GuiEscape:
ExitApp
;----------------------------------------------------------------------------------------------------------------------------------------
; Support for different languages
SetLanguage:
; This procedure uses the AutoHotkey A_Language variable
; which contains the language code of the system the program is running on.
; To get a list of A_Language values and corresponding languages, goto:
; http://www.autohotkey.com/docs/misc/Languages.htm
languageCode_040c = French
languageCode_080c = French
languageCode_0c0c = French
languageCode_100c = French
languageCode_140c = French
languageCode_180c = French
languageCode_0416 = Portuguese
languageCode_0816 = Portuguese
the_language := languageCode_%A_Language% ; Get the name of the system's default language.
if the_language =
{
the_language := "English"
}
Gosub %the_language%
Return
ChangeButtonNames:
IfWinNotExist, %ScriptName%
return ; Keep waiting.
SetTimer, ChangeButtonNames, off
WinActivate
ControlSetText, Button1, %OKBtn%
ControlSetText, Button2, %CancelBtn%
return
English: ; English translation (default)
ScriptName = BRLTTY Configurator %Version%
CnfFileNotFoundMsg = File %CnfFile% not found.
NeedToChooseAFileMsg = You must select a braille display
NeedToChooseAPortMsg = You must select a communication port
YouHaveSelectedMsg = You selected terminal
ConnectedToPortMsg = attached to port
HelpText =
(
Please choose the braille display type and communication port.
- If your braille device is USB,
* if you have installed your manufacturer's driver, you should rather select its virtual COM port if it provides one,
else select "USB:" to use libusb-win32's filter,
* if you do not want or can not install your manufacturer's driver, you can select "USB:" here and install
libusb-win32's driver.
- If your braille device is serial, is connect through a serial to USB converter, or through bluetooth, just select the
proper COM port. Make sure to select the proper braille display as incorrect probing seems to possibly brick some devices.
)
SelectBrailleDisplayText = Select braille display
SelectBraillePortText = Select communication port
OKBtn = &OK
CancelBtn = &Cancel
Return
French: ; French translation
ScriptName = Configurateur BRLTTY %Version%
CnfFileNotFoundMsg = Le fichier %CnfFile% est introuvable
NeedToChooseAFileMsg = Vous devez choisir un afficheur braille
NeedToChooseAPortMsg = Vous devez choisir un port de communication
YouHaveSelectedMsg = Vous avez choisi l'afficheur
ConnectedToPortMsg = connecté au port
HelpText =
(
Veuillez choisir le type d'afficheur braille et le port de communication.
- Si votre afficheur utilise un port USB,
* si vous avez installé le pilote de votre fabriquant, vous devriez choisir son port COM virtuel s'il en fournit un, sinon
choisissez "USB:" pour utiliser le filtre libusb-win32,
* si vous ne voulez pas ou ne pouvez pas installer le pilote de votre fabriquant, vous pouvez choisir "USB:" ici et
installer le pilote libusb-win32.
- Si votre afficheur braille utilise un port série, ou est connecté via un adaptateur USB vers série, ou via bluetooth, choisissez simplement
le port COM approprié. Assurez-vous de choisir le bon afficheur car un choix incorrect semble parfois planter certains matériels.
)
SelectBrailleDisplayText = Choisissez l'afficheur braille
SelectBraillePortText = Choisissez le port de communication
OKBtn = &Accepter
CancelBtn = A&nnuler
Return
Portuguese: ; Portuguese translation
ScriptName = Configurador do BRLTTY %Version%
CnfFileNotFoundMsg = O ficheiro %CnfFile% não foi encontrado
NeedToChooseAFileMsg = Tem que seleccionar uma linha Braille
NeedToChooseAPortMsg = Tem que seleccionar uma porta de mcomunicação
YouHaveSelectedMsg = Seleccionou o terminal
ConnectedToPortMsg = conectado à porta
HelpText =
(
Por favor escolha o tipo da linha Braille e a porta de comunicação.
- Se o seu dispositivo Braille é USB,
* se tem instalado o driver do fabricante, deverá seleccionar a porta de série respectiva se existir, caso contrário
seleccione "USB:" para usar o filtro libusb-win32's.
* se não pretende ou não consegue instalar o driver do fabricante, pode seleccionar aqui "USB:" e instalar
o driver libusb-win32's.
- Se o seu dispositivo braille trabalha via porta série, seleccione a apropriada. Tenha a certeza que selecciona a linha Braille correcta visto que
utilizar drivers errados poderá danificar alguns dispositivos...
)
SelectBrailleDisplayText = Seleccione a linha Braille
SelectBraillePortText = Seleccione a porta de comunicação
OKBtn = &OK
CancelBtn = &Cancelar
Return