-
Notifications
You must be signed in to change notification settings - Fork 0
/
AHKCommandPicker.ahk
1300 lines (1083 loc) · 63.1 KB
/
AHKCommandPicker.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
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
/*
IDEAS:
- Have the GUI optional. Instead can just press CapsLock to bring up tooltip that says "Enter Command", and then user types in the tooltip instead of popping the large GUI. Could still autocomplete the command and show it in the tooltip though.
- Maybe just hide the GUI instead of actually closing it every time; this would be good for tooltip mode too, since the tooltip could show the currently selected command from the window.
- Allow user to create new simple commands easily from the GUI and save them in their own file (open file/program, path, website).
- Use Ctrl+Space to copy the full command/parameter into the input textbox, and Ctrl+, to copy it with a trailing comma (easier for parameters). Or maybe use Shift instead of Ctrl.
*/
; Use the two following commands to debug a script.
;ListVars
;Pause
#SingleInstance force ; Make it so only one instance of this script can run at a time (and reload the script if another instance of it tries to run).
#NoEnv ; Avoid checking empty variables to see if they are environment variables (better performance).
;==========================================================
; Global Variables - prefix everything with "cp" for Command Picker, so that variable/function names are not likely to conflict with user variables/function names.
;==========================================================
_cpWindowName := "AHK Command Picker v1.3.2"
_cpWindowGroup := "" ; The group that will hold our Command Picker window so we can reference it from # directive statements (e.g. #IfWinExists).
_cpCommandList := "" ; Will hold the list of all available commands.
_cpCommandSelected := "" ; Will hold the command selected by the user.
_cpSearchedString := "" ; Will hold the actual string that the user entered.
_cpCommandArray := Object() ; Will hold the array of all Command objects.
_cpCommandDelimiter := "|" ; The character used to separate each command in the _cpCommandList. This MUST be the pipe character in order to work with a ListBox/ComboBox/DropDownList/Tab.
_cpCommandIsRunning := false ; Tells if a Command is currently being executed or not.
; Delimeters/Separators seen or used by the user.
_cpParameterDelimiter := "," ; The character used to separate each parameter in the AddCommand() function's parameter list and when manually typing in custom parameters into the search box. Also used to separate and each command in the AddCommands() function's command list. This MUST be a comma for the Regex whitespace removal to work properly, and it makes it easy to loop through all of the parameters using CSV.
_cpCommandParameterListSeparator := "," ; The character used to separate the command name from the parameter list when the user is typing their command.
_cpCommandDescriptionSeparator := "=>" ; The character or string used to separate the command name from the description of what the command does.
_cpCommandParameterSeparator := "," ; The character or string used to separate the command name from the command's preset parameter name/value in the Listbox.
_cpParameterNameValueSeparator := "|" ; The character used to separate a preset parameter's name from its value, in the AddCommand() function's parameter list.
_cpCommandNameValueSeparator := "|" ; The character used to separate a command's name from its value, in the AddCommands() function's command list.
;----------------------------------------------------------
; Global Variables Used By The User In Their Code.
;----------------------------------------------------------
_cpActiveWindowID := "" ; Will hold the ID of the Window that was Active when this picker was launched.
_cpDisableEscapeKeyScriptReloadUntilAllCommandsComplete := false ; Variable that user can set to True to disable the Escape key from reloading the script.
;----------------------------------------------------------
; AHK Command Picker Settings - Specify the default Command Picker Settings, then load any existing settings from the settings file.
;----------------------------------------------------------
_cpSettingsFilePath := A_ScriptDir . "\AHKCommandPicker.settings"
_cpShowAHKScriptInSystemTray := true
_cpWindowWidthInPixels := 700
_cpFontSize := 10
_cpNumberOfCommandsToShow := 20
_cpCommandMatchMethod := "Type Ahead" ; Valid values are: "Type Ahead" and "Incremental".
_cpShowSelectedCommandWindow := true
_cpNumberOfSecondsToShowSelectedCommandWindowFor := 2.0
_cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand := true
_cpNumberOfSecondsToShowSelectedCommandWindowForWhenInfoIsReturnedFromCommand := 4.0
_cpEscapeKeyShouldReloadScriptWhenACommandIsRunning := true
CPLoadSettings()
;==========================================================
; Load Command Picker Settings From File.
;==========================================================
CPLoadSettings()
{
; Include any global setting variables the we need.
global _cpSettingsFilePath, _cpWindowWidthInPixels, _cpNumberOfCommandsToShow, _cpShowAHKScriptInSystemTray, _cpShowSelectedCommandWindow, _cpCommandMatchMethod, _cpNumberOfSecondsToShowSelectedCommandWindowFor, _cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand, _cpNumberOfSecondsToShowSelectedCommandWindowForWhenInfoIsReturnedFromCommand, _cpEscapeKeyShouldReloadScriptWhenACommandIsRunning
; If the file exists, read in its contents and then delete it.
If (FileExist(_cpSettingsFilePath))
{
; Read in each line of the file.
Loop, Read, %_cpSettingsFilePath%
{
; Split the string at the = sign
StringSplit, setting, A_LoopReadLine, =
; If this is a valid setting line (e.g. setting=value)
if (setting0 = 2)
{
; Get the setting variable's value
_cp%setting1% = %setting2%
}
}
}
; Save the settings.
CPSaveSettings()
; Apply any applicable settings.
CPShowAHKScriptInSystemTray(_cpShowAHKScriptInSystemTray)
}
;==========================================================
; Save Command Picker Settings To File.
;==========================================================
CPSaveSettings()
{
; Include any global setting variables the we need.
global _cpSettingsFilePath, _cpWindowWidthInPixels, _cpNumberOfCommandsToShow, _cpShowAHKScriptInSystemTray, _cpShowSelectedCommandWindow, _cpCommandMatchMethod, _cpNumberOfSecondsToShowSelectedCommandWindowFor, _cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand, _cpNumberOfSecondsToShowSelectedCommandWindowForWhenInfoIsReturnedFromCommand, _cpEscapeKeyShouldReloadScriptWhenACommandIsRunning
; Delete and recreate the settings file every time so that if new settings were added to code they will get written to the file.
If (FileExist(_cpSettingsFilePath))
{
FileDelete, %_cpSettingsFilePath%
}
; Write the settings to the file (will be created automatically if needed)
; Setting name in file should be the variable name, without the "_cp" prefix.
FileAppend, CPShowAHKScriptInSystemTray=%_cpShowAHKScriptInSystemTray%`n, %_cpSettingsFilePath%
FileAppend, WindowWidthInPixels=%_cpWindowWidthInPixels%`n, %_cpSettingsFilePath%
FileAppend, NumberOfCommandsToShow=%_cpNumberOfCommandsToShow%`n, %_cpSettingsFilePath%
FileAppend, CommandMatchMethod=%_cpCommandMatchMethod%`n, %_cpSettingsFilePath%
FileAppend, ShowSelectedCommandWindow=%_cpShowSelectedCommandWindow%`n, %_cpSettingsFilePath%
FileAppend, NumberOfSecondsToShowSelectedCommandWindowFor=%_cpNumberOfSecondsToShowSelectedCommandWindowFor%`n, %_cpSettingsFilePath%
FileAppend, ShowSelectedCommandWindowWhenInfoIsReturnedFromCommand=%_cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand%`n, %_cpSettingsFilePath%
FileAppend, NumberOfSecondsToShowSelectedCommandWindowForWhenInfoIsReturnedFromCommand=%_cpNumberOfSecondsToShowSelectedCommandWindowForWhenInfoIsReturnedFromCommand%`n, %_cpSettingsFilePath%
FileAppend, EscapeKeyShouldReloadScriptWhenACommandIsRunning=%_cpEscapeKeyShouldReloadScriptWhenACommandIsRunning%`n, %_cpSettingsFilePath%
}
;==========================================================
; Add a Dummy command to use for debugging.
;==========================================================
AddNamedCommand("Dummy Command", "DummyCommand", "A command that doesn't do anything, but can be useful for testing and debugging", "Parameter1Name|Parameter1Value, Parameter2Value,Param3Name|Param3Value,Param4Value")
DummyCommand(parameters = "")
{
; Example of how to check if parameters were provided.
if (parameters != "")
MsgBox, Parameters were provided!
; Example of how to loop through the parameters
Loop, Parse, parameters, CSV
MsgBox Item %A_Index% is '%A_LoopField%'
return, "This is some text returned by the dummy command."
}
;==========================================================
; Inserts the scripts containing the commands (i.e. string + function) to run.
; The scripts we are including should add commands and their associated functions.
;
; Example:
; AddCommand("SQL", "Launch SQL Management Studio")
; SQL()
; {
; Run "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
; return false ; (optional) Return false to not display the command text after running the command.
; }
;==========================================================
#Include %A_ScriptDir%\CommandScriptsToInclude.ahk
;==========================================================
; Hotkey to launch the Command Picker window.
;==========================================================
f5::
SetCapslockState, Off ; Turn CapsLock off after it was pressed
CPLaunchCommandPicker()
return
;==========================================================
; Launch the Command Picker window.
;==========================================================
CPLaunchCommandPicker()
{
; Let this function know about the necessary global variables.
global _cpWindowName, _cpActiveWindowID
; If the Command Picker Window is not already open and in focus.
if !WinActive(_cpWindowName)
{
_cpActiveWindowID := WinExist("A") ; Save the ID of the Window that was active when the picker was launched.
}
CPPutCommandPickerWindowInFocus()
}
;==========================================================
; Hotkey to reload the AHK Command Picker when it is executing a command.
; This can be used if one of the scripts is out of control and you need to kill it quickly.
;==========================================================
Esc Up::
global _cpEscapeKeyShouldReloadScriptWhenACommandIsRunning, _cpCommandIsRunning, _cpDisableEscapeKeyScriptReloadUntilAllCommandsComplete
; Rethrow the Escape keypress that we intercepted.
SendInput, {Esc}
; If the Escape key is allowed to reload the script when a Command is running, AND a Command is running, AND the user hasn't temporarily disabled the Escape key refresh functionaliry, then reload the script.
if (_cpEscapeKeyShouldReloadScriptWhenACommandIsRunning && _cpCommandIsRunning && !_cpDisableEscapeKeyScriptReloadUntilAllCommandsComplete)
Run, %A_ScriptFullPath%
return
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Only process the following hotkeys in this Command Picker window.
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#IfWinActive, ahk_group _cpWindowGroup
;==========================================================
; Intercept the Up and Down actions to move through the commands in the listbox.
;==========================================================
Up::CPForwardKeyPressToListBox("Up") return
Down::CPForwardKeyPressToListBox("Down") return
PgUp::CPForwardKeyPressToListBox("PgUp") return
PgDn::CPForwardKeyPressToListBox("PgDn") return
^Home::CPForwardKeyPressToListBox("Home") return ; Ctrl+Home to jump to top of list.
^End::CPForwardKeyPressToListBox("End") return ; Ctrl+End to jump to bottom of list.
CPForwardKeyPressToListBox(key = "Down")
{
global _cpWindowName
; If the Command Picker window is active and the Edit box (i.e. search box) has focus.
ControlGetFocus, control, %_cpWindowName%
if (%control% = Edit1)
{
; Move the selected command to the previous/next command in the list.
ControlSend, ListBox1, {%key%}, %_cpWindowName%
}
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Return hotkeys back to being processed in all windows.
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#IfWinActive
;==========================================================
; Create the Command Picker window if necessary and put it in focus.
;==========================================================
CPPutCommandPickerWindowInFocus()
{
; Let this function know that all variables except the passed in parameters are global variables.
global _cpWindowName, _cpWindowGroup, _cpSearchedString
; If the window is already open.
windowID := WinExist(_cpWindowName)
if (windowID > 0)
{
; Put the window in focus, and give focus to the text box.
WinActivate, %_cpWindowName%
ControlFocus, Edit1, %_cpWindowName%
}
; Else the window is not already open.
else
{
; Create the window
CPCreateCommandPickerWindow()
; Make sure this window is in focus before sending commands.
WinWaitActive, %_cpWindowName%,, 5
; If the window wasn't opened for some reason (or it opened but was closed very quickly).
windowID := WinExist(_cpWindowName)
if (windowID = 0)
{
; Exit.
return false
}
}
; Add this window to Command Picker window group.
GroupAdd, _cpWindowGroup, ahk_id %windowID%
}
;==========================================================
; Create and show the Command Picker Window.
;==========================================================
CPCreateCommandPickerWindow()
{
; Let this function know about the necessary global variables.
global _cpWindowName, _cpCommandList, _cpCommandArray, _cpCommandDelimiter, _cpCommandSelected, _cpSearchedString, _cpNumberOfCommandsToShow, _cpWindowWidthInPixels, _cpFontSize, _cpShowAHKScriptInSystemTray, _cpShowSelectedCommandWindow, _cpCommandParameterSeparator, _cpParameterNameValueSeparator, _cpCommandMatchMethod, _cpCommandParameterListSeparator, _cpParameterDelimiter, _cpCommandDescriptionSeparator
; Define any static variables needed for the GUI.
static commandListBoxContents := "" ; Will hold the commands currently being shown in the command list.
static lastKeyPressWasSearchingParameters := false ; Tells if the last search performed was on the command's preset parameters or not.
; Create the GUI.
Gui 1:Default
Gui, +AlwaysOnTop +Owner +OwnDialogs ToolWindow ; +Owner avoids a taskbar button ; +OwnDialogs makes any windows launched by this one modal ; ToolWindow makes border smaller and hides the min/maximize buttons.
Gui, font, S%_cpFontSize% ; S=Size
; Calculate how to size and position the controls to look nice.
editBoxWidth := _cpWindowWidthInPixels - (11.5 * _cpFontSize) ; Try and size the Edit box according to the font size so that it leaves enough room for the "Run Command" button.
buttonHeightOffset := 0.25 * _cpFontSize ; The Button is taller than the Edit box, so calculate how much to move it up according to the font size to try and vertically center it with the Edit box.
buttonLeftMargin := _cpFontSize ; Calculate how much to space the Button from the Edit box based on the font size.
; Add the controls to the GUI.
Gui Add, Edit, w%editBoxWidth% v_cpSearchedString gSearchedStringChanged
Gui Add, Button, gCommandSubmittedByButton Default x+%buttonLeftMargin% yp-%buttonHeightOffset%, Run Command ; default makes this the default action when Enter is pressed.
Gui Add, ListBox, Sort v_cpCommandSelected gCommandSubmittedByListBoxClick w%_cpWindowWidthInPixels% r%_cpNumberOfCommandsToShow% hscroll vscroll xm
; Fill the ListBox with the commands.
gosub, FillListBoxWithAllCommands
; Create and attach the Menu Bar
Menu, FileMenu, Add, &Close Window, MenuHandler
Menu, FileMane, Add ; Separator
Menu, FileMenu, Add, &Exit (stop script from running), MenuHandler
Menu, SettingsMenu, Add, Show &Settings, MenuHandler
Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Settings, :SettingsMenu
Gui, Menu, MyMenuBar
; Show the GUI, set focus to the input box, and wait for input.
Gui, Show, AutoSize Center, %_cpWindowName% - Choose a command to run
GuiControl, Focus, _cpSearchedString
; Display a tooltip that we are waiting for a command to be entered.
CPShowTooltip("Enter a command")
SetTimer, SleepScript, Off ; Restart the Sleep timer.
SetTimer, SleepScript, 100 ; Sleep the AHK Command Picker several times a second so we can process hotkeys sent while commands are running.
return ; End of auto-execute section. The script is idle until the user does something.
SleepScript:
; Just sleep the script for one millisecond, so that if we are in a long-running loop in a user's command, the script will stop to
; check if any other hotkeys or hotstrings have been sent.
; This is extremely important as it allows us to kill this script with a hotkey if the user's command is out of control.
Sleep, 1
return
MenuHandler:
; File menu commands.
if (A_ThisMenu = "FileMenu")
{
if (A_ThisMenuItem = "&Close Window")
goto, GuiClose
else if (A_ThisMenuItem = "&Exit (stop script from running)")
ExitApp
}
; Settings menu commands.
else if (A_ThisMenu = "SettingsMenu")
{
; Close this window and show the Settings window. When the Settings window is closed this window will be reloaded to show any changes.
Gui, 1:Destroy ; Close the GUI, but leave the script running.
CPShowSettingsWindow() ; Show the Settings window so the user can change settings if they want.
}
return
SearchedStringChanged:
Gui 1:Submit, NoHide ; Get the values from the GUI controls without closing the GUI.
; A problem seemed to be introduced with Windows 8 where if the user types very fast the "text changed" event on the Edit box
; does not fire after the last key has been pressed, so we end up filtering the listbox on a different SearchedString than is in the Edit box.
; The solution is to re-run the search again if the SearchedString is different than what we just searched with, so we keep looping until we are sure we searched on the proper SearchedString.
haveEnteredLoopOnce := false
while ((haveEnteredLoopOnce = false) || isCurrentlyRunningSearchForCommand = false && textThatWillBeSearchedWith != _cpSearchedString)
{
haveEnteredLoopOnce := true
; Save the text that we are going to search on, so that we know if it has changed by the time the search finishes and if we need to search again or not.
textThatWillBeSearchedWith := _cpSearchedString
; Filter the listbox to show items based on the new SearchedString.
gosub, SearchForCommand
; Sleep for a short period of time to allow the GUI to update, and then do the search again if necessary.
Sleep, 25
Gui 1:Submit, NoHide ; Get the values from the GUI controls without closing the GUI.
}
return
SearchForCommand:
isCurrentlyRunningSearchForCommand := true
searchingWithParameters := false ; Mark that we are searching for the command, ignoring any parameters that may be supplied.
; Get the user's search string, stripping off any parameters that may have been provided.
searchText := _cpSearchedString
StringGetPos, firstCommandParameterSeparatorPosition, _cpSearchedString, %_cpCommandParameterListSeparator%
if (firstCommandParameterSeparatorPosition >= 0)
{
searchText := SubStr(_cpSearchedString, 1, firstCommandParameterSeparatorPosition)
}
; Search for the command to select based on the user's input.
gosub, PerformSearch
; If parameters are being provided, narrow the listbox contents down to just the currently selected command and any preset parameters that it might have before performing the search.
if (firstCommandParameterSeparatorPosition >= 0)
{
gosub, PerformSearchForPresetParameters
; Record that this search was done on the preset parameters.
lastKeyPressWasSearchingParameters := true
}
else
{
; Record that this search was NOT done on the preset parameters.
lastKeyPressWasSearchingParameters := false
}
isCurrentlyRunningSearchForCommand := false
return
PerformSearch:
indexThatShouldBeSelected := 0 ; Assume that there are no matches for the given user string.
currentSelectionsText := "" ; The text of the selected command that will be run.
; Do the search using whatever search method is specified in the settings.
if (_cpCommandMatchMethod = "Incremental")
gosub, IncrementalSearch
else
gosub, CamelCaseSearch
; Select the command in the list, using the index if we have it (faster than using string).
; If currentSelectedText is empty then indexThatShouldBeSelected is likely 0, but we still use the index so that NO item gets selected.
if (indexThatShouldBeSelected > 0 || currentSelectionsText = "")
GuiControl Choose, _cpCommandSelected, %indexThatShouldBeSelected%
else
GuiControl Choose, _cpCommandSelected, %currentSelectionsText%
; Display the currently selected command in the tooltip, and hide it after a bit of time.
CPShowTooltip(_cpSearchedString . " (" . currentSelectionsText . ")")
return
PerformSearchForPresetParameters:
; If the user is trying to enter parameters for a command that doesn't exist, just exit.
if (_cpCommandSelected = "")
return
; Get the name of the currently selected command.
commandName := CPGetCommandName(_cpCommandSelected)
; Create a delimited list of the command's preset parameters.
commandParameters := ""
commandParametersArray := _cpCommandArray[commandName].Parameters
Loop, Parse, commandParametersArray, %_cpParameterDelimiter%
{
parameterNameAndValue := A_LoopField
; If this preset parameter has both a name and a value, strip them out to get the name.
StringGetPos, firstDelimiterPosition, parameterNameAndValue, %_cpParameterNameValueSeparator%
if (firstDelimiterPosition >= 0)
{
parameterName := SubStr(parameterNameAndValue, 1, firstDelimiterPosition)
parameterValue := SubStr(parameterNameAndValue, firstDelimiterPosition + 2) ; +2 because SubStr starts at position 1 (not 0), and we want to start at the character AFTER the delimiter.
}
else
parameterName := parameterNameAndValue
; Append this parameter name to the list of parameters
parameterName := Trim(parameterName)
commandParameters .= _cpCommandDelimiter . commandName . _cpCommandParameterSeparator . " " . parameterName
}
; If we have some parameters, copy them into the ListBox contents (always have the parameterless command as the first item in the listbox).
commandListBoxContents := _cpCommandArray[commandName].ToString()
if (commandParameters != "")
commandListBoxContents .= commandParameters
; Sort the list of commands alphabetically.
Sort, commandListBoxContents, D%_cpCommandDelimiter%
; Refresh the list of words in the ListBox.
GuiControl, -Redraw, _cpCommandSelected ; To improve performance, don't redraw the list box until all items have been added.
GuiControl, , _cpCommandSelected, %_cpCommandDelimiter%%commandListBoxContents% ; Put a delimiter before the contents to clear the current listbox contents.
GuiControl, +Redraw, _cpCommandSelected
; Setup the searchText to use to search for.
; Since the user may provide multiple parameters, we only want to search on the last parameter provided.
StringGetPos, lastCommandParameterSeparatorPosition, _cpSearchedString, %_cpCommandParameterListSeparator%, R ; Search from the Right side of the string.
searchText := SubStr(_cpSearchedString, 1, firstCommandParameterSeparatorPosition) ; Get the command text.
searchText .= SubStr(_cpSearchedString, lastCommandParameterSeparatorPosition + 1) ; Append the last parameter provided.
; Since we want to search through the parameters, but the user may not have provided the full command name, modify the searchText so it looks like they did provide the full command name so the search focuses on the parameters.
searchTextContentsAfterParameterSeparator := SubStr(searchText, firstCommandParameterSeparatorPosition + 2) ; +2 because SubStr first char position is 1 (not 0), and we don't want to include the CommandParameterSeparator.
searchText := commandName . _cpCommandParameterSeparator . searchTextContentsAfterParameterSeparator
; Search for the item to select based on the user's input, now that we have populated the listbox with the preset parameters (if any).
searchingWithParameters := true
gosub, PerformSearch
; If no matches were found, choose the parameterless command (should always be the first item in the listbox).
if (currentSelectionsText = "")
GuiControl Choose, _cpCommandSelected, 1
return
IncrementalSearch: ; The user changed the text in the Edit box.
; If we are not searching through a command's preset parameters.
if (searchingWithParameters = false)
{
; If the last keypress was searching parameters (and now this one isn't), refresh the Listbox contents to show all commands, since they would have been changed to only show the preset parameters.
if (lastKeyPressWasSearchingParameters)
{
gosub, FillListBoxWithAllCommands
}
}
; Incremental search will need to exactly match the listbox contents, and items are never removed in incremental mode so we can always just search the listbox contents.
itemsToSearchThrough := commandListBoxContents
searchedStringLength := StrLen(searchText) ; Get the length of the string the user entered.
; Loop through each item in the ListBox to see if the typed text matches any of the items.
Loop Parse, itemsToSearchThrough, %_cpCommandDelimiter%
{
StringLeft part, A_LoopField, searchedStringLength ; We only want to compare the number of characters that the user has typed so far.
If (part = searchText)
{
indexThatShouldBeSelected := A_Index
currentSelectionsText := A_LoopField
break
}
}
return
CamelCaseSearch:
matchingCommands := "" ; Will hold all of the commands that match the search string, so we know which ones to keep in the ListBox.
lowestWordIndexMatchedAgainst = 9999 ; Used to keep track of which command matched against the string in the least number of words (as we want to select that command by default).
; If we are not searching through a command's preset parameters.
if (searchingWithParameters = false)
{
; Because items are removed from the listbox in TypeAhead mode, we actually need to search the list of commands, so that when the user backspaces, items that were removed come back into the listbox.
itemsToSearchThrough := _cpCommandList
}
; Else we are searching through a command's preset parameters.
else
{
; Because we always repopulate the listbox contents with all preset parameters, we want to search through the listbox contents.
itemsToSearchThrough := commandListBoxContents
StringReplace, searchText, searchText, %_cpCommandParameterListSeparator% ; Strip the command-parameter list separator out so that it doesn't mess up the search.
}
; Loop through each command to see if the typed text matches any of the commands.
Loop Parse, itemsToSearchThrough, %_cpCommandDelimiter%
{
; Skip empty entries (somehow an empty one gets added after backspacing out the entire search string).
if (A_LoopField = "")
continue
; Get the commandLine to process.
commandLine := A_LoopField
; If we are not searching through preset parameters.
if (searchingWithParameters = false)
{
; Let's only search the command name, so that the camel-case search doesn't include the command description when matching.
commandLine := CPGetCommandName(commandLine)
}
; Strip any spaces out of the command name, as they just get in the way of the camel case matching.
StringReplace, commandLine, commandLine, %A_Space%, , All
; Also strip out the command-parameter separator so that it doesn't interfere.
StringReplace, commandLine, commandLine, %_cpCommandParameterSeparator%
; Break each camel-case word out of the Command Line by separating them with a space.
; Regex Breakdown: This will match against each word in Camel and Pascal case strings, while properly handling acrynoms.
; (^[a-z]+) Match against any lower-case letters at the start of the command.
; ([0-9]+) Match against one or more consecutive numbers (anywhere in the string, including at the start).
; ([A-Z]{1}[a-z]+) Match against Title case words (one upper case followed by lower case letters).
; ([A-Z]+(?=([A-Z][a-z])|($)|([0-9]))) Match against multiple consecutive upper-case letters, leaving the last upper case letter out the match if it is followed by lower case letters, and including it if it's followed by the end of the string or a number.
words := RegExReplace(commandLine, "((^[a-z]+)|([0-9]+)|([A-Z]{1}[a-z]+)|([A-Z]+(?=([A-Z][a-z])|($)|([0-9]))))", "$1 ")
words := Trim(words)
; Split the string into an array at each space.
StringSplit, wordArray, words, %A_Space%
; Throw the array of words into an object so that we can pass it into the function below (array can't be passed directly by itself).
camelCaseWordsInCommandLine := {} ; Create a new object to hold the array of words.
camelCaseWordsInCommandLine.Length := wordArray0 ; Record how many words are in the array.
camelCaseWordsInCommandLine.Words := Object() ; Will hold the array of all words in the Command.
Loop, %wordArray0%
{
camelCaseWordsInCommandLine.Words[%A_Index%] := wordArray%A_Index%
}
; Get if this command matches against the searched string, and how good the match is.
lastWordIndexMatchedAgainst := CPCommandIsPossibleCamelCaseMatch(searchText, camelCaseWordsInCommandLine)
; If we are searching through parameters, make sure that the parameterless command is always added to the listbox, but make sure it is given a high value so that it is not chosen over another potential match.
if (searchingWithParameters && InStr(commandLine, _cpCommandDescriptionSeparator))
lastWordIndexMatchedAgainst := 9999
; If this Command matches the search string, add it to our list of Commands to be displayed.
if (lastWordIndexMatchedAgainst > 0)
{
; Add this command to the list of matching commands.
matchingCommands .= _cpCommandDelimiter . A_LoopField
; We want to select the command whose match is closest to the start of the string.
if (lastWordIndexMatchedAgainst < lowestWordIndexMatchedAgainst)
{
; Record the LowestWordIndex to beat and the command that should be selected so far.
lowestWordIndexMatchedAgainst := lastWordIndexMatchedAgainst
currentSelectionsText := A_LoopField
}
; If these two commands match against the same word index, pick the one that is lowest alphabetically.
else if(lastWordIndexMatchedAgainst = lowestWordIndexMatchedAgainst)
{
if (A_LoopField < currentSelectionsText)
{
currentSelectionsText := A_LoopField
}
}
}
}
; If we have some matches, copy the matches into the ListBox contents (leaving the leading delimiter as a signal to overwrite the existing contents), otherwise leave a delimiter character to clear the list.
if (matchingCommands != "")
commandListBoxContents := matchingCommands
else
commandListBoxContents := _cpCommandDelimiter
; Refresh the list of words in the ListBox.
GuiControl, -Redraw, _cpCommandSelected ; To improve performance, don't redraw the list box until all items have been added.
GuiControl, , _cpCommandSelected, %commandListBoxContents%
GuiControl, +Redraw, _cpCommandSelected
return
GuiSize: ; The user resized the window.
return
CommandSubmittedByButton: ; The user submitted a selection using the Enter key or the Run Command button.
gosub, CommandSubmitted
return
CommandSubmittedByListBoxClick: ; The user submitted a selection by clicking in the ListBox.
; Only allow double clicks to run a command.
if (A_GuiEvent != "DoubleClick")
return
gosub, CommandSubmitted
return
CommandSubmitted:
Gui 1:Submit, NoHide ; Get the values from the GUI controls without closing the GUI.
commandWasSubmitted := true ; Record that the user actually wants to run the selected command (e.g. not just exit).
; If the user did not specify a valid command, don't process anything.
if (_cpCommandSelected = "")
{
commandWasSubmitted := false
return
}
GuiClose: ; The window was closed (by clicking X or through task manager).
GuiEscape: ; The Escape key was pressed.
Gui 1:Show, Hide ; Hide the GUI.
CPHideTooltip() ; Hide the tooltip that we were showing.
; If the user just wants to close the window (i.e. they didn't submit a command), destroy it and exit.
if (commandWasSubmitted != true)
{
Gui, 1:Destroy ; Close the GUI, but leave the script running.
return
}
; Else the user submitted a command.
; Strip the Description off the command to get just the Command Name.
commandName := CPGetCommandName(_cpCommandSelected)
; Get each provided parameter and store it in an array.
StringSplit, parametersArray, _cpSearchedString, %_cpCommandParameterListSeparator%
; If parameters were provided, get their proper values (since some may be preset parameters).
parameters := ""
if (parametersArray0 > 1)
{
; Loop over each parameter that was typed by the user.
Loop, %parametersArray0%
{
; Skip the first loop since it just contains the command name that the user typed.
if (A_Index = 1)
continue
; If more than one parameter was provided (command name + 1 parameter = 2), select the value in the ListBox for this parameter.
if (parametersArray0 > 2)
{
; Form a new string to search the listbox with, which is just the Command Name and this one parameter.
_cpSearchedString := commandName . _cpCommandParameterListSeparator . parametersArray%A_Index%
; Select the proper parameter value in the ListBox
gosub, PerformSearchForPresetParameters
Gui 1:Submit, NoHide ; Get the GUI's selected ListBox value.
}
; If a preset parameter was chosen (i.e. the command-parameter separator is found in the ListBox's selected command, and the command-description separator is not).
StringGetPos, positionOfCommandParameterSeparator, _cpCommandSelected, %_cpCommandParameterSeparator%
StringGetPos, positionOfCommandDescriptionSeparator, _cpCommandSelected, %_cpCommandDescriptionSeparator%
if (positionOfCommandParameterSeparator >= 0 && positionOfCommandDescriptionSeparator < 0)
{
; Get the preset parameter value
parameterValue := CPGetPresetParameterValues(commandName, SubStr(_cpCommandSelected, positionOfCommandParameterSeparator + 2)) ; +2 becaues SubStr starts at 1 (not 0), and we want to start at the character AFTER the delimiter.
}
; Else get the custom parameter if one was specified.
else
{
parameterValue := parametersArray%A_Index%
}
parameterValue := Trim(parameterValue)
; If a parameter was provided, add it to the list of parameters.
if (parameterValue != "")
{
; If this is not the first parameter, prepend it with the separator character.
if (parameters = "")
parameters := parameterValue
else
parameters .= _cpCommandParameterListSeparator . parameterValue
}
}
}
; Destroy the GUI before running the selected command.
Gui, 1:Destroy ; Close the GUI, but leave the script running.
; Run the command with the given parameters.
CPRunCommand(commandName, parameters)
return
FillListBoxWithAllCommands:
; Copy the _cpCommandList into commandListBoxContents.
commandListBoxContents := _cpCommandList
; Sort the list of commands alphabetically.
Sort, commandListBoxContents, D%_cpCommandDelimiter%
; Refresh the list of words in the ListBox.
GuiControl, -Redraw, _cpCommandSelected ; To improve performance, don't redraw the list box until all items have been added.
GuiControl, , _cpCommandSelected, %_cpCommandDelimiter%%commandListBoxContents% ; Insert a delimiter onto the start of the list to clear the current listbox contents.
GuiControl, +Redraw, _cpCommandSelected
return
}
; Shows the given Tooltip for the specified amount of time.
CPShowTooltip(tooltipText = "", durationInMilliseconds = 3000)
{
ToolTip, %tooltipText%
SetTimer, HideToolTip, Off ; Restart the tooltip timer.
SetTimer, HideTooltip, %durationInMilliseconds%
return
HideTooltip:
CPHideTooltip()
return
}
; Clears out and hides the Tooltip.
CPHideTooltip()
{
SetTimer HideTooltip, Off
Tooltip
}
; Returns whether the given searchText matches against the words in the Array or not.
CPCommandIsPossibleCamelCaseMatch(searchText, camelCaseWordsInCommandLine)
{
; Strip any spaces out of the user's string, as they just get in the way of the camel case matching.
StringReplace, searchText, searchText, %A_Space%, , All
; Get the number of characters that will need to be checked.
lengthOfUsersString := StrLen(searchText)
; Call recursive function to roll through each letter the user typed, checking to see if it's part of one of the command's words.
return CPLetterMatchesPartOfCurrentWordOrBeginningOfNextWord(searchText, lengthOfUsersString, 1, camelCaseWordsInCommandLine.Words, camelCaseWordsInCommandLine.Length, 1, 1)
}
; Recursive function to see if the searchString characters sequentially match characters in the word array, where as long as the first character in the word
; was matched again, the searchString could then match against the next sequential characters in that word, or match against the start of the next word in the array.
; searchString = the user string that was entered.
; searchStringLength = the number of characters in the searchString.
; searchCharacterIndex = the current character of the searchString that we are trying to find a match for.
; wordArray = the camel case words in the Command Name to match the searchString against.
; numberOfWordsInArray = the number of words in the wordArray.
; wordIndex = the current word in the wordArray that we are looking to match against.
; wordCharacterIndex = the current character of the wordIndex word that we are looking for a match against.
CPLetterMatchesPartOfCurrentWordOrBeginningOfNextWord(searchString, searchStringLength, searchCharacterIndex, wordArray, numberOfWordsInArray, wordIndex, wordCharacterIndex)
{
; If all of the characters in the search string were matched, return true that this command is a possible match.
if (searchCharacterIndex > searchStringLength)
{
; Return the index of the word that was last matched against.
return %wordIndex%
}
; If we were asked to look against a word that doesn't exist, or past the last character in the word, just return false since we can't go any further on this path.
if (wordIndex > numberOfWordsInArray || wordCharacterIndex > StrLen(wordArray%wordIndex%))
{
return 0
}
; Get the character at the specified character index
character := SubStr(searchString, searchCharacterIndex, 1)
; If the character matches in this word, then keep going down this path.
if (character = SubStr(wordArray%wordIndex%, wordCharacterIndex, 1))
{
; See if the next character matches the next character in the current word, or the start of the next word.
match1 := CPLetterMatchesPartOfCurrentWordOrBeginningOfNextWord(searchString, searchStringLength, searchCharacterIndex + 1, wordArray, numberOfWordsInArray, wordIndex, wordCharacterIndex + 1)
match2 := CPLetterMatchesPartOfCurrentWordOrBeginningOfNextWord(searchString, searchStringLength, searchCharacterIndex + 1, wordArray, numberOfWordsInArray, wordIndex + 1, 1)
; If one or both of the paths returned a match.
if (match1 > 0 || match2 > 0)
{
; Return the match with the lowest word index above zero (i.e. the one that matched closest to the start of the (array) string).
if (match1 > 0 && match2 > 0)
return match1 < match2 ? match1 : match2 ; Returns the Min out of match1 and match2.
else
return match1 < match2 ? match2 : match1 ; Returns the Max out of match1 and match2, since one of them is zero.
}
; Else neither path found a match, so see if this character matches the start of the next word.
else
return CPLetterMatchesPartOfCurrentWordOrBeginningOfNextWord(searchString, searchStringLength, searchCharacterIndex, wordArray, numberOfWordsInArray, wordIndex + 1, 1)
}
; Otherwise the character doesn't match the current word.
else
{
; See if this character matches the start of the next word.
return CPLetterMatchesPartOfCurrentWordOrBeginningOfNextWord(searchString, searchStringLength, searchCharacterIndex, wordArray, numberOfWordsInArray, wordIndex + 1, 1)
}
}
;==========================================================
; Run the given command.
;==========================================================
CPRunCommand(commandName, parameters)
{
global _cpCommandArray, _cpShowSelectedCommandWindow, _cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand, _cpCommandIsRunning, _cpDisableEscapeKeyScriptReloadUntilAllCommandsComplete
static _cpListOfFunctionsCurrentlyRunning, _cpListOfFunctionsCurrentlyRunningDelimiter := "|"
; If the Command to run doesn't exist, display error and exit.
if (!_cpCommandArray[commandName])
{
MsgBox, Command "%commandName%" does not exist.
return
}
; Get the Command's Function to call.
commandFunction := _cpCommandArray[commandName].FunctionName
; If the Function to call doesn't exist, display an error and exit.
if (!IsFunc(commandFunction))
{
MsgBox, Function "%commandFunction%" does not exist.
return
}
; If we are already running the given function then exit with an error message, as running the same function concurrently may crash the AHK script.
Loop Parse, _cpListOfFunctionsCurrentlyRunning, %_cpListOfFunctionsCurrentlyRunningDelimiter%
{
; Skip empty entries (somehow an empty one gets added after backspacing out the entire search string).
if (A_LoopField = commandFunction)
{
CPDisplayTextOnScreen("COMMAND NOT CALLED!", "'" . commandName . "' is currently running so it will not be called again.")
return
}
}
; Record that we are running this function.
_cpListOfFunctionsCurrentlyRunning .= commandFunction . _cpListOfFunctionsCurrentlyRunningDelimiter
_cpCommandIsRunning := true
; If no parameters were given, but this command provides a default parameter, use the default parameter value.
if (parameters = "" && _cpCommandArray[commandName].DefaultParameterValue != "")
parameters := _cpCommandArray[commandName].DefaultParameterValue
; Call the Command's function, only passing in parameters if they were supplied (so that default parameter values will be used by functions).
if (parameters = "")
textReturnedFromCommand := %commandFunction%()
else
textReturnedFromCommand := %commandFunction%(parameters)
; Now that we are done running the function, remove it from our list of functions currently running.
functionNameAndDelimeter := commandFunction . _cpListOfFunctionsCurrentlyRunningDelimiter
StringReplace, _cpListOfFunctionsCurrentlyRunning, _cpListOfFunctionsCurrentlyRunning, %functionNameAndDelimeter%
; If we are no longer running any Commands at the moment.
if (_cpListOfFunctionsCurrentlyRunning = "")
{
_cpCommandIsRunning := false ; Record that all functions have finished running.
_cpDisableEscapeKeyScriptReloadUntilAllCommandsComplete := false ; Reset the Disable Escape Key user variable (if it was enabled) now that all commands have finished running.
}
;~ ; Example of how to loop through the parameters
;~ For index, value in parameters
;~ MsgBox % "Item " index " is '" value "'"
; If the setting to show which command was ran is enabled, and the command did not explicitly return telling us to not show the text, display the command text.
if ((_cpShowSelectedCommandWindow || (_cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand && parameters != "")) && textReturnedFromCommand != false)
{
; Get the command's text to show.
command := _cpCommandArray[commandName].ToString()
; Display the Command's text on the screen, as well as any text returned from the command (i.e. the textReturnedFromCommand).
CPDisplayTextOnScreen(command, textReturnedFromCommand)
}
}
;==========================================================
; Parse the given command to pull the Command Name from it.
;==========================================================
CPGetCommandName(command)
{
; Let this function know about the necessary global variables.
global _cpCommandDescriptionSeparator, _cpCommandParameterSeparator
; We're not sure if we are being given the Command+Description or Command+Parameter, so try and split against both.
; Replace each Command-Description separator string with an accent symbol so that it is easy to split against (since we can only split against characters, not strings).
StringReplace, command, command, %_cpCommandDescriptionSeparator%, ``, All
; Replace each Command-Parameter separator string with an accent symbol so that it is easy to split against (since we can only split against characters, not strings).
StringReplace, command, command, %_cpCommandParameterSeparator%, ``, All
; Split the string at the accent symbol, and strip spaces and tabs off each element.
StringSplit, commandArray, command,``, %A_Space%%A_Tab%
; return the first element of the array, as that should be the command name.
return %commandArray1%
}
;==========================================================
; Retrieves a preset parameter's value, given its Name and the command it is on.
;==========================================================
CPGetPresetParameterValues(commandName, presetParameterNames)
{
; Let this function know about the necessary global variables.
global _cpCommandArray, _cpParameterDelimiter, _cpParameterNameValueSeparator
; String to hold the parameter values to be returned.
parameterValues := ""
; Loop through each of the given parameter Names.
Loop, Parse, presetParameterNames, %_cpParameterDelimiter%
{
; Trim any whitespace off the preset parameter name so that we can match against it properly.
presetParameterName := Trim(A_LoopField)
; Variable to tell if we found a value for this presetParameterName or not.
matchFound := false
; Get the command's preset parameters and loop through each of them.
presetParameters := _cpCommandArray[commandName].Parameters
Loop, Parse, presetParameters, %_cpParameterDelimiter%
{
parameterNameAndValue := A_LoopField
; If this preset parameter has both a name and a value, strip them out to get the value.
StringGetPos, firstDelimiterPosition, parameterNameAndValue, %_cpParameterNameValueSeparator%
if (firstDelimiterPosition >= 0)
{
parameterName := Trim(SubStr(parameterNameAndValue, 1, firstDelimiterPosition))
parameterValue := SubStr(parameterNameAndValue, firstDelimiterPosition + 2) ; +2 because SubStr starts at position 1 (not 0), and we want to start at the character AFTER the delimiter.
}
else
{
parameterName := Trim(parameterNameAndValue)
parameterValue := parameterNameAndValue
}
; If this is the parameter that we are looking for, append it to the parameter list to be returned and move on to the next parameter to process.
if (presetParameterName = parameterName)
{
parameterValues := CPAppendParameterValueToEndOfList(parameterValues, parameterValue)
matchFound := true
break
}
}
; If we couldn't find the parameter name in the list of preset parameters, assume this is a custom parameter and append it to the end of the list.
if (matchFound = false)
parameterValues := CPAppendParameterValueToEndOfList(parameterValues, presetParameterName)
}
; Return the list of parameter values that corresond to the list of parameter names we were given.
return parameterValues
}
; Returns the given parameterList with the given parameterValue appended to the end of it, separated by the parameter delimiter if necessary.
CPAppendParameterValueToEndOfList(parameterList, parameterValue)
{
global _cpParameterDelimiter
; If the list is empty right now, just set it to this value, otherwise append this value to the end of the list, separating it from the previous paramter value with the delimiter.
if (parameterList = "")
parameterList := parameterValue
else
parameterList .= _cpParameterDelimiter . parameterValue
return parameterList
}
;==========================================================
; Displays the Settings window to allow user to change settings.
;==========================================================
CPShowSettingsWindow()
{
; Let this function know about the necessary global variables.
global _cpWindowName, _cpNumberOfCommandsToShow, _cpWindowWidthInPixels, _cpFontSize, _cpShowAHKScriptInSystemTray, _cpCommandMatchMethod, _cpShowSelectedCommandWindow, _cpNumberOfSecondsToShowSelectedCommandWindowFor, _cpShowSelectedCommandWindowWhenInfoIsReturnedFromCommand, _cpNumberOfSecondsToShowSelectedCommandWindowForWhenInfoIsReturnedFromCommand, _cpEscapeKeyShouldReloadScriptWhenACommandIsRunning
; Define any static variables needed for the GUI.
static CommandMatchMethodDescription
Gui 2:Default ; Specify that these controls are for window #2.
; Create the GUI.
Gui, +AlwaysOnTop +Owner ToolWindow ; +Owner avoids a taskbar button ; +OwnDialogs makes any windows launched by this one modal ; ToolWindow makes border smaller and hides the min/maximize buttons.