/
_default.py
578 lines (508 loc) · 25.6 KB
/
_default.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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
#appModules/_default.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/>
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
import gc
import comtypesClient
import datetime
import time
import tones
from keyUtils import key
import keyboardHandler
import IAccessibleHandler
import controlTypes
import api
import textHandler
import debug
import speech
import sayAllHandler
import virtualBuffers
from NVDAObjects import NVDAObject
import globalVars
from synthDriverHandler import *
import gui
import core
import config
import winUser
import appModuleHandler
import winKernel
import win32clipboard
import win32con
class appModule(appModuleHandler.appModule):
def event_switchStart(self,obj,nextHandler):
speech.cancelSpeech()
def event_switchEnd(self,obj,nextHandler):
speech.cancelSpeech()
def script_keyboardHelp(self,keyPress,nextScript):
if not globalVars.keyboardHelp:
state=_("on")
globalVars.keyboardHelp=True
else:
state=_("off")
globalVars.keyboardHelp=False
speech.speakMessage(_("keyboard help %s")%state)
script_keyboardHelp.__doc__=_("Turns keyboard help on and off. When on, pressing a key on the keyboard will tell you what script is associated with it, if any.")
def script_reportCurrentLine(self,keyPress,nextScript):
obj=api.getFocusObject()
info=obj.makeTextInfo(textHandler.POSITION_CARET)
info.expand(textHandler.UNIT_LINE)
speech.speakFormattedText(info)
def script_dateTime(self,keyPress,nextScript):
text=winKernel.GetTimeFormat(winKernel.getThreadLocale(), winKernel.TIME_NOSECONDS, None, None)+", "+winKernel.GetDateFormat(winKernel.getThreadLocale(), winKernel.DATE_LONGDATE, None, None)
speech.speakMessage(text)
script_dateTime.__doc__=_("Reports the current date and time")
def script_increaseRate(self,keyPress,nextScript):
rate=min(getSynth().rate+5, 100)
getSynth().rate=rate
config.conf["speech"][getSynth().name]["rate"]=rate
speech.speakMessage(_("rate %d%%")%rate)
script_increaseRate.__doc__=_("Increases the speech rate by 5 percent")
def script_decreaseRate(self,keyPress,nextScript):
rate=max(0, getSynth().rate-5)
getSynth().rate=rate
config.conf["speech"][getSynth().name]["rate"]=rate
speech.speakMessage(_("rate %d%%")%rate)
script_decreaseRate.__doc__=_("decreases the speech rate by 5 percent")
def script_increaseSetting(self,keyPress,nextScript):
#val = globalVars.settingsRing.increase()
speech.speakMessage("%s %s" % (globalVars.settingsRing.currentSettingName, globalVars.settingsRing.increase()))
script_increaseSetting.__doc__=_("Increases currently active setting in the synth settings ring")
def script_decreaseSetting(self,keyPress,nextScript):
#val = globalVars.settingsRing.decrease()
speech.speakMessage("%s %s" % (globalVars.settingsRing.currentSettingName, globalVars.settingsRing.decrease()))
script_decreaseSetting.__doc__=_("Decreases currently active setting in the synth settings ring")
def script_nextSetting(self,keyPress,nextScript):
#name = globalVars.settingsRing.next()
speech.speakMessage("%s %s"%(globalVars.settingsRing.next(), globalVars.settingsRing._get_currentSettingValue()))
script_nextSetting.__doc__=_("Moves to the next available setting in the synth settings ring")
def script_previousSetting(self,keyPress,nextScript):
# name = globalVars.settingsRing.previous()
speech.speakMessage("%s %s"%(globalVars.settingsRing.previous(), globalVars.settingsRing._get_currentSettingValue()))
script_previousSetting.__doc__=_("Moves to the previous available setting in the synth settings ring")
def script_toggleSpeakTypedCharacters(self,keyPress,nextScript):
if config.conf["keyboard"]["speakTypedCharacters"]:
onOff=_("off")
config.conf["keyboard"]["speakTypedCharacters"]=False
else:
onOff=_("on")
config.conf["keyboard"]["speakTypedCharacters"]=True
speech.speakMessage(_("speak typed characters")+" "+onOff)
script_toggleSpeakTypedCharacters.__doc__=_("Toggles on and off the speaking of typed characters")
def script_toggleSpeakTypedWords(self,keyPress,nextScript):
if config.conf["keyboard"]["speakTypedWords"]:
onOff=_("off")
config.conf["keyboard"]["speakTypedWords"]=False
else:
onOff=_("on")
config.conf["keyboard"]["speakTypedWords"]=True
speech.speakMessage(_("speak typed words")+" "+onOff)
script_toggleSpeakTypedWords.__doc__=_("Toggles on and off the speaking of typed words")
def script_toggleSpeakCommandKeys(self,keyPress,nextScript):
if config.conf["keyboard"]["speakCommandKeys"]:
onOff=_("off")
config.conf["keyboard"]["speakCommandKeys"]=False
else:
onOff=_("on")
config.conf["keyboard"]["speakCommandKeys"]=True
speech.speakMessage(_("speak command keys")+" "+onOff)
script_toggleSpeakCommandKeys.__doc__=_("Toggles on and off the speaking of typed keys, that are not specifically characters")
def script_toggleSpeakPunctuation(self,keyPress,nextScript):
if config.conf["speech"]["speakPunctuation"]:
onOff=_("off")
config.conf["speech"]["speakPunctuation"]=False
else:
onOff=_("on")
config.conf["speech"]["speakPunctuation"]=True
speech.speakMessage(_("speak punctuation")+" "+onOff)
script_toggleSpeakPunctuation.__doc__=_("Toggles on and off the speaking of punctuation. When on NVDA will say the names of punctuation symbols, when off it will be up to the synthesizer as to how it speaks punctuation")
def script_moveMouseToNavigatorObject(self,keyPress,nextScript):
speech.speakMessage(_("Move mouse to navigator"))
api.moveMouseToNVDAObject(api.getNavigatorObject())
script_moveMouseToNavigatorObject.__doc__=_("Moves the mouse pointer to the current navigator object.")
def script_moveNavigatorObjectToMouse(self,keyPress,nextScript):
speech.speakMessage(_("Move navigator object to mouse"))
(x,y)=winUser.getCursorPos()
obj=NVDAObjects.IAccessible.getNVDAObjectFromPoint(x,y)
if obj:
api.setNavigatorObject(obj)
speech.speakObject(obj,reason=speech.REASON_QUERY)
script_moveNavigatorObjectToMouse.__doc__=_("Sets the navigator object to the object that is directly under the mouse pointer")
def script_navigatorObject_current(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
speech.speakObject(curObject,reason=speech.REASON_QUERY)
return False
script_navigatorObject_current.__doc__=_("Reports the current navigator object")
def script_navigatorObject_currentDimensions(self,keyPress,nextScript):
obj=api.getNavigatorObject()
if not obj:
speech.speakMessage(_("no navigator object"))
location=obj.location
if not location:
speech.speakMessage(_("No location information for navigator object"))
(left,top,width,height)=location
speech.speakMessage(_("%d wide by %d high, located %d from left and %d from top")%(width,height,left,top))
script_navigatorObject_currentDimensions.__doc__=_("Reports the hight, width and position of the current navigator object")
def script_navigatorObject_toFocus(self,keyPress,nextScript):
obj=api.getFocusObject()
if not isinstance(obj,NVDAObject):
speech.speakMessage(_("no focus"))
api.setNavigatorObject(obj)
speech.speakMessage(_("move to focus"))
speech.speakObject(obj,reason=speech.REASON_QUERY)
script_navigatorObject_toFocus.__doc__=_("Sets the navigator object to the current focus")
def script_navigatorObject_parent(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
curObject=curObject.parent
if curObject is not None:
api.setNavigatorObject(curObject)
speech.speakObject(curObject,reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("No parents"))
script_navigatorObject_parent.__doc__=_("Sets the navigator object to the parent of the object it is currently on.")
def script_navigatorObject_next(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
curObject=curObject.next
if curObject is not None:
api.setNavigatorObject(curObject)
speech.speakObject(curObject,reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("No next"))
script_navigatorObject_next.__doc__=_("Sets the navigator object to the next object to the one it is currently on")
def script_navigatorObject_previous(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
curObject=curObject.previous
if curObject is not None:
api.setNavigatorObject(curObject)
speech.speakObject(curObject,reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("No previous"))
script_navigatorObject_previous.__doc__=_("Sets the navigator object to the previous object to the one it is currently on")
def script_navigatorObject_firstChild(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
curObject=curObject.firstChild
if curObject is not None:
api.setNavigatorObject(curObject)
speech.speakObject(curObject,reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("No children"))
script_navigatorObject_firstChild.__doc__=_("Sets the navigator object to the first child object to the one it is currently on")
def script_navigatorObject_nextInFlow(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
up=[]
down=[]
curObject=curObject.getNextInFlow(up=up,down=down)
if curObject is not None:
api.setNavigatorObject(curObject)
if len(up)>0:
for count in range(len(up)+1):
tones.beep(880*(1.25**count),50)
time.sleep(0.025)
if len(down)>0:
for count in range(len(down)+1):
tones.beep(880/(1.25**count),50)
time.sleep(0.025)
speech.speakObject(curObject,reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("end of flow"))
script_navigatorObject_nextInFlow.__doc__=_("Sets the navigator object to the object this object flows to.")
def script_navigatorObject_previousInFlow(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
up=[]
down=[]
curObject=curObject.getPreviousInFlow(up=up,down=down)
if curObject is not None:
api.setNavigatorObject(curObject)
if len(up)>0:
for count in range(len(up)+1):
tones.beep(880*(1.25**count),50)
time.sleep(0.025)
if len(down)>0:
for count in range(len(down)+1):
tones.beep(880/(1.25**count),50)
time.sleep(0.025)
speech.speakObject(curObject,reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("Beginning of flow"))
script_navigatorObject_previousInFlow.__doc__=_("Sets the navigator object to the object this object flows from.")
def script_navigatorObject_doDefaultAction(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
curObject.doDefaultAction()
script_navigatorObject_doDefaultAction.__doc__=_("Performs the default action on the current navigator object (example: presses it if it is a button).")
def script_navigatorObject_where(self,keyPress,nextScript):
"""Reports where the current navigator object is by reporting each of its ancestors"""
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
curObject=curObject.parent
while curObject is not None:
speech.speakMessage("in")
speech.speakObject(curObject,reason=speech.REASON_QUERY)
curObject=curObject.parent
script_navigatorObject_where.__doc__=_("Reports where the current navigator object is by reporting each of its ancestors")
def script_review_top(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_top(keyPress,nextScript)
script_review_top.__doc__=_("Moves the review cursor to the top line of the current navigator object")
def script_review_previousLine(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_previousLine(keyPress,nextScript)
script_review_previousLine.__doc__=_("Moves the review cursor to the previous line of the current navigator object")
def script_review_currentLine(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_currentLine(keyPress,nextScript)
script_review_currentLine.__doc__=_("Reports the line of the current navigator object where the review cursor is situated")
def script_review_nextLine(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_nextLine(keyPress,nextScript)
script_review_nextLine.__doc__=_("Moves the review cursor to the next line of the current navigator object")
def script_review_bottom(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_bottom(keyPress,nextScript)
script_review_bottom.__doc__=_("Moves the review cursor to the bottom line of the current navigator object")
def script_review_previousWord(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_previousWord(keyPress,nextScript)
script_review_previousWord.__doc__=_("Moves the review cursor to the previous word of the current navigator object")
def script_review_currentWord(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_currentWord(keyPress,nextScript)
script_review_currentWord.__doc__=_("Speaks the word of the current navigator object where the review cursor is situated")
def script_review_nextWord(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_nextWord(keyPress,nextScript)
script_review_nextWord.__doc__=_("Moves the review cursor to the next word of the current navigator object")
def script_review_startOfLine(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_startOfLine(keyPress,nextScript)
script_review_startOfLine.__doc__=_("Moves the review cursor to the start of the line where it is situated, in the current navigator object")
def script_review_previousCharacter(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_previousCharacter(keyPress,nextScript)
script_review_previousCharacter.__doc__=_("Moves the review cursor to the previous character of the current navigator object")
def script_review_currentCharacter(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_currentCharacter(keyPress,nextScript)
script_review_currentCharacter.__doc__=_("Reports the character of the current navigator object where the review cursor is situated")
def script_review_nextCharacter(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_nextCharacter(keyPress,nextScript)
script_review_nextCharacter.__doc__=_("Moves the review cursor to the next character of the current navigator object")
def script_review_endOfLine(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_endOfLine(keyPress,nextScript)
script_review_endOfLine.__doc__=_("Moves the review cursor to the end of the line where it is situated, in the current navigator object")
def script_review_moveToCaret(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_moveToCaret(keyPress,None)
script_review_moveToCaret.__doc__=_("Moves the review cursor to the position of the system caret, in the current navigator object")
def script_review_moveCaretHere(self,keyPress,nextScript):
obj=api.getNavigatorObject()
obj.script_review_moveCaretHere(keyPress,None)
script_review_moveCaretHere.__doc__=_("Moves the system caret to the position of the review cursor , in the current navigator object")
def script_speechMode(self,keyPress,nextScript):
curMode=speech.speechMode
speech.speechMode=speech.speechMode_talk
newMode=(curMode+1)%3
if newMode==speech.speechMode_off:
name=_("off")
elif newMode==speech.speechMode_beeps:
name=_("beeps")
elif newMode==speech.speechMode_talk:
name=_("talk")
speech.speakMessage(_("speech mode %s")%name)
speech.speechMode=newMode
script_speechMode.__doc__=_("Toggles between the speech modes of off, beep and talk. When set to off NVDA will not speak anything. If beeps then NVDA will simply beep each time it its supposed to speak something. If talk then NVDA wil just speak normally.")
def script_toggleVirtualBufferPassThrough(self,keyPress,nextScript):
api.toggleVirtualBufferPassThrough()
script_toggleVirtualBufferPassThrough.__doc__=_("Toggles virtualBuffer pass-through mode on and off. When on, keys will pass straight through the current virtualBuffer, allowing you to interact with a control without the virtualBuffer doing something else with the key.")
def script_quit(self,keyPress,nextScript):
gui.quit()
script_quit.__doc__=_("Quits NVDA!")
def script_showGui(self,keyPress,nextScript):
gui.showGui()
script_showGui.__doc__=_("Shows the NVDA interface window")
def script_review_sayAll(self,keyPress,nextScript):
o=api.getNavigatorObject()
info=o.reviewPosition.copy()
sayAllHandler.readText(info,sayAllHandler.CURSOR_REVIEW)
script_review_sayAll.__doc__ = _("reads from review cursor up to end of current text, moving the review cursor as it goes")
def script_navigatorObject_sayAll(self,keyPress,nextScript):
obj=api.getNavigatorObject()
sayAllHandler.readObjects(obj)
script_navigatorObject_sayAll.__doc__ = _("reads from navigator object ")
def script_sayAll(self,keyPress,nextScript):
o=api.getFocusObject()
v=virtualBuffers.getVirtualBuffer(o)
if v and not api.isVirtualBufferPassThrough():
sayAllHandler.sayAll(v.text_reviewPosition,v.text_characterCount,v.text_getNextLineOffsets,v.text_getText,v.text_reportNewPresentation,v._set_text_reviewPosition)
else:
info=o.makeTextInfo(textHandler.POSITION_CARET)
sayAllHandler.readText(info,sayAllHandler.CURSOR_CARET)
script_sayAll.__doc__ = _("reads from system caret up to end of text, moving the caret as it goes")
def script_reportFormatting(self,keyPress,nextScript):
o=api.getFocusObject()
info=o.makeTextInfo(textHandler.POSITION_CARET)
info.expand(textHandler.UNIT_CHARACTER)
formattedText=info.getFormattedText(includes=set([controlTypes.ROLE_FONTNAME,controlTypes.ROLE_FONTSIZE,controlTypes.ROLE_BOLD,controlTypes.ROLE_ITALIC,controlTypes.ROLE_UNDERLINE]))
for item in formattedText:
if isinstance(item,textHandler.FormatCommand):
if item.cmd in (textHandler.FORMAT_CMD_ON,textHandler.FORMAT_CMD_SINGLETON):
speech.speakMessage("%s %s"%(controlTypes.speechRoleLabels[item.format.role],item.format.value))
def script_reportCurrentFocus(self,keyPress,nextScript):
focusObject=api.getFocusObject()
if isinstance(focusObject,NVDAObject):
speech.speakObject(focusObject, reason=speech.REASON_QUERY)
else:
speech.speakMessage(_("no focus"))
script_reportCurrentFocus.__doc__ = _("reports the object with focus")
def script_reportStatusLine(self,keyPress,nextScript):
focus=api.getFocusObject()
statusBarObject=focus.statusBar
if not statusBarObject:
speech.speakMessage(_("no status bar found"))
return
speech.speakObject(statusBarObject,reason=speech.REASON_QUERY)
api.setNavigatorObject(statusBarObject)
script_reportStatusLine.__doc__ = _("reads the current aplication status bar and moves the navigation cursor to it")
def script_toggleReportObjectUnderMouse(self,keyPress,nextScript):
if config.conf["mouse"]["reportObjectUnderMouse"]:
onOff=_("off")
config.conf["mouse"]["reportObjectUnderMouse"]=False
else:
onOff=_("on")
config.conf["mouse"]["reportObjectUnderMouse"]=True
speech.speakMessage(_("Report object under mouse")+" "+onOff)
script_toggleReportObjectUnderMouse.__doc__=_("Toggles on and off the reporting of objects under the mouse")
def script_title(self,keyPress,nextScript):
obj=api.getForegroundObject()
if obj:
speech.speakObject(obj,reason=speech.REASON_QUERY)
script_title.__doc__=_("Reports the title of the current application or foreground window")
def script_speakForeground(self,keyPress,nextScript):
obj=api.getForegroundObject()
if obj:
speech.speakObject(obj,reason=speech.REASON_QUERY)
obj.speakDescendantObjects()
script_speakForeground.__doc__ = _("speaks the current foreground object")
def script_test_navigatorWindowInfo(self,keyPress,nextScript):
obj=api.getNavigatorObject()
debug.writeMessage("%s %s"%(obj.role,obj.windowHandle))
speech.speakMessage("%s"%obj)
speech.speakMessage(_("Control ID: %s")%winUser.getControlID(obj.windowHandle))
speech.speakMessage(_("Class: %s")%obj.windowClassName)
for char in obj.windowClassName:
speech.speakSymbol("%s"%char)
speech.speakMessage(_("internal text: %s")%winUser.getWindowText(obj.windowHandle))
speech.speakMessage(_("text: %s")%obj.windowText)
script_test_navigatorWindowInfo.__doc__ = _("reports some info about the current navigator object, mainly useful for developers: control id, class and internal text")
def script_toggleBeepOnProgressBarUpdates(self,keyPress,nextScript):
if config.conf["presentation"]["beepOnProgressBarUpdates"]:
onOff=_("off")
config.conf["presentation"]["beepOnProgressBarUpdates"]=False
else:
onOff=_("on")
config.conf["presentation"]["beepOnProgressBarUpdates"]=True
speech.speakMessage(_("Beep on progress bar updates")+" "+onOff)
script_toggleBeepOnProgressBarUpdates.__doc__=_("Toggles on and off the beeping on progress bar updates")
def script_toggleReportDynamicContentChanges(self,keyPress,nextScript):
if globalVars.reportDynamicContentChanges:
onOff=_("off")
globalVars.reportDynamicContentChanges=False
else:
onOff=_("on")
globalVars.reportDynamicContentChanges=True
speech.speakMessage(_("report dynamic content changes")+" "+onOff)
script_toggleReportDynamicContentChanges.__doc__=_("Toggles on and off the reporting of dynamic content changes, such as new text in dos console windows")
def script_toggleCaretMovesReviewCursor(self,keyPress,nextScript):
if globalVars.caretMovesReviewCursor:
onOff=_("off")
globalVars.caretMovesReviewCursor=False
else:
onOff=_("on")
globalVars.caretMovesReviewCursor=True
speech.speakMessage(_("caret moves review cursor")+" "+onOff)
script_toggleCaretMovesReviewCursor.__doc__=_("Toggles on and off the movement of the review cursor due to the caret moving.")
def script_toggleFocusMovesNavigatorObject(self,keyPress,nextScript):
if globalVars.focusMovesNavigatorObject:
onOff=_("off")
globalVars.focusMovesNavigatorObject=False
else:
onOff=_("on")
globalVars.focusMovesNavigatorObject=True
speech.speakMessage(_("focus moves navigator object")+" "+onOff)
script_toggleFocusMovesNavigatorObject.__doc__=_("Toggles on and off the movement of the navigator object due to focus changes")
#added by Rui Batista<ruiandrebatista@gmail.com> to implement a battery status script
def script_say_battery_status(self, keyPress, nextScript):
UNKNOWN_BATTERY_STATUS = 0xFF
AC_ONLINE = 0X1
NO_SYSTEM_BATTERY = 0X80
sps = winKernel.SYSTEM_POWER_STATUS()
if not winKernel.GetSystemPowerStatus(sps) or sps.BatteryFlag is UNKNOWN_BATTERY_STATUS:
debug.writeError("error accessing system power status")
return
if sps.BatteryFlag & NO_SYSTEM_BATTERY:
speech.speakMessage(_("no system battery"))
return
text = _("%d percent") % sps.BatteryLifePercent + " "
if sps.ACLineStatus & AC_ONLINE: text += _("AC power on")
elif sps.BatteryLifeTime!=0xffffffff:
text += _("%d hours and %d minutes remaining") % (sps.BatteryLifeTime / 3600, (sps.BatteryLifeTime % 3600) / 60)
speech.speakMessage(text)
script_say_battery_status.__doc__ = _("reports battery status and time remaining if AC is not plugged in")
def script_passNextKeyThrough(self,keyPress,nextScript):
keyboardHandler.passNextKeyThrough()
speech.speakMessage(_("Pass next key through"))
script_passNextKeyThrough.__doc__=_("The next key that is pressed will not be handled at all by NVDA, it will be passed directly through to Windows.")
def script_navigatorObject_copyCurrent(self,keyPress,nextScript):
curObject=api.getNavigatorObject()
if not isinstance(curObject,NVDAObject):
speech.speakMessage(_("no navigator object"))
return
text=""
if curObject.name is not None:
text=text+curObject.name
if curObject.name is not None and curObject.value is not None:
text=text+" "
if curObject.value is not None:
text=text+curObject.value
if text is not None:
win32clipboard.OpenClipboard()
try:
win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, text)
finally:
win32clipboard.CloseClipboard()
win32clipboard.OpenClipboard() # there seems to be a bug so to retrieve unicode text we have to reopen the clipboard
try:
got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
finally:
win32clipboard.CloseClipboard()
if got == text:
speech.speakMessage(_("%s copyed to clipboard")%got)
return False
script_navigatorObject_copyCurrent.__doc__=_("Copies name and value of current navigator object to the clipboard")