forked from campg2j003/jfw_nsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJFW.nsh
2548 lines (2314 loc) · 88.8 KB
/
JFW.nsh
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
/*
Jaws script installer
Written by Dang Manh Cuong <[email protected]> and Gary Campbell <[email protected]>
This installer requires the NSIS program from http://nsis.sourceforge.net version 3.0 or later.
This installer has the following features and limitations:
Features:
. Installs into all English versions of Jaws. This will be true as long as Freedom Scientific does not change the place to put scripts.
. The user can choose whether to install scripts for all users or the current user.
. Gets the correct install path of Jaws from the registry.
. Checks for a Jaws installation before starting setup. If Jaws is not installed, displays a warning message and quits.
. contains macros for extracting, compiling, deleting, and modifying scripts, so user can create a package containing multiple scripts quickly and easily.
. Macro to copy script from all users to current user.
Limitations:
Date created: Wednesday, September 20, 2012
Last updated: 2018-05-27
*/
!define JFW_NSH_REV 2.7
/*
Modifications:
*/
/*
Copyright (C) 2012-2018 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.
*/
!ifndef __JAWSSCRIPTSINCLUDED
!define __JAWSSCRIPTSINCLUDED
!ifndef JAWSMINVERSION
!define JAWSMINVERSION "" ; min version of JAWS for which this script can be installed
!endif
!ifndef JAWSMAXVERSION
!define JAWSMAXVERSION "" ; max version of JAWS for which this script can be installed
!endif
;If you want to enable support for choosing to install in either the current user or all users, define JAWSALLOWALLUSERS before including this file. If not defined, the default is to install into the current user. If you execute SetShellVarContext you should also set the variable JAWSSHELLCONTEXT to match.
!ifdef JAWSALLOWALLUSERS
!echo "Including support for choosing between current user and all users."
!else
!warning "Support for installing for all users is not enabled. To enable, define JAWSALLOWALLUSERS before including this file."
!EndIf ; else not JAWSALLOWALLUSERS
;Default value of $JAWSCompileMethod. Can be j=JAWSUtil, s=scompile, or n=do not compile JAWS scripts.
!ifndef JAWSDefaultCompileMethod
!define JAWSDefaultCompileMethod "j"
!EndIf
!ifndef JAWSSrcDir
!define JAWSSrcDir "script\" ;Folder relative to current folder containing JAWS scripts, empty or ends with backslash.
!EndIf
!ifndef JAWSDefaultProgDir
!define JAWSDefaultProgDir "$JAWSPROGDIR" ;Default directory containing JAWS program files (in JAWSDefaultProgDir\<JAWSVersion>)
!EndIf
!Define InstallFile $instdir\Install.ini ; file that stores information for the uninstaller
!Define tempFile $temp\Install.ini
!Define UnInstaller "Uninst.exe"
!Define JawsDir "$appdata\Freedom Scientific\Jaws" ;the folder where app data for Jaws 6.0 and above is located
!Define ScriptVerLangSep "/" ;separates JAWS version and language string. The language string is the folder under ScriptDir for the scripts.
!ifndef JAWSScriptLangs
!Define JAWSScriptLangs "" ;default supported languages.
!EndIf
!Define ScriptDefaultLang "enu" ;default language string, these script jsm files will be in the script source directory.
!Define Scriptdir "Settings" ;folder in $JawsDir for current user or earlier than 17.0, the script is put in a language folder under this folder
!Define JawsApp "JFW.EXE" ;Used to check if Jaws is installed
!Define Compiler "Scompile.exe" ;Used to compile script after installation
; Name of folder relative to $INSTDIR in which to install the installer source files.
!define JAWSINSTALLERSRC "Installer Source"
;We include langstring header after the MUI_LANGUAGE macro.
!include "uninstlog.nsh"
!include "logging.nsh"
!include "strfunc.nsh" ; used in DisplayJawsList to check for a digit, and other things
!include "filefunc.nsh" ; used to get language subfolders
!Include "WordFunc.nsh" ;for Version Compare
;!include "stack.nsh" ; debug
; Declare used functions from strfunc.nsh.
!ifndef StrTok_INCLUDED
${StrTok}
!endif
!ifndef StrLoc_INCLUDED
${StrLoc}
!endif
!include "nsDialogs.nsh"
;Multiuser configuration
!define MULTIUSER_EXECUTIONLEVEL Highest
!Define MULTIUSER_INSTALLMODE_INSTDIR "${ScriptName}"
;We don't want to use the registry key!
;!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTALLKEY}\${ScriptName}"
;!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "UninstallString"
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_INSTALLMODE_FUNCTION JAWSMuInstallMode
!define MULTIUSER_MUI
!include "multiuser.nsh"
;Modern UI configurations
!Include "MUI2.nsh"
;Timestamp of this run for messages.
!define /DATE MsgTimeStamp "%Y-%m-%d %H:%M"
;!define MUI_FINISHPAGE_NOAUTOCLOSE ; debug
;Global variables
var JAWSPROGDIR ; directory containing the JAWS programs.
var JAWSDLG ; handle of JAWS page dialog
var JAWSLV ; handle of JAWS versions list view
var JAWSGB
var JAWSRB1
var JAWSRB2
var JAWSREADME ;location of the README file for the Finish page
var JAWSFinishPageText ;Added immediately after the default finish page text, needs to start with $\r$\n if message should start on a new line, set to "" for no message
var JAWSCompileMethod ;Compile method: j=JAWSUtil, s=scompile, n=none
var JAWSFailedCompiles ;number of failed compiles in this run
;-----
;Multi-language script support
function GetVersionLangs
;$0 -- JAWS version
;Returns language subfolders separated by | in $1, count in $2.
;Uses defines ${JawsDir} and ${ScriptDir}.
push $R1
push $R2
Push $R6
Push $R7
Push $R8
Push $R9
StrCpy $R1 "" ;accumulator
StrCpy $R2 0 ; count
${Locate} "${JawsDir}\$0\${ScriptDir}" "/L=D /G=0 /M=???" "GetVersionLangsHelper"
Pop $R9
Pop $R8
Pop $R7
Pop $R6
StrCpy $2 $R2
pop $R2
StrCpy $1 $R1
Pop $R1
${if} $1 != ""
StrCpy $1 $1 -1
${endif}
FunctionEnd ;GetVersionLangs
Function GetVersionLangsHelper
StrCpy $R1 "$R1$R7|"
intop $R2 $R2 + 1 ;count
Push $R1 ;used to stop execution
FunctionEnd ; GetVersionLangsHelper
Function GetVerLang
;Separate version and lang dir.
;$0 - ver/lang pair, or just ver which will use default for lang
;Return: TOS = lang dir (default lang dir if none given), TOS -1 = ver
;Uses ${ScriptVerLangSep}, ${ScriptDefaultDir}
push $1 ; used for version
push $3 ;used for lang dir
${StrLoc} $3 "$0" "${ScriptVerLangSep}" ">"
${if} $3 != ""
${StrTok} $1 "$0" "${ScriptVerLangSep}" "0" "0"
${StrTok} $3 "$0" "${ScriptVerLangSep}" "1" "0"
${else}
;Assume $0 is just a version, so copy it.
StrCpy $1 "$0"
StrCpy $3 "${ScriptDefaultLang}"
${endif}
;$1 = version, $3 = lang dir
;TOS = old $3, TOS-1 = old $1
exch
; TOS = old $1, TOS-1 = old $3
exch $1 ; TOS = ver
exch ; TOS = old $3, TOS-1 = ver
exch $3 ; TOS = lang
FunctionEnd ;GetVerLang
!ifndef StrLoc_INCLUDED
${StrLoc}
!endif
function _StrContainsTok
;Report if token $1 is in $0 where $0 is a list of tokens with separator $2. $2 must be a single character.
; Returns "" in $3 if not found, a number >= 0 otherwise.
Push $R0
StrCpy $R0 "$2$0$2"
${StrLoc} $3 $R0 "$2$1$2" ">"
pop $R0
FunctionEnd ;_StrContainsTok
!macro StrContainsTok rslt list tok sep
;Determine if string tok is a token in list which is separated by character sep.
;Returns 1 in rslt if found, 0 otherwise.
push $3
push $0
push $1
push $2
StrCpy $0 "${list}"
StrCpy $1 "${tok}"
StrCpy $2 "${sep}"
call _StrContainsTok
${If} $3 == ""
;MessageBox MB_OK "StrContainsTok: $1 not found" ; debug
StrCpy $3 0
${Else}
StrCpy $3 1
${EndIf}
pop $2
pop $1
pop $0
exch $3
pop ${rslt}
!MacroEnd ;StrContainsTok
!define StrContainsTok "!InsertMacro strContainsTok"
;-----
;Additional scripts from Cuong's cjfw.nsh
!Macro CompileSingle JAWSVer Source
;Assumes $OUTDIR points to folder where source file is and compiled file will be placed.
;JAWSVer - JAWS version/lang or version, i.e. "10.0/enu" or "10.0"
;Source - name of script to compile without .jss extension
;return: writes error message on failure, returns exit code of scompile (0 if successful) in $1.
;Recommend for scripts wich have only one source (*.JSS) file, or don't make any modification to any original files
;this macro calls the function __CompileSingle_bx, which runs the
;JAWSUtil.vbs script to do the compile. This script copies all
;required files to a temp folder and uses the -d scompile option to
;compile the script. This makes it possible to compile versions of
;the script for multiple languages. The function __CompileSingle,
;which runs scompile directly, is currently retained in case it may be
;useful. __CompileSingle would save time because it doesn't store and
;delete any temporary files. It might be useful to compile a script
;for a single language more efficiently.
;Note that __CompileSingle and __CompileSingle_bx handle compiler output differently.
push $0
strcpy $0 ${JAWSVer}
push $R1
;StrCpy $R1 "$OUTDIR\${Source}"
StrCpy $R1 "${Source}"
${If} $JAWSCompileMethod == "j"
call __CompileSingle_bx
${ElseIf} $JAWSCompileMethod == "s"
call __CompileSingle
${EndIf}
pop $R1
pop $0
!MacroEnd
Function __CompileSingle
;$0 - JAWS version/lang or version, i.e. "10.0/enu" or "10.0"
;$R1 - name of script to compile without .jss extension
push $R0
push $R2 ;stdout/stderr output of scompile.
call GetVerLang
pop $0 ;lang, we don't need it
pop $0 ;version
call GetJawsProgDir
pop $R0
; $R0 has backslash at end of path.
StrCpy $R0 "$R0${Compiler}"
;StrCpy $R1 "$OUTDIR\${Source}"
;${GetFileAttributes} "$R1.jss" "all" $1
;DetailPrint "Attributes of file $R1.jss: $1"
!ifndef JAWSDEBUG ; debug
IfFileExists "$R0" +1 csNoCompile
!endif ; debug
!ifdef JAWSDEBUG
MessageBox MB_OK `Pretending to run nsexec::Exec '"$R0" "$R1.jss"'`
!Else ; not JAWSJEBUG
DetailPrint `Executing command '"$R0" "$R1.jss"'` ; debug
;nsexec::Exec '"$R0" "$R1.jss"'
;pop $1 ;exit code of scompile
;StrCpy $R0 "c:\progra~2\mingw_sylvan\win32\wbin\cp" ; debug
;nsexec::ExecToStack '"$R0" "$R1.jss" "$R1.jsb"' ; debug
nsexec::ExecToStack '"$R0" "$R1.jss"'
pop $1 ;exit code of scompile
pop $R2 ;scompile output
;MessageBox MB_OK "compile $R1.jss, SCompile returned $1$\r$\n$$OutDir=$OutDir, Output:$\R$\N$R2" ; debug
IntCmp $1 0 csGoodCompile +1 +1
DetailPrint "Could not compile $R1.jss, SCompile returned $1$\r$\n$$OutDir=$OutDir, Output:$\r$\n$R2$\r$\n"
MessageBox MB_OK "$(CouldNotCompile)"
GoTo csEnd
csGoodCompile:
DetailPrint "Compiled $R1.jss"
!EndIf ; else not JAWSDEBUG
GoTo csEnd
csNoCompile:
DetailPrint "Could not find JAWS script compiler $R0. You will need to compile it with JAWS Script Manager to use it."
MessageBox MB_OK "$(CouldNotFindCompiler)"
strcpy $1 1 ; return error
csEnd:
pop $R2
pop $R0
FunctionEnd ;__CompileSingle
;-----
;JAWSUtil, adapted from jfw_bx.nsi revision 1876 by Doug Lee.
!define ErrMsg DetailPrint
!define DetailPrint DetailPrint
!define un ""
Function ${UN}runJAWSUtil
; Run the included JAWSUtil utility.
; This runs jawsutil.vbs in a cmd shell to allow stdout to be sent to a file.
; $PLUGINSDIR is used so JAWSUtil.out/err will be automatically removed on installer exit.
; $0 -- The target JAWS version/language.
;$1 -- JAWSUtil command
; See JAWSUtil.vbs for command line syntaxes.
; Returns (on stack) 1 on success and 0 on failure.
; Usage:
; - Set $0 = JAWSBuild/JAWSLang.
; - set $1 to a JAWSUtil command like "compile myscripts.jss."
; - Call this function.
; - Pop the return value.
;pop $cs_cmd
;exch $1 ;command
push $R1
push $R8
push $R9
strcpy $R1 "$PLUGINSDIR\jawsutil"
${DetailPrint} 'JAWSUtil command: "$1" for JAWS $0'
; But don't print the following huge command line.
; nsExec::Exec doesn't, but we leave this here just in case.
setDetailsPrint none
clearErrors
; TODO: Cmd assumed, and 2> not tested on Windows versions before XP.
nsExec::Exec 'cmd /c $SYSDIR\CScript.exe //nologo "$PLUGINSDIR\jawsutil.vbs" $0 $1 > "$R1.out" 2>"$R1.err"'
;nsExec::Exec 'cmd /c $SYSDIR\CScript.exe //nologo "$PLUGINSDIR\jawsutil.vbs" -d $0 $1 > "$R1.out" 2>"$R1.err"' ; debug
pop $R9 ;exit code
setDetailsPrint both
${If} ${Errors}
${ErrMsg} "Command failed."
;$1=JAWSUtil command, $0=JAWS ver/lang.
messageBox MB_OK "$(JAWSUtilCommandFailed)" /SD IDOK
goto cs_fail
${EndIf}
push "$R1.err"
call ${UN}isFileNonblank
pop $R8 ;1 if file "nonblank"
${If} $R8 = 1
push "$R1.err"
push "Error output"
call ${UN}fileTextToDetails
${EndIf}
${If} $R9 = 0 ;JAWSUtil exit code
${AndIf} $R8 = 1 ;output file nonblank
; Unfortunately CScript can return 0 when it fails.
; It tends to send errors to stderr in such a case though.
; [DGL, 2010-04-08]
${ErrMsg} "Command failed."
messageBox MB_OK "$(JAWSUtilCommandFailed)" /SD IDOK
goto cs_fail
${EndIf}
${If} $R9 <> 0
${ErrMsg} "Command returned $R9."
push "$R1.out"
push "Output"
call ${UN}fileTextToDetails
messageBox MB_OK "$(JAWSUtilCommandFailedWithError)" /SD IDOK
goto cs_fail
${EndIf}
StrCpy $R1 "1"
goto cs_exit
cs_fail:
StrCpy $R1 "0"
cs_exit:
pop $R9
pop $R8
exch $R1
FunctionEnd
Function ${UN}isFileNonblank
; Returns 1 if the indicated text file is "blank" and 0 if not.
; Usage: push filename, call, pop result.
; "Blank" means the file contains no meaningful text.
exch $1
push $2
fileOpen $2 $1 r
${If} $2 == ""
; We call a missing file "blank."
StrCpy $1 "0"
goto nb_exit
${EndIf}
fileSeek $2 0 END $1
fileClose $2
${If} $1 > 4
; We allow four characters to be "blank" in case of extra CRLF's and such,
; but any meaningful content should be longer.
StrCpy $1 "1"
${Else}
StrCpy $1 "0"
${EndIf}
nb_exit:
pop $2
exch $1
FunctionEnd
Function ${UN}fileTextToDetails
; Absorb into the Details list the text of the indicated file,
; naming the block of lines as indicated.
; Usage: push path, push name (for details), call. No return value.
; Registers (preserved): $1 path and text lines, $2 name (for details), $3 file handle.
exch $2
exch
exch $1
push $3
clearErrors
fileOpen $3 $1 r
${If} $3 == ""
${DetailPrint} "Failed to open output file."
ClearErrors
${Else}
${DetailPrint} "$2:"
${Do}
fileRead $3 $1
${If} ${Errors}
${DetailPrint} "End of output."
${break}
${EndIf}
${DetailPrint} $1
${Loop}
clearErrors
fileClose $3
${EndIf}
pop $3
pop $1
pop $2
FunctionEnd
Function ${UN}setupJAWSUtil
; Prepare the JAWSUtil.vbs file for use in compiling etc.
; $PLUGINSDIR is used so JAWSUtil.vbs/.out will be automatically removed on installer exit.
${DetailPrint} "Preparing for JAWS script compilation."
InitPluginsDir
setDetailsPrint none
file "/oname=$PLUGINSDIR\jawsutil.vbs" jawsutil.vbs
setDetailsPrint both
FunctionEnd
Function ${UN}Quit
; Use this in place of the built-in Quit instruction to enable log writing.
; Does not preserve registers because it doesn't return anyway.
;${ErrMsg} "Writing log file."
;StrCpy $0 "$TEMP\${LOGFILE}"
;push $0
;call logging_DumpLog
;pop $1
;${If} $1 = 0
;${ErrMsg} "!Failed to write a log of this process to disk for examination by the script author."
;Quit
;${EndIf}
;${ErrMsg} "Log file written successfully."
;MessageBox MB_OK "A log of this run has been written to disk and will be shown when this installer exits.$\n\
Sending some or all of this log to the script author may help determine the cause of any problems encountered." /SD IDOK
;ExecShell "open" "$0"
;${If} ${Errors}
;${ErrMsg} "!Unable to display $0"
;${EndIf}
Quit
FunctionEnd
Function __CompileSingle_bx
;$0 - JAWS version/lang or version, i.e. "10.0/enu" or "10.0"
;$R1 - name of script to compile without .jss extension
;push $R0
;push $R2 ;stdout/stderr output of scompile.
;?? Seems we don't need to save $1 because it is result, but result not documented.
StrCpy $1 "compile $R1.jss" ;JAWSUtil command
!ifdef JAWSDEBUG
MessageBox MB_OK `Pretending to run JAWSUtil $0 "$R1.jss"'`
!Else ; not JAWSJEBUG
;DetailPrint `Executing JAWSUtil command '"$1"' for JAWS $0` ; debug
call runJAWSUtil
pop $1 ;exit code of JAWSUtil, 1=success, 0=error.
;pop $R2 ;scompile output
;MessageBox MB_OK "compile $R1.jss, jawsutil returned $1$\r$\n$$OutDir=$OutDir, Output:$\R$\N$R2" ; debug
IntCmp $1 1 csGoodCompile +1 +1
DetailPrint "Could not compile $R1.jss, JAWSUtil returned $1$\r$\n$$OutDir=$OutDir$\r$\n"
;MessageBox MB_OK "$(CouldNotCompile)"
;runJAWSUtil returns 0 for error, but we return 1.
StrCpy $1 1
GoTo csEnd
csGoodCompile:
DetailPrint "Compiled $R1.jss"
;runJAWSUtil returns 1 for success but we return 0.
StrCpy $1 0
!EndIf ; else not JAWSDEBUG
csEnd:
;pop $R2
;pop $R0
FunctionEnd ;__CompileSingle_bx
!Macro AdvanceCompileSingle JAWSVer Path Source
;Assumes $OUTDIR points to folder where source file is and compiled file will be placed.
;JAWSVer - JAWS version/lang or version, i.e. "10.0/enu" or "10.0"
;Path - desired context, either "current" or "all".
;Source - name of script to compile without .jss extension
;return: writes error message on failure, returns exit code of scompile (0 if successful)-- actually returns 1 on failure.
${If} "${Path}" = "current"
SetShellVarContext current
${Else}
SetShellVarContext all
${EndIf}
!insertmacro CompileSingle ${JAWSVer} ${Source}
${If} "$JAWSSHELLCONTEXT" = "current"
SetShellVarContext current
${Else}
SetShellVarContext all
${EndIf}
/*
ReadIniStr $0 ${TempFile} Install ${Path}
ReadIniStr $1 ${TempFile} Install Compiler
;Exec the sCompile.exe hiddently
;The extention of script source has been added
nsExec::Exec '"$1" "$0\${Source}.jss"'
*/
!MacroEnd
!Macro AddHotkey JKM Key Script
;Add hotkeys to *.jkm file
;Usually used by advanced user
;Assumes JKM file is in $OUTDIR.
;JKM - name of JKM file without the .jkm extension.
;key - string containing the key sequence, like "CTRL+JAWSKey+a".
;Script - name of script to bind to key.
;Entries will be added to the "Common Keys" section.
push $0
WriteIniStr "$OUTDIR\${JKM}.jkm" "Common Keys" "${Key}" "${Script}"
pop $0
!MacroEnd
!Macro CopyScript JAWSVer Name
;Use to copy any script source from share folder
push $0
push $1
SetShellVarContext "current"
strcpy $0 ${JAWSVer}
call GetJawsScriptDir
pop $0
IfFileExists $0\${Name} end
SetShellVarContext "all"
push $0
strcpy $0 ${JAWSVer}
call GetJAWSScriptDir
pop $1
pop $0
CopyFiles /silent "$1\${Name}" "$0\${Name}"
end:
SetShellVarContext $JAWSShellContext
pop $1
pop $0
!Macroend
!macro ModifyScript JAWSVer File Code
;Use to add some code to the existing script
;Like adding: use "skypewatch.jsb"" to default.jss
push $0
push $1
strcpy $0 $JAWSVer
call GetJAWSScriptDir
pop $0
FileOpen $1 "$0\${File}"
;Go to the botum of file
FileSeek $1 0 end
;Add a blank line to safely modify
FileWrite $1 `$\r$\n${Code}$\r$\n`
FileClose $1
pop $1
pop $0
!Macroend
!macro AdvanceModifyScript JAWSVer Path File Code
;Use to add some code to the existing script
;Like adding: use "skypewatch.jsb"" to default.jss
SetShellVarContext ${Path}
!insertmacro ModifyScript "${JAWSVer}" "${File}" "${Code}"
SetShellVarContext $JAWSShellContext
/*
ReadIniStr $0 ${TempFile} Install ${Path}
FileOpen $1 $0\${File} a
;Go to the bottom of file
FileSeek $1 0 end
;Add a blank lines to safely modify
FileWrite $1 "$\r$\n"
FileWrite $1 `${Code}`
FileClose $1
*/
!Macroend
!Macro Un.RemoveHotkey JAWSVer JKM Key
push $0
strcpy $0 ${JAWSVer}
call GetJAWSScriptDir
pop $1
DeleteIniStr "$1\${jkm}.jkm" "Common Keys" ${Key}"
pop $1
!macroend
;JAWS uninstall log macros.
;This file uses uninstlog macros UNINSTLOG_OPENINSTALL, UNINSTLOG_CLOSEINSTALL, File, FileDated, AddItem, and AddItemAlways.
!ifdef UNINSTALLLOGINCLUDED
!define JAWSLOGFILENAME "jawsuninstlog.txt"
!macro JAWSLOG_OPENINSTALL
push $UninstLog
!ifdef UninstLog
!define __JAWSLOGTemp ${UninstLog}
undef Uninstlog
!EndIf
!define UninstLog ${JAWSLOGFILENAME}
!insertmacro UNINSTLOG_OPENINSTALL
!macroend ;JAWSLOG_OPENINSTALL
!macro JAWSLOG_CLOSEINSTALL
!insertmacro UNINSTLOG_CLOSEINSTALL
pop $UninstLog
!undef UninstLog
!ifdef __JAWSLOGTemp
!define UninstLog ${__JAWSLOGTemp}
!undef __JAWSLOGTemp
!EndIf
!macroend ;JAWSLOG_CLOSEINSTALL
!macro JAWSLOG_UNINSTALL
push $UninstLog ; save log file handle if it exists
; if the log file name is defined, save it.
!ifdef UninstLog
!define __JAWSLOGTemp ${UninstLog}
!undef UninstLog
!EndIf
!define UninstLog ${JAWSLOGFILENAME}
!insertmacro UNINSTLOG_UNINSTALL
pop $UninstLog ; restore log file handle
!undef UninstLog
;If the log file name was previously defined, restore it.
!ifdef __JAWSLOGTemp
!define UninstLog ${__JAWSLOGTemp}
!undef __JAWSLOGTemp
!EndIf
!macroend ;JAWSLOG_UNINSTALL
;-----
; The following goes in the .nsh file.
!macro __FileDatedNF path item
!define __FileDatedNFUID ${__LINE__}
File /nonfatal "${path}${item}"
IfFileExists "$OUTDIR\${item}" 0 end${__FileDatedNFUID}
${AddItemDated} "$OUTDIR\${item}"
end${__FileDatedNFUID}:
!undef __FileDatedNFUID
!macroend
!define FileDatedNF "!insertmacro __FileDatedNF"
!else
;uninstlog not included, define dummy stuff to make everything work.
var UninstLogAlwaysLog
!macro JAWSLOG_OPENINSTALL
!macroend ;JAWSLOG_OPENINSTALL
!macro JAWSLOG_CLOSEINSTALL
!macroend ;JAWSLOG_CLOSEINSTALL
!macro JAWSLOG_UNINSTALL
!macroend ;JAWSLOG_UNINSTALL
!macro __FileDatedNF path item
File /nonfatal "${path}${item}"
!macroend
!define FileDatedNF "!insertmacro __FileDatedNF"
!define AddItem "!insertmacro AddItem"
!macro AddItem Path
!macroend
!macro File FilePath FileName
File "${FilePath}${FileName}"
!macroend
!macro WriteUninstaller Path
WriteUninstaller "${Path}"
!macroend
!define AddItemAlways "!insertmacro AddItem"
!define AddItemDated "!insertmacro AddItem"
!define File "!insertmacro File"
!define FileDated "!insertmacro File"
!define WriteUninstaller "!insertmacro WriteUninstaller"
!define SetOutPath "SetOutPath"
!define CreateDirectory CreateDirectory
!macro UNINSTLOG_OPENINSTALL
!macroend
!macro UNINSTLOG_CLOSEINSTALL
!macroend
!endif ;else uninstlog not included
!macro ReadCurrentRegStr dest subkey name
;Read from HKCU or HKLM depending on $JAWSSHELLCONTEXT
${If} $JAWSSHELLCONTEXT == "current"
readregstr ${dest} HKCU "${subkey}" "${name}"
${Else}
readregstr ${dest} HKLM "${subkey}" "${name}"
${EndIf}
!MacroEnd ;ReadCurrentRegStr
!Define ReadCurrentRegStr "!insertmacro ReadCurrentRegStr"
!macro WriteCurrentRegStr subkey name value
;Write to HKCU or HKLM depending on $JAWSSHELLCONTEXT
;!echo 'WriteCurrentRegStr: subkey=${subkey}, name=${name}, value=${value}' ; debug
${If} $JAWSSHELLCONTEXT == "current"
DetailPrint 'Writing to registry HKCU "${subkey}" "${name}" ${value}'
WriteRegStr HKCU "${subkey}" "${name}" '${value}'
${Else}
DetailPrint 'Writing to registry HKLM "${subkey}" "${name}" ${value}'
WriteRegStr HKLM "${subkey}" "${name}" '${value}'
${EndIf}
!MacroEnd ;WriteCurrentRegStr
!Define WriteCurrentRegStr "!insertmacro WriteCurrentRegStr"
!macro JAWSSetShellVarContext context
;So we can pass context as a variable.
${if} ${context} == "current"
DetailPrint "Setting shell context to current"
SetShellVarContext current
${Else}
DetailPrint "Setting shell context to all"
SetShellVarContext all
${EndIf}
!MacroEnd
!define JAWSSetShellVarContext "!insertmacro JAWSSetShellVarContext"
!Define JAWSScriptExt "|jsb|jsh|jss|qs|"
!Define JAWSScriptLangExt "|jbs|jkm|jsd|"
!Define JAWSSettingsExt "|jcf|jdf|jgf|"
;jsm and qsm are handled specially-- if $1 == enu they are placed in scripts, otherwise in the language folder.
!macro JawsScriptSetPath ext
;Set $OUTDIR to proper location for script file type ext.
;Usage: ${JawsScriptSetPath} ext
;ext -- script file extension.
;Assumes $0 = version, $1 = lang, shell var context is set to $SHELLSCRIPTCONTEXT.
DetailPrint "JawsScriptSetExt: ext=${ext}, version=$0, lang=$1, context=$JAWSSCRIPTCONTEXT" ; debug
Push $R1 ;scratch
Push $R2 ;$OUTDIR
StrCpy $R2 "$OUTDIR"
${VersionCompare} $0 "17.0" $R1
${If} $JAWSSCRIPTCONTEXT == "current"
${OrIf} $R1 = 2 ;< 17.0
;OutDir is set, do nothing.
${Else}
;17 or later and shared
${Do} ; a block we can exit out of
;if in JAWSScriptExt
${StrLoc} $R1 "${JAWSScriptExt}" "|${ext}|" ">"
${If} $R1 != ""
DetailPrint "JawsScriptSetPath: Setting path for ext in scriptext, strloc returned $R1" ; debug
StrCpy $R2 "${JAWSDir}\$0\Scripts"
${ExitDo}
${EndIf}
;if in ScriptLang
${StrLoc} $R1 "${JAWSScriptLangExt}" "|${ext}|" ">"
${If} $R1 != ""
DetailPrint "JawsScriptSetPath: Setting path for ext in scriptLangext, strloc returned $R1" ; debug
StrCpy $R2 "${JAWSDir}\$0\Scripts\$1"
${ExitDo}
${EndIf}
${If} ${ext} == "jsm"
${OrIf} ${ext} == "qsm"
${If} $1 == "${ScriptDefaultLang}"
DetailPrint "JawsScriptSetPath: ext=jsm, setting path for default lang ${ScriptDefaultLang}" ; debug
StrCpy $R2 "${JAWSDir}\$0\Scripts"
${Else}
DetailPrint "JawsScriptSetPath: ext=jsm, setting path for lang" ; debug
StrCpy $R2 "${JAWSDir}\$0\Scripts\$1"
${EndIf} ;${Else} not enu
${ExitDo}
${EndIf} ;jsm
${StrLoc} $R1 "${JAWSSettingsExt}" "|${ext}|" ">"
${If} $R1 != ""
DetailPrint "JawsScriptSetPath: Setting path for SettingsExt, strloc returned $R1" ; debug
StrCpy $R2 "${JAWSDir}\$0\SETTINGS\$1"
${ExitDo}
${EndIf}
DetailPrint "Warning: shouldn't be here, version=$0, lang=$1, ext=${ext}" ; debug
${ExitDo}
${Loop} ; end of block
${EndIf} ;${Else} shared
${If} $R2 != $OUTDIR
${SetOutPath} "$R2"
${EndIf}
Pop $R2
Pop $R1
!MacroEnd ;JawsScriptSetPath
!define JawsScriptSetPath "!insertmacro JawsScriptSetPath"
!macro JawsScriptFile SrcDir file
;Install a JAWS script file into the proper location. Takes into account whether installing into current user's scripts or shared scripts, JAWS version, and language.
;Usage: ${JawsScriptFile} SrcDir file
;SrcDir -- folder containing source file, used in FileDated macro.
;File -- name of file in SrcDir, used in FileDated macro and elsewhere.
;Assumes uninstlog macros available (either the real thing or dummies defined here) -- for SetOutPath and FileDated.
;Assumes $0 = version, $1 = lang, shell var context is set to $SHELLSCRIPTCONTEXT.
Push $R0 ;extension
DetailPrint "Enter JawsScriptFile: SrcDir=${SrcDir}, file=${File}, $$0=$0,"
StrCpy $R2 $OUTDIR
${GetFileExt} ${file} $R0
${JawsScriptSetPath} $r0
;install file
${FileDated} ${SrcDir} "${file}"
;${If} "$OUTDIR" != $R2
;;Make sure we exit with the same $OUTDIR we started with.
;${SetOutPath} "$R2"
;${EndIf}
Pop $R0
!MacroEnd ;JawsScriptFile
!define JawsScriptFile "!insertmacro JawsScriptFile"
; If not defined, we use this default macro. It copies the jss file, then tries to copy every other kind of script file if it exists.
!ifmacrondef JAWSInstallScriptItems
!macro JAWSInstallScriptItems
${FileDated} "${JAWSSrcDir}" "${ScriptApp}.jss"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jbf"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jbs"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jbt"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jcf"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jdf"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jfd"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jff"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jgf"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jkm"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jsd"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jsh"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.jsm"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.qs"
${FileDatedNF} "${JAWSSrcDir}" "${ScriptApp}.qsm"
!macroend ; JAWSInstallScriptItems
!EndIf ;macro JAWSInstallScriptItems not defined
;-----
; These are section indexes of sections whose state we need to know to write the installation summary. They are set by code in macro JAWSAfterInstallSections and used in function JAWSInstConfirmPre.
var JAWSSecInstSrc
var JAWSSecUninstaller
!ifmacrodef JAWSInstallFullItems
var JAWSSecInstDirFiles
!EndIf ;if JAWSInstallFullItems
;-----
;Now deals with version/language pairs.
Var INSTALLEDJAWSVERSIONS ;separated by |
var INSTALLEDJAWSVERSIONCOUNT
var SELECTEDJAWSVERSIONS
var SELECTEDJAWSVERSIONCOUNT
var JAWSSHELLCONTEXT ; value for SetShellVarContext-- current or all, default set in .OnInit
var JAWSSCRIPTCONTEXT ;whether to install the scripts for all users or current user, can be "all" or "current"
Var JAWSORIGINSTALLMODE ;original install mode, used to display Install For radio group
;-----
; Multiline edit box for nsdialogs
!define __NSD_TextMultiline_CLASS EDIT
!define __NSD_TextMultiline_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_MULTILINE}
!define __NSD_TextMultiline_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
!insertmacro __NSD_DefineControl TextMultiline
;-----
;Remove a style from a control.
!macro _NSD_RemoveStyle CONTROL STYLE
Push $0
push $1
System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_STYLE}) i .r0"
intop $1 ${STYLE} ~
intop $0 $0 & $1
System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_STYLE}, i $0)"
pop $1
Pop $0
!macroend ;_NSD_RemoveStyle
!define NSD_RemoveStyle "!insertmacro _NSD_RemoveStyle"
;-----
!macro _ForJawsVersions
; Execute a block of code for each selected JAWS version.
; Place before the code to be executed for each selected JAWS version.
; Follow the code block with _ForJawsVersionsEnd. These macros can be used more than once but they cannot be nested.
;In the code block $0 contains the current version and $R0 contains the 0-based index of this version in $SELECTEDJAWSVERSIONS. The code block must protect $R0 since it is the loop index.
!ifndef _ForJawsVersionsCounter
!define _ForJawsVersionsCounter 0
!else
!define /math _ForJawsVersionsCounterTemp ${_ForJawsVersionsCounter} + 1
!undef _ForJawsVersionsCounter
!define _ForJawsVersionsCounter ${_ForJawsVersionsCounterTemp}
!undef _ForJawsVersionsCounterTemp
!endif
push $0
push $R0
strcpy $R0 0
_ForJawsVersionsLoop${_ForJawsVersionsCounter}:
${StrTok} $0 "$SELECTEDJAWSVERSIONS" "|" $R0 0
Push $R0 ; protect loop index
;DetailPrint "ForJawsVersions: running code block with $$R0 = $R0" ; debug
!macroend ; _ForJawsVersions
!define ForJawsVersions "!insertmacro _ForJawsVersions"
!macro _ForJawsversionsEnd
; Place after the code that installs scripts to a version.
Pop $R0 ;restore loop index
;DetailPrint "ForJawsVersionsEnd: before incrementing, $$R0 = $R0" ; debug
intop $R0 $R0 + 1
intcmp $R0 $SELECTEDJAWSVERSIONCOUNT 0 _ForJawsVersionsLoop${_ForJawsVersionsCounter} 0
pop $R0
pop $0
!macroend
!define ForJawsVersionsEnd "!insertmacro _ForJawsVersionsEnd"
;-----
;Pages
!macro JAWSWelcomePage
!define MUI_WELCOMEPAGE_TITLE "$(WelcomePageTitle)"
!ifdef LegalCopyright
!define MUI_WELCOMEPAGE_TEXT "$(WelcomeTextCopyright)"
!else
!define MUI_WELCOMEPAGE_TEXT "$(WelcomeTextNoCopyright)"
!EndIf
!Insertmacro Mui_Page_Welcome
!macroend ; JAWSWelcomePage
!macro JAWSComponentsPage
;The order of the insstype commands is important.
insttype "$(InstTypeFull)"
insttype "$(InstTypeJustScripts)"
;insttype /NOCUSTOM
insttype /COMPONENTSONLYONCUSTOM
!define INST_FULL 1
!define INST_JUSTSCRIPTS 2
;!define INST_CUSTOM 33
!define INST_CUSTOM 32
; Displays 3 lines of about 98 chars.
!define MUI_COMPONENTSPAGE_TEXT_TOP "$(InstTypeFullMsg)"
;!define MUI_COMPONENTSPAGE_TEXT_COMPLIST text
;!define MUI_COMPONENTSPAGE_TEXT_INSTTYPE text
;!define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_TITLE text
;!define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO text ;Text to display inside the description box when no section is selected.
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsPageLeave
!insertmacro mui_page_Components
function ComponentsPageLeave
getcurinsttype $0
intop $0 $0 + 1
;messagebox MB_OK "ComponentsPageLeave: insttype = $0, justscripts = ${INST_JUSTSCRIPTS}" ; debug
;sectiongetflags $JAWSSecInstSrc $1 ; debug
;messagebox MB_OK "ComponentsPageLeave: SecInstSrc flags = $1" ; debug
intcmp $0 ${INST_JUSTSCRIPTS} end +1 +1
;sectiongetflags $JAWSSecUninstaller $1 ; debug
;messagebox MB_OK "ComponentsPageLeave: before selecting insttype = $0, section flags = $1" ; debug
!insertmacro SelectSection $JAWSSecUninstaller
!ifmacrodef JAWSInstallFullItems
!insertmacro SelectSection $JAWSSecInstDirFiles
!EndIf ;if JAWSInstallFullItems
;sectiongetflags $JAWSSecUninstaller $1 ; debug
;messagebox MB_OK "ComponentsPageLeave: after selecting section flags = $1" ; debug
end:
functionend
!macroend ;JAWSComponentsPage
;-----
; List view control
;(Windows) Messages, styles, and structs for handling a list view.