-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaudacity.JSS
1651 lines (1488 loc) · 52.4 KB
/
audacity.JSS
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
ni; JAWS script for Audacity multitrack sound editor V2.0.1.0 (http://audacity.sourceforge.net).
;Original author: Gary Campbell
;Modified: Dang Manh Cuong
;Vietnamese README file translation by Nguyen Hoang Giang.
; This constant contains the script version. The spacing of the following line must be preserved exactly so that the installer can read the version from it. There is exactly 1 space between const and the name, and 1 space on either side of the equals sign.
Const CS_SCRIPT_VERSION = "2.0 9/15/13 19:56UTC"
; This puts the copyright in the jsb file.
Messages
@msgCopyright
JAWS script for Audacity multitrack sound editor V2.0 or later (http://audacity.sourceforge.net).
Copyright (C) 2012, 2013 Gary Campbell and Dang Manh Cuong. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
See the file copying.txt for details.
@@
EndMessages
;Modifications:
Include "hjconst.jsh"
Include "hjglobal.jsh"
Include "common.jsm"
Include "audacity.jsm"
Include "msaaconst.jsh"
;The next line makes the script compiled on Jaws 13.0 to behave the same as it does with earlier versions.
;#pragma StringComparison partial
Const
ID_SELECTION_START = 2705,
ID_SELECTION_END = 2706, ; selection end or selection length
ID_END_RADIO = 2704,
ID_LENGTH_RADIO = 2703,
WC_wxWindowClass = "wxWindowClass", ; grabber control on toolbars
CS_INI_FILE="Audacity.jsi",
;For VST plugins
ID_Load_Preset=11001,
ID_Save_Preset=11002,
ID_Preset=11000,
;For user options.
CI_MESSAGES_OFF = 0,
CI_MESSAGES_FULL = 1, ; announce all messages
CI_TOOLBARS_OFF = 0,
CI_TOOLBARS_ON = 1, ; announce all toolbars
CI_ENTERPAUSE_OFF = 0, ; ENTER during play/record sent to ap
CI_ENTERPAUSE_ON = 1, ; ENTER pauses during play and record
;For the Edit chains dialog
ID_Chains_List=7001,
ID_Chain_Cmds_List=10002
/*
Const
;Names of toolbar button images for use when GetObjectInfoByName doesn't work. See GetAudacityState.
;Each ends with a trailing space.
CS_IMGRECORDPRESSED = "graphic 405 ",
CS_IMGPLAYPRESSED = "graphic 28 ",
CS_IMGPAUSEPRESSED = "graphic 161 "
*/
Globals
Int App_FirstTime,
Int gfEnterPause,
String gsJawsGuideLink, ;URL of Audacity Guide for JAWS users
;Commented this out 9/14/13.
;String gsJawsGuideTitle, ;title of Audacity Guide for JAWS users
Handle ghNull, ; to clear a handle
;When focus is on a slider with an associated edit, this holds the handle of the associated edit so that it will be spoken by SayNonHighlightedText. Be sure to set this to 0 when focus moves away from the slider.
Handle ghSliderEdit
Int Function AnnounceOn (String sKey)
;Indicate whether messages related to certain Audacity operations should be spoken. Return True if messages should be spoken.
;This function can be used to check if announce toolbars is on by specifying the appropriate value for sKey.
;sKey: key to read in audacity.JSI file
;New method given by Le Van Mai (Cuong's friend)
Return IniReadInteger ("Settings", sKey, 0, CS_INI_FILE)
EndFunction ; AnnounceOn
Int Function FocusInTrackPanel ()
;Indicates that the focus is in the track panel. It is used to prevent JAWS from speaking messages such as move to start of track etc. in the selection bar or toolbar.
Return (FocusInMainWindow () && GetWindowName(GetFocus()) == WN_TRACKPANEL )
EndFunction ; FocusInTrackPanel
Void Function SaySelectionPosition (Int iPosition, String sMessage)
;say the selection position field and pass the key to the ap.
;iPosition - control ID of the selection position control.
;sMessage - Spoken message
;This function now uses the method of saying selection start and end position, from Gary Campbell.
Var
Handle wnd, ;the window containing the selection bar
String sValue ;the selection field value
If DialogActive ()||MenusActive () Then
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey () ;allow users to type [, ] if focus in any text box
ElIf NoProject () Then
SayNoProject ()
Return
ElIf FocusInMainWindow () Then
TypeCurrentScriptKey ()
Pause () ;Wait for possible appearance of Boundary Position dialog.
If !DialogActive () Then
Pause ()
Let wnd=FindDescendantWindow (GetRealWindow (GetFocus ()), iPosition)
;If the Announce Messages option is on, speak the selection posision.
If AnnounceOn ("AnnounceMessage") Then
Let sValue=GetPositionField (wnd) ;get value of desired control
If !sValue Then ;the selection toolbar is turned off
Say (MSGNoSelection, OT_Error)
Else
SayFormattedMessage (OT_USER_REQUESTED_INFORMATION, sMessage, sMessage)
SayFormattedMessage (OT_USER_REQUESTED_INFORMATION, sValue, sValue)
EndIf ;say selection position
EndIf ; AnnounceOn
EndIf ; if !DialogActive
EndIf ; If FocusInMainWindow
EndFunction ; SaySelectionPosition
Void Function MarkerMovement (String sScript, String sAlert)
;Used for marker scripts, such as move start of selection to the left by a small amount
;First, check to make sure we have a project open.
If !UserBufferIsActive ()&&FocusInTrackPanel () && IsStopped () Then
If NoProject () Then
SayNoProject ()
Return
EndIf
TypeCurrentScriptKey ()
If AnnounceOn ("AnnounceMessage") Then
SayFormattedMessage (OT_Cursor, sAlert) ;The alert specified by calling script
EndIf ; if AnnounceOn
Else
;Not main window, perform the specified script, passed as a parameter. This method suggested by Doug Lee
FormatStringWithEmbeddedFunctions("<$" +sScript +">") ;instead of PerformScript method.
EndIf ; else not main window
EndFunction ; MarkerMovement
Void Function MouseMovement (String sScript)
;Used to bypass scripts such as MouseLeft, MouseRight etc. that are assigned to Audacity keys while in the main window.
;sScript - name of JAWS script to be executed when not in the Audacity main window.
If FocusInMainWindow ()
&& IsPCCursor () && !NoProject () Then ;focus at the main window, there's a project open, and the Jaws cursor is not active
TypeCurrentScriptKey () ;Audacity hotkey for adjusting gain
Else
;otherwise, perform the default JAWS script
formatStringWithEmbeddedFunctions("<$" +sScript +">")
EndIf ; else perform default script
EndFunction ; MouseMovement
Void Function AnnounceKeyMessage (String Message)
;This speaks an alert message when the user presses certain Audacity hotkeys, such as j or Shift J when appropriate, and passes the key to Audacity.
; Message - message to be spoken.
If !NoProject ()&&! UserBufferIsActive ()&&FocusInMainWindow () Then
If AnnounceOn ("AnnounceMessage") Then
SayUsingVoice (VCTX_Message, Message, OT_status) ;Speak alert message.
EndIf ; if AnnounceOn
TypeCurrentScriptKey ()
Else
;Not main window, etc.
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
EndIf ; else not main window, etc.
EndFunction ; AnnounceKeyMessage
Void Function SayNotStopped ()
If AnnounceOn ("AnnounceMessage") Then
SayFormattedMessage (ot_Error, msgNotStopped_l, msgNotStopped_s)
EndIf
EndFunction ; SayNotStopped
Void Function SayNoProject ()
;If no project is open, speak an alert message.
SayFormattedMessage (OT_error, msgNoProject_l, msgNoProject_s)
EndFunction ; SayNoProject
Int Function NoProject ()
;Return True if no project is open (focus in main window and no tracks in track panel).
;This is a feature from GoldWave scripts.
Var
Int iSubtype,
Handle hTemp,
Object obj
If !UserBufferIsActive () && FocusInMainWindow () Then
Let hTemp = GetRealWindow(GetFocus())
Let hTemp = FindWindow (hTemp, "", WN_TRACKPANEL)
SaveCursor ()
InvisibleCursor ()
MoveToWindow(hTemp)
Pause ()
Let obj = GetCurrentObject (0)
RestoreCursor ()
If obj.AccChildCount == 0 Then
Return True
EndIf ; if no tracks
EndIf ; if in main window
Return False
EndFunction ; NoProject
Function AutoStartEvent ()
Var
String sTemp,
Int iTemp
If !App_FirstTime Then
Let App_FirstTime=1
SayFormattedMessage (OT_No_Disable, MSG_App_Start)
;write default settings of Audacity script if settings file doesn't exist.
If !FileExists (FindJAWSPersonalizedSettingsFile (CS_INI_FILE, True)) Then
AddDefaultConfig ()
EndIf
Let gfEnterPause = IniReadInteger("Settings", "EnterPause", CI_ENTERPAUSE_ON, CS_INI_FILE)
;Read a value for the JAWS ref guide link, initialize to default.
;The disadvantage of storing these in globals is that you have to shut down and restart JAWS to make changes to an externally edited config file take effect. This could be avoided by reading from the config file when the values are needed. Because of the complexity of decoding this value, I choose to use globals despite this disadvantage. One could also decrease the complexity by using a second key for the title.
/*
Commented the title part of this feature out because it could make the hot key help claim it is for a different version of the guide than it was taken from.
Let sTemp = StringTrimTrailingBlanks (IniReadString ("Settings", "JAWSGuideLink", CS_JawsGuide_LINK + cScSpace + CS_JawsGuide_TITLE , CS_INI_FILE))
Let iTemp = StringContains (sTemp, cScSpace)
If iTemp Then
;We found a space and it's not the last character.
Let gsJawsGuideLink = StringLeft (sTemp, iTemp - 1)
Let gsJawsGuideTitle = StringRight(sTemp, StringLength (sTemp) - iTemp)
Else
Let gsJawsGuideLink = sTemp
Let gsJawsGuideTitle = CS_JawsGuide_Title
EndIf ; else no space
*/
Let gsJawsGuideLink = StringTrimTrailingBlanks (IniReadString ("Settings", "JAWSGuideLink", CS_JawsGuide_LINK, CS_INI_FILE))
EndIf ; if first time
EndFunction ; AutoStartEvent
Void Function SayNonHighlightedText (Handle hwnd, String buffer)
;If we are monitoring an edit associated with a slider, speak it.
If ghSliderEdit && hWnd == ghSliderEdit Then
Say (buffer, OT_NONHIGHLIGHTED_SCREEN_TEXT)
EndIf
SayNonhighlightedText (hWnd, buffer)
EndFunction ; SayNonHighlightedText
Globals Handle ghAudacityLastArea,
Handle ghAudacityLastToolbar
Int Function HandleCustomWindows ()
Var
Handle hParent,
Handle hFocus,
Handle hOld,
Handle hToolbar,
Handle hTemp,
Handle hTemp2,
String sName,
Int iMSAA_JCFOpt
Let hFocus = GetFocus ()
If DialogActive () && GetWindowSubtypeCode (hFocus) == WT_LEFTRIGHTSLIDER && GetWindowSubtypeCode (GetPriorWindow(hFocus)) == WT_EDIT Then
Let ghSliderEdit = GetPriorWindow (hFocus)
Let hTemp = GetPriorWindow(ghSliderEdit) ; control name
SayControlEx(hFocus,
GetWindowName(hTemp), "", ; control name, type
"", ; control state
"", "", ; Container name, type
"", "", ; value, position
"") ; dialog text
Return True
Else
;this must be executed any time focus moves away from a slider with a monitored edit, even when we exit the dialog
Let ghSliderEdit = ghNull
EndIf ;else not slider
;Announce when focus changes to a different area of the main window.
If !FocusInMainWindow() Then
If DialogActive () && GetWindowName(GetFocus()) == cscNULL Then
Let iMSAA_JCFOpt = GetJCFOption (OPT_MSAA_MODE)
SetJCFOption (OPT_MSAA_MODE, 2)
Let sName = GetObjectName()
SetJCFOption (OPT_MSAA_MODE, iMSAA_JCFOpt)
SayControlEx(GetFocus (),
sName, "", ; control name, type
"", ; control state
"", "", ; Container name, type
"", "", ; value, position
"") ; dialog text
Return True
ElIf IsWarningDialog ()&&!CheckAudacityVersion ("2,0,3") Then
SayWindowTypeAndText (GetFocus ())
Return true
EndIf ; no window name
Return HandleCustomWindows () ; not main window, continue with normal processing
EndIf ; if ! focus in main window
Let hParent = GetParent(hFocus)
If GetWindowName(hFocus) != WN_TRACKPANEL Then
Let hParent = GetParent(hParent)
EndIf ; if not track panel
; If hFocus is the track panel, hParent is its parent. Otherwise it is the grandparent of hFocus.
Let hOld = ghAudacityLastArea
If hParent != hOld Then
Let ghAudacityLastArea = hParent ; new area.
; We could use FocusInTrackPanel here but we've already tested most of its conditions.
If GetWindowName(hFocus) == WN_TRACKPANEL Then
Say (CS_TrackPanel, OT_Position)
Return HandleCustomWindows ()
EndIf ; if track panel
; We could also identify the selection by testing for WindowHierarchyX = 3.
If GetWindowName(GetFirstChild(hParent)) == WN_SELECTION Then
Say (CS_SelectionBar, OT_position)
Else
Say (CS_ToolBars, OT_position)
EndIf ; else toolbar
EndIf ; new area
If IsToolbar(GetToolbar ()) Then
Let hToolbar = GetToolbar ()
If hToolbar != ghAudacityLastToolbar Then
Let ghAudacityLastToolbar = hToolbar
If AnnounceOn ("AnnounceToolbars") Then
Say(GetWindowName(hToolbar), OT_CONTROL_GROUP_NAME)
EndIf
EndIf ; new toolbar
EndIf ; If IsToolbar
Return HandleCustomWindows () ; allow others to process
EndFunction ; HandleCustomWindows
Void Function SayFocusedObject ()
If FocusInTrackPanel () Then
;Suppress speaking of "track table" when moving between tracks.
SayObjectActiveItem ()
Else
SayFocusedObject ()
EndIf
EndFunction ; SayFocusedObject
Int Function IsToolbar (Handle hWnd)
; Return True if hWnd is one of the toolbars.
; The toolbars are in a window named ToolDock under the app window. It is the second window, the selection bar is inside the window following it, which is also named ToolDock.
; Assumes focus is in the main window.
Var
Handle hParent
Let hParent = GetParent(hWnd)
If hParent == 0 Then
;Make sure we have a window handle, just to be safe.
Let hParent = hWnd
EndIf ; no parent
If GetWindowName(hParent) == WN_TOOLDOCK && GetWindowHierarchyX(hParent) == 2 Then
Return True
EndIf
Return False
EndFunction ; IsToolbar
Handle Function GetToolbar ()
; When focus is on a toolbar control returns the handle of the toolbar containing the control.
Return GetParent(GetFocus())
EndFunction ; GetToolbar
Int Function FocusInMainWindow ()
;Returns True if the focused control is in the main window, False otherwise.
Var
Handle hFocus,
Handle hWnd
Let hFocus = GetFocus ()
If (GetWindowName(hFocus) == WN_TRACKPANEL || GetWindowName(GetParent(GetParent(hFocus))) == WN_TOOLDOCK) Then
Return True
EndIf
Return False
EndFunction ; FocusInMainWindow
String Function GetPositionField (Handle hWnd)
;Returns the value of the specified audio selection or position field.
;hWnd - the handle of the control.
;Return - the value of the position field suitable for speaking.
;We don't receive a control ID because of Audio Position field.
Var
String s,
String s1,
String s2,
String s3,
String s4,
Int i,
Int j
Let s = GetWindowText(hWnd, 0)
;Remove "uninteresting" stuff from the position, like leading zeros and ".000"
;A position can be in several formats, such as "0 0 h 0 0 m 0 0 .0 0 0 s " or "0 0 0 ,0 0 0 seconds ".
;These strings may need to be localized because H, M, ., and comma may be different.
Let s2 = StringStripAllBlanks(s)
If StringContains(s2, csGroupSep) Then
;SayString("no point") ; debug
Let s1 = csPositionGroupFmt ;does not include final 0.
Else
;Let s1 = "0 0 h 0 0 m 0 0 .0 0" ; we strip as much of this as matches off the front, we don't match the last 0 so it will say something.
;SayString("decimal") ; debug
Let s1 = ""
If StringContains (s2, csDays) Then
Let s1 = "00" + csDays
EndIf
Let s1 = s1 + csPositionHHMMFmt ; we strip as much of this as matches off the front up to the decimal point.
;SayString("s1 = " + s1) ; debug
;S1 contains what needs to be stripped from the staart of s2.
EndIf ; else contains decimal
; Return is in s1 and s2, passed by reference!!!
StringTrimCommon(s1, s2, 1) ; 1=trim from start
Let i = StringContains (s2, csDecimal)
If i > 0 Then
;Check all digits immediately following the decimal point for nonzero digits.
Let s3 = StringRight (s2, StringLength (s2) - i)
; We want to know if there are nonzero digits between the point and the next nondigit. We change all zeros to blanks and strip the leading blanks. The difference in length is the number of leading digits.
Let s4 = StringTrimLeadingBlanks(StringReplaceChars(s3, "0", " "))
If !StringContainsChars(Substring(s4, 1, 1), "123456789") Then
;No nonzeros, find the number of zeros.
Let j = StringLength(s3) - StringLength(s4)
;SayString("no nonzeros, j = " + IntToString(j)) ; debug
If i == 1 Then
Let s2 = "0" + s2
Let i = i + 1
EndIf ; if decimal is first char
Let s3 = StringReplaceSubstrings(substring(s2, 1, i - 1), "00", "0")
Let s2 = s3 + Substring (s2, i + 1 + j, StringLength(s2) - j)
Else
; nonzeros after decimal
Let s3 = StringReplaceSubstrings(substring(s2, 1, i - 1), "00", "0")
Let s2 = s3 + Substring (s2, i, StringLength(s2) - i + 1)
EndIf ; if no nonzeros after decimal
EndIf ; if decimal
; What we want is in s2.
;Don't say leading parts if they are 0.
Return s2
EndFunction ; GetPositionField
Script SaySelectionStart ()
;Say the value of the Selection Start field.
Var
Handle hWnd,
String sName,
String sValue
;I modified this script to make it work on open project only.
If NoProject () Then
SayNoProject ()
Return ;exit this script when no project open
ElIf DialogActive ()||MenusActive () Then
;Pass key to app.
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
Return
Else
Let hWnd = FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_START)
If (IsSameScript()) Then
SetFocus(hWnd)
Return
EndIf ;if IsSameScript
EndIf ; Else not NoProject()
Let sValue = GetPositionField(hWnd)
If !sValue Then ;some time user turn off the selection toolbar, so this condition varify the selection boolbar is turned on or not
Say (msgNoSelection, OT_error)
Else
SayMessage (OT_NO_DISABLE, sValue, sValue)
EndIf
EndScript ; SaySelectionStart
Script SaySelectionEnd ()
;Say the value of the Selection End or Length field.
Var
Handle hRadio,
Handle hEnd, ; handle of the edit control
String sName,
String sValue,
Int bIsSelected
If NoProject () Then
SayNoProject ()
Return
ElIf DialogActive () || MenusActive () Then
;Pass key to app.
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
Return
Else ; project open
Let hEnd = FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_END)
If (IsSameScript()) Then
SetFocus(hEnd)
Return
EndIf ; if IsSameScriqt
Let hRadio = FindDescendantWindow (GetRealWindow (GetFocus ()), ID_END_RADIO)
SaveCursor()
InvisibleCursor()
MoveToWindow (hRadio)
Pause()
Let bIsSelected = ControlIsChecked ()
RestoreCursor()
If (Not bIsSelected) Then
Let hRadio = GetNextWindow (hRadio)
EndIf
Let sName = GetWindowName (hRadio)
Let sValue = GetPositionField(hEnd)
If !sValue Then
Say (msgNoSelection, OT_error)
Else
SayMessage (OT_NO_DISABLE, sName + sValue, sValue)
EndIf
EndIf ; else project open
EndScript ; SaySelectionEnd
Script SayActiveCursor ()
; Say audio position field if PC cursor is on, or perform the normal function if pressed twice quickly.
Var
Handle hWnd,
String sValue
If (Not FocusInMainWindow () || IsSameScript () || Not IsPCCursor () || UserBufferIsActive ())||NoProject () Then
PerformScript SayActiveCursor()
Return
EndIf
Let hWnd = FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_END)
Let hWnd = GetNextWindow(GetNextWindow(hWnd))
;hWnd is Audio Position field.
Let sValue = GetPositionField(hWnd)
If !sValue Then
Say (msgNoSelection, OT_error)
Else
SayMessage (OT_NO_DISABLE, sValue, sValue)
EndIf
EndScript ; SayActiveCursor
Script ScriptFileName ()
ScriptAndAppNames(msgProgName)
EndScript ; ScriptFileName
Script AudacityScriptKeyHelp ()
Var
String sMessage
If UserBufferIsActive () Then
UserBufferDeactivate ()
EndIf
If !IsSameScript () && FocusInMainWindow () Then
Let sMessage=FormatString (MSGScript_Ver, CS_SCRIPT_VERSION)
SayFormattedMessage (OT_User_buffer, sMessage)
SayFormattedMessage (OT_User_Buffer, msgScriptkeyHelp)
;In JAWS 10 the produced link redisplays the Audacity hot keys list when activated from the text. It works correctly from the links list (JAWSKey+F7). This is the same behavior as seen in Outlook for Office 2003.
AddHotkeyLinks ()
;UserBufferAddText (cScBufferNewLine)
;UserBufferAddText (cMsgHotKeysLink, cFuncHotKey, cMsgHotKeysFunc)
;UserBufferAddText (cScBufferNewLine)
;UserBufferAddText (cMsgBuffExit)
Else
If DialogActive () && FindDescendantWindow (GetRealWindow (GetFocus ()), ID_Preset) Then
;We are in a dialog with a preset.
sayFormattedMessage (OT_User_Buffer, msgPresetHotkeyHelp)
;UserBufferAddText (cScBufferNewLine)
;UserBufferAddText(cMsgHotKeysLink, cFuncHotKey, cMsgHotKeysFunc)
;UserBufferAddText (cScBufferNewLine)
;UserBufferAddText (cMsgBuffExit)
AddHotkeyLinks ()
Return
EndIf
PerformScript HotKeyHelp ()
EndIf ;else not in main window
EndScript ; AudacityScriptKeyHelp
Function ShowJawsGuide()
SayMessage(OT_JAWS_MESSAGE, msgLoadingJawsGuide_L, msgLoadingJawsGuide_S)
run(gsJawsGuideLink)
EndFunction ; ShowJawsGuide
/*
Int Function IsWinKeyHelp()
;This causes Hotkey and window key help to display links to default JAWS and Windows hotkeys. To use it we could make it return a global that we set in AudacityHotKeyHelp.
Return True
EndFunction
*/
Script AudacityKeysHelp ()
If !IsSameScript() && FocusInMainWindow() Then
If UserBufferIsActive () Then
UserBufferDeactivate ()
EndIf
UserBufferClear()
UserBufferAddText(FormatString(msgAudacityHotKeyHelp1, CS_JawsGuide_Title, CS_JawsGuide_Author))
UserBufferAddText(gsJawsGuideLink, "ShowJawsGuide()", CS_JawsGuide_LINK_DISP)
UserBufferAddText(msgAudacityHotKeyHelp2)
;AddHotKeyLinks ()
UserBufferAddText (cScBufferNewLine)
UserBufferAddText (cMsgBuffExit)
UserBufferActivate()
JAWSTopOfFile()
SayLine()
Else
PerformScript WindowKeysHelp()
EndIf
EndScript ; AudacityKeysHelp
;These scripts allow access to Audacity keys assigned to the same keys as JAWS scripts such as MouseUp, MouseDown etc. The user can still perform the JAWS functions by turning on the JAWS cursor.
Script MouseUp ()
Var
String sScriptName
Let sScriptName="MouseUp" ;Perform script name for MouseUp in a variable
MouseMovement (sScriptName)
EndScript ; MouseUp
Script MouseDown ()
Var
String sScriptName
Let sScriptName="MouseDown"
MouseMovement (sScriptName)
EndScript ; MouseDown
Script MouseLeft ()
Var
String sScriptName
Let sScriptName="MouseLeft"
MouseMovement (sScriptName)
EndScript ; MouseLeft
Script MouseRight ()
Var
String sScriptName
Let sScriptName="MouseRight"
MouseMovement (sScriptName)
EndScript ; MouseRight
;The scripts below just speak an alert message when user presses certain Audacity hotkeys when they are active.
Script SelectionStart ()
;Say selection start position when user presses the left bracket key to set it.
SaySelectionPosition (ID_SELECTION_START, msgSelectionStart)
EndScript ; SelectionStart
Script SelectionEnd ()
;Say selection end position
SaySelectionPosition (ID_SELECTION_END, msgSelectionEnd)
EndScript ; SelectionEnd
Script FinishMarkerRight ()
;move the end of the selection to the right by a small amount.
Var
Handle hWnd,
String sScriptName,
String sMessage
If !IsPCCursor () || UserBufferIsActive () Then
PerformScript SelectNextCharacter ()
Return
EndIf
If !IsStopped () Then
;When playing this does long jump right, in recording I don't think it does anything, and it certainly doesn't select.
TypeCurrentScriptKey ()
Return
EndIf ; playing/recording
Let sMessage=FormatString (MSGMoveSelection, msgEnd, msgRight)
Let sScriptName="SelectNextCharacter" ;The default script to perform if not in main window
MarkerMovement (sScriptName, sMessage)
If AnnounceOn ("AnnounceMessage") && !NoProject () && FocusInTrackPanel () Then
pause ()
Let hWnd=FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_END)
Say(GetPositionField (hWnd), OT_USER_REQUESTED_INFORMATION)
EndIf
EndScript ; FinishMarkerRight
Script FinishMarkerLeft ()
Var
Handle hWnd,
String sScriptName,
String sMessage
If !IsPCCursor () || UserBufferIsActive () || !IsStopped () Then
PerformScript SelectPriorWord ()
Return
EndIf
Let sMessage=FormatString (MSGMoveSelection, msgEnd, msgLeft)
Let sScriptName="SelectPriorWord"
MarkerMovement (sScriptName, sMessage)
If AnnounceOn ("AnnounceMessage") && !NoProject () Then
pause ()
Let hWnd=FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_END)
Say(GetPositionField (hWnd), OT_USER_REQUESTED_INFORMATION)
EndIf
EndScript ; FinishMarkerLeft
Script StartMarkerRight ()
Var
Handle hWnd,
String sScriptName,
String sMessage
If !IsPCCursor () || UserBufferIsActive () || !IsStopped () Then
PerformScript SelectNextWord ()
Return
EndIf
Let sMessage=FormatString (MSGMoveSelection, msgStart, msgRight)
Let sScriptName="SelectNextWord"
MarkerMovement (sScriptName, sMessage)
If AnnounceOn ("AnnounceMessage") && !NoProject () Then
pause ()
Let hWnd=FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_START)
Say(GetPositionField (hWnd), OT_USER_REQUESTED_INFORMATION)
EndIf
EndScript ; StartMarkerRight
Script StartMarkerLeft ()
Var
Handle hWnd,
String sScriptName,
String sMessage
If !IsPCCursor () || UserBufferIsActive () Then
PerformScript SelectPriorCharacter ()
Return
EndIf
If !IsStopped () Then
;When playing this does long jump right, in recording I don't think it does anything, and it certainly doesn't select.
TypeCurrentScriptKey ()
Return
EndIf ; playing/recording
Let sMessage=FormatString (MSGMoveSelection, msgStart, msgLeft)
Let sScriptName="SelectPriorCharacter"
MarkerMovement (sScriptName, sMessage)
If AnnounceOn ("AnnounceMessage") && !NoProject () && FocusInTrackPanel () Then
pause ()
Let hWnd=FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_START)
Say(GetPositionField (hWnd), OT_USER_REQUESTED_INFORMATION)
EndIf
EndScript ; StartMarkerLeft
Script JawsHome ()
;If we are speaking an Audacity message, don't speak the key name.
If NoProject () && FocusInTrackPanel () &&!UserBufferIsActive () Then
SayNoProject ()
Return
EndIf ; if no project
If IsPCCursor () &&FocusInTrackPanel () &&! NoProject () &&!UserBufferIsActive ()&&AnnounceOn ("AnnounceMessage")Then
If !IsStopped () Then
SayNotStopped ()
Return
EndIf ;!IsStopped
JawsHome () ; do Home without speaking key label
SayFormattedMessage (OT_Position, FormatString (MSGMoveTo, msgStart, msgTrack))
Else
PerformScript JAWSHome ()
EndIf
EndScript ; JawsHome
Script JawsEnd ()
;If we are speaking an Audacity message, don't speak the key name.
If NoProject () && FocusInTrackPanel () &&!UserBufferIsActive () Then
SayNoProject ()
Return
EndIf ; if no project
If IsPCCursor () &&FocusInTrackPanel () && !NoProject () &&!UserBufferIsActive ()&&AnnounceOn ("AnnounceMessage") Then
If !IsStopped () Then
SayNotStopped ()
Return
EndIf ;!IsStopped
JAWSEnd () ; do End without speaking key label
SayFormattedMessage (OT_Position, FormatString (MSGMoveTo, msgEnd, msgAllAudio))
Else
PerformScript JAWSEnd ()
EndIf
EndScript ; JawsEnd
Script MoveToStartOfSelectedTracks ()
If DialogActive () ||MenusActive () Then
;A dialog is open, pass key to application and speak its label.
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
ElIf !IsTrackSelected () Then
SayNoTrackSelected ()
Return
Else
AnnounceKeyMessage (FormatString (MSGMoveTo, msgStart, msgSelectedTracks))
EndIf
EndScript ; MoveToStartOfSelectedTracks
Script MoveToEndOfSelectedTracks ()
If DialogActive () ||MenusActive () Then
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
ElIf !IsTrackSelected () Then
SayNoTrackSelected ()
Return
Else
AnnounceKeyMessage (FormatString (MSGMoveTo, msgEnd, msgSelectedTracks))
EndIf
EndScript ; MoveToEndOfSelectedTracks
Script SelectToBeginning ()
;Select to start of tracks.
If DialogActive () || MenusActive () Then
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
ElIf !IsTrackSelected () Then
SayNoTrackSelected ()
Return
Else
AnnounceKeyMessage (FormatString (MSGSelectedTo, msgStart))
EndIf
EndScript ; SelectToBeginning
Script SelectToEnd ()
;Select to end of tracks.
If DialogActive () || MenusActive () Then
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
ElIf !IsTrackSelected () Then
SayNoTrackSelected ()
Return
Else
AnnounceKeyMessage (FormatString (MSGSelectedTo, msgEnd))
EndIf
EndScript ; SelectToEnd
Script SelectFromStartOfLine ()
;Select from current position to the start of file
If NoProject () Then
SayNoProject ()
Return
EndIf ;No project
If IsPCCursor ()&&FocusInTrackPanel ()&&!NoProject ()&&!UserBufferIsActive () Then
SelectFromStartOfLine ()
If AnnounceOn ("AnnounceMessage") Then ;User can turn off this message
SayFormattedMessage (OT_No_Disable, msgStartOfFile) ;alerts when user activates this script at the main window, and a project is open
EndIf
;Otherwise, perform default script
Else
PerformScript SelectFromStartOfLine ()
EndIf
EndScript ; SelectFromStartOfLine
Script SelectToEndOfLine ()
;Select from current position to the end of file
If NoProject () Then
SayNoProject ()
Return
EndIf ;No project
If IsPCCursor ()&&FocusInTrackPanel ()&&!UserBufferIsActive ()&&!NoProject () Then
SelectToEndOfLine ()
If AnnounceOn ("AnnounceMessage") Then
SayFormattedMessage (OT_No_Disable, msgEndOfFile)
EndIf
Else
PerformScript SelectToEndOfLine ()
EndIf
EndScript ; SelectToEndOfLine
Script DeleteSelectedAudio ()
;Alerts when user deletes selected sound
If NoProject () Then
SayNoProject ()
Return
ElIf DialogActive () || MenusActive () Then
;Pass key to app.
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
Return
ElIf !IsTrackSelected () Then
SayNoTrackSelected ()
Return
ElIf FocusInMainWindow () Then
If !IsStopped () Then
SayNotStopped ()
Return
EndIf ; If not stopped
TypeCurrentScriptKey ()
If AnnounceOn ("AnnounceMessage") Then
SayFormattedMessage (OT_Jaws_Message, MSGDelete_l, MSGDelete_s)
EndIf ; if AnnounceOn
Else ; not main window, etc.
; !NoProject () && !DialogActive () && !MenusActive () && IsTrackSelected () && !FocusInTrackPanel ()
; Just in case it is used somewhere else (like CTRL+k). Actually, we could do it at the top of the script and eliminate this else.
SayCurrentScriptKeyLabel ()
TypeCurrentScriptKey ()
EndIf ; else not main window, etc.
EndScript ; DeleteSelectedAudio
Script JawsDelete ()
;If focus is in the main window, a project exists, and audio is selected, the DEL key will delete it. In this case we perform the script DeleteSelectedAudio. Otherwise we perform the defaault script.
If FocusInMainWindow () Then
; (!FocusInMainWindow () || IsTrackSelected ()) && (FocusInTrackPanel ()&&!NoProject ())
PerformScript DeleteSelectedAudio()
Else
; NoProdect() || ((!FocusInMainWindow () || IsTrackSelected ()) && !FocusInTrackPanel ()) ; ?? not sure these are t`he right conditions here
PerformScript JAWSDelete ()
EndIf
EndScript ; JawsDelete
Script JAWSBackspace ()
;This script is similar to the JawsDelete script.
If FocusInTrackPanel ()&&!NoProject () Then
PerformScript DeleteSelectedAudio()
Else
PerformScript JAWSBackspace()
EndIf
EndScript ; JAWSBackspace
Script SayPriorCharacter ()
Var
Handle hWnd
If !userBufferIsActive () && AnnounceOn ("AnnounceMessage") && IsPCCursor () && FocusInTrackPanel () && IsStopped () Then
If NoProject () Then
SayNoProject ()
Return
EndIf ; if no project
TypeCurrentScriptKey ()
Pause ()
Let hWnd=FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_START)
Say(GetPositionField (hWnd), OT_USER_REQUESTED_INFORMATION)
Else
PerformScript SayPriorCharacter ()
EndIf
EndScript ; SayPriorCharacter
Script SayNextCharacter ()
Var
Handle hWnd
If !userBufferIsActive () && AnnounceOn ("AnnounceMessage") && IsPCCursor () && FocusInTrackPanel () && IsStopped () Then
If NoProject () Then
SayNoProject ()
Return
EndIf ; if no project
TypeCurrentScriptKey ()
Pause ()
Let hWnd=FindDescendantWindow (GetRealWindow (GetFocus ()), ID_SELECTION_START)
Say(GetPositionField (hWnd), OT_USER_REQUESTED_INFORMATION)
Else
PerformScript SayNextCharacter ()
EndIf
EndScript ; SayNextCharacter
Script Copy ()
;Copy selected sound to clipboard in main window.
If !IsTrackSelected () &&!UserBufferIsActive ()&&!DialogActive () && !MenusActive () Then
SayNoTrackSelected ()
Return
ElIf FocusInMainWindow ()
&&!UserBufferIsActive () Then ;this second condition makes the default script active in virtual viewer
If NoProject () Then
SayNoProject ()
Return
EndIf ; no project
If !IsStopped () Then
SayNotStopped ()
Return
EndIf
TypeCurrentScriptKey ()
If AnnounceOn ("AnnounceMessage") Then
SayUsingVoice (VCTX_Message, msgCopyAudio, OT_status) ;speak alert message
EndIf ; if AnnounceOn
Else
;If no project open, or focus in other windows, perform the default script
PerformScript CopySelectedTextToClipboard ()
EndIf
EndScript ; Copy
Script CutToClipboard ()
If !IsTrackSelected () &&! DialogActive () Then
SayNoTrackSelected ()
Return
ElIf FocusInMainWindow ()
&&!UserBufferIsActive () Then ;this second condition makes the default script active in virtual viewer
If NoProject () Then
SayNoProject ()