-
Notifications
You must be signed in to change notification settings - Fork 12
/
Console.au3
4348 lines (3986 loc) · 282 KB
/
Console.au3
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
;~ This line below is commented out because not everyone in their projects has customized code
;~ #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#Tidy_Parameters=/sf
#include-once
#include <WinAPI.au3>
; #INDEX# =======================================================================================================================
; Title .........: Console.au3
; Version .......: 0.0.0.28
; AutoIt Version : 3.3.9.5a1+
; Minimum OS ....: Windows 2000
; Language ......: English
; Description ...: The following functions are used to access a console.
; Author(s) .....: Matt Diesel (Mat), Erik Pilsits (wraithdu)
; Modified ......: Michał Lipok (mLipok)
; Forum link ....: http://www.autoitscript.com/forum/index.php?showtopic=?????? (tba)
; MSDN link .....: http://msdn.microsoft.com/en-us/library/ms682073.aspx
; DLL(s) ........: Kernel32.dll
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _Console_AddAlias
; _Console_Alloc
; _Console_Attach
; _Console_CreateScreenBuffer
; _Console_FillOutputAttribute
; _Console_FillOutputCharacter
; _Console_FlushInputBuffer
; _Console_Free
; _Console_GenerateCtrlEvent
; _Console_GetAlias
; _Console_GetAliases
; _Console_GetAliasesLength
; _Console_GetAliasExes
; _Console_GetAliasExesLength
; _Console_GetCP
; _Console_GetCurrentFont
; _Console_GetCurrentFontEx
; _Console_GetCurrentFontFace
; _Console_GetCurrentFontFamily
; _Console_GetCurrentFontIndex
; _Console_GetCurrentFontSize
; _Console_GetCurrentFontWeight
; _Console_GetCursorInfo
; _Console_GetCursorPosition
; _Console_GetCursorSize
; _Console_GetCursorVisible
; _Console_GetDisplayMode
; _Console_GetFontSize
; _Console_GetHistoryBufferSize
; _Console_GetHistoryDuplicates
; _Console_GetHistoryInfo
; _Console_GetHistoryNumberOfBuffers
; _Console_GetInput
; _Console_GetLargestWindowSize
; _Console_GetMode
; _Console_GetNumberOfInputEvents
; _Console_GetNumberOfMouseButtons
; _Console_GetOriginalTitle
; _Console_GetOutputCP
; _Console_GetProcessList
; _Console_GetScreenBufferAttributes
; _Console_GetScreenBufferColorTable
; _Console_GetScreenBufferFullscreen
; _Console_GetScreenBufferInfo
; _Console_GetScreenBufferInfoEx
; _Console_GetScreenBufferMaxSize
; _Console_GetScreenBufferPopupAttributes
; _Console_GetScreenBufferPos
; _Console_GetScreenBufferSize
; _Console_GetSelectionAnchor
; _Console_GetSelectionFlags
; _Console_GetSelectionInfo
; _Console_GetSelectionRect
; _Console_GetSelectionRectEx
; _Console_GetStdHandle
; _Console_GetTitle
; _Console_GetWindow
; _Console_Pause
; _Console_PauseMessage
; _Console_Read
; _Console_ReadConsole
; _Console_ReadConsoleEx
; _Console_ReadInput
; _Console_ReadInputRecord
; _Console_ReadConsoleInput
; _Console_ReadConsoleInputRecord
; _Console_ReadOutputCharacter
; _Console_Run
; _Console_ScrollScreenBuffer
; _Console_ScrollScreenBufferEx
; _Console_SetActiveScreenBuffer
; _Console_SetCP
; _Console_SetCtrlHandler
; _Console_SetCurrentFontEx
; _Console_SetCursorInfo
; _Console_SetCursorPosition
; _Console_SetCursorSize
; _Console_SetCursorVisible
; _Console_SetDisplayMode
; _Console_SetHistoryInfo
; _Console_SetIcon
; _Console_SetIconEx
; _Console_SetMode
; _Console_SetOutputCP
; _Console_SetScreenBufferInfoEx
; _Console_SetScreenBufferInfoExEx
; _Console_SetScreenBufferSize
; _Console_SetStdHandle
; _Console_SetTextAttribute
; _Console_SetTitle
; _Console_SetWindowInfo
; _Console_SetWindowPos
; _Console_Write
; _Console_WriteConsole
; _Console_WriteLine
; _Console_WriteOutputAttribute
; _Console_WriteOutputCharacter
; ===============================================================================================================================
; #STRUCTURES# ==================================================================================================================
; $tagCHAR_INFO
; $tagCHAR_INFO_A
; $tagCHAR_INFO_W
; $tagCONSOLE_CURSOR_INFO
; $tagCONSOLE_FONT_INFO
; $tagCONSOLE_FONT_INFOEX
; $tagCONSOLE_HISTORY_INFO
; $tagCONSOLE_READCONSOLE_CONTROL
; $tagCONSOLE_SCREEN_BUFFER_INFO
; $tagCONSOLE_SCREEN_BUFFER_INFOEX
; $tagCONSOLE_SELECTION_INFO
; $tagSMALL_RECT
; ===============================================================================================================================
; #CONSTANTS# ===================================================================================================================
; Standard device flags
; WinBase.h (1048 - 1050)
Global Const $STD_INPUT_HANDLE = -10
Global Const $STD_OUTPUT_HANDLE = -11
Global Const $STD_ERROR_HANDLE = -12
; ControlKeyState flags
; WinCon.h (63 - 71)
Global Const $RIGHT_ALT_PRESSED = 0x0001 ; the right alt key is pressed.
Global Const $LEFT_ALT_PRESSED = 0x0002 ; the left alt key is pressed.
Global Const $RIGHT_CTRL_PRESSED = 0x0004 ; the right ctrl key is pressed.
Global Const $LEFT_CTRL_PRESSED = 0x0008 ; the left ctrl key is pressed.
Global Const $SHIFT_PRESSED = 0x0010 ; the shift key is pressed.
Global Const $NUMLOCK_ON = 0x0020 ; the numlock light is on.
Global Const $SCROLLLOCK_ON = 0x0040 ; the scrolllock light is on.
Global Const $CAPSLOCK_ON = 0x0080 ; the capslock light is on.
Global Const $ENHANCED_KEY = 0x0100 ; the key is enhanced.
; ControlKeyState flags (Other)
; WinCon.h (72 - 78)
Global Const $NLS_DBCSCHAR = 0x00010000 ; DBCS for JPN: SBCS/DBCS mode.
Global Const $NLS_ALPHANUMERIC = 0x00000000 ; DBCS for JPN: Alphanumeric mode.
Global Const $NLS_KATAKANA = 0x00020000 ; DBCS for JPN: Katakana mode.
Global Const $NLS_HIRAGANA = 0x00040000 ; DBCS for JPN: Hiragana mode.
Global Const $NLS_ROMAN = 0x00400000 ; DBCS for JPN: Roman/Noroman mode.
Global Const $NLS_IME_CONVERSION = 0x00800000 ; DBCS for JPN: IME conversion.
Global Const $NLS_IME_DISABLE = 0x20000000 ; DBCS for JPN: IME enable/disable.
; ButtonState flags
; WinCon.h (91 - 95)
Global Const $FROM_LEFT_1ST_BUTTON_PRESSED = 0x0001
Global Const $RIGHTMOST_BUTTON_PRESSED = 0x0002
Global Const $FROM_LEFT_2ND_BUTTON_PRESSED = 0x0004
Global Const $FROM_LEFT_3RD_BUTTON_PRESSED = 0x0008
Global Const $FROM_LEFT_4TH_BUTTON_PRESSED = 0x0010
; EventFlags
; WinCon.h (101 - 106)
Global Const $MOUSE_MOVED = 0x0001
Global Const $DOUBLE_CLICK = 0x0002
Global Const $MOUSE_WHEELED = 0x0004
Global Const $MOUSE_HWHEELED = 0x0008
; EventType flags
; WinCon.h (135 - 139)
Global Const $KEY_EVENT = 0x0001 ; Event contains key event record
Global Const $MOUSE_EVENT = 0x0002 ; Event contains mouse event record
Global Const $WINDOW_BUFFER_SIZE_EVENT = 0x0004 ; Event contains window change event record
Global Const $MENU_EVENT = 0x0008 ; Event contains menu event record
Global Const $FOCUS_EVENT = 0x0010 ; event contains focus change
; Attributes flags (colors)
; WinCon.h (153 - 160)
Global Const $FOREGROUND_BLUE = 0x0001 ; text color contains blue.
Global Const $FOREGROUND_GREEN = 0x0002 ; text color contains green.
Global Const $FOREGROUND_RED = 0x0004 ; text color contains red.
Global Const $FOREGROUND_INTENSITY = 0x0008 ; text color is intensified.
Global Const $BACKGROUND_BLUE = 0x0010 ; background color contains blue.
Global Const $BACKGROUND_GREEN = 0x0020 ; background color contains green.
Global Const $BACKGROUND_RED = 0x0040 ; background color contains red.
Global Const $BACKGROUND_INTENSITY = 0x0080 ; background color is intensified.
; Attributes flags
; WinCon.h (161 - 169)
Global Const $COMMON_LVB_LEADING_BYTE = 0x0100 ; Leading Byte of DBCS
Global Const $COMMON_LVB_TRAILING_BYTE = 0x0200 ; Trailing Byte of DBCS
Global Const $COMMON_LVB_GRID_HORIZONTAL = 0x0400 ; DBCS: Grid attribute: top horizontal.
Global Const $COMMON_LVB_GRID_LVERTICAL = 0x0800 ; DBCS: Grid attribute: left vertical.
Global Const $COMMON_LVB_GRID_RVERTICAL = 0x1000 ; DBCS: Grid attribute: right vertical.
Global Const $COMMON_LVB_REVERSE_VIDEO = 0x4000 ; DBCS: Reverse fore/back ground attribute.
Global Const $COMMON_LVB_UNDERSCORE = 0x8000 ; DBCS: Underscore.
Global Const $COMMON_LVB_SBCSDBCS = 0x0300 ; SBCS or DBCS flag.
; For tagCONSOLE_HISTORY_INFO
; WinCon.h (213)
Global Const $HISTORY_NO_DUP_FLAG = 0x1
; Selection flags
; WinCon.h (232 - 236)
Global Const $CONSOLE_NO_SELECTION = 0x0000
Global Const $CONSOLE_SELECTION_IN_PROGRESS = 0x0001 ; selection has begun
Global Const $CONSOLE_SELECTION_NOT_EMPTY = 0x0002 ; non-null select rectangle
Global Const $CONSOLE_MOUSE_SELECTION = 0x0004 ; selecting with mouse
Global Const $CONSOLE_MOUSE_DOWN = 0x0008 ; mouse is down
; Event flags
; WinCon.h (249 - 255)
Global Const $CTRL_C_EVENT = 0
Global Const $CTRL_BREAK_EVENT = 1
Global Const $CTRL_CLOSE_EVENT = 2
Global Const $CTRL_LOGOFF_EVENT = 5
Global Const $CTRL_SHUTDOWN_EVENT = 6
; Input Mode flags
; WinCon.h (261 - 269)
Global Const $ENABLE_PROCESSED_INPUT = 0x0001
Global Const $ENABLE_LINE_INPUT = 0x0002
Global Const $ENABLE_ECHO_INPUT = 0x0004
Global Const $ENABLE_WINDOW_INPUT = 0x0008
Global Const $ENABLE_MOUSE_INPUT = 0x0010
Global Const $ENABLE_INSERT_MODE = 0x0020
Global Const $ENABLE_QUICK_EDIT_MODE = 0x0040
Global Const $ENABLE_EXTENDED_FLAGS = 0x0080
Global Const $ENABLE_AUTO_POSITION = 0x0100
; Output Mode flags
; WinCon.h (275 - 276)
Global Const $ENABLE_PROCESSED_OUTPUT = 0x0001
Global Const $ENABLE_WRAP_AT_EOL_OUTPUT = 0x0002
; For _Console_CreateScreenBuffer
; WinCon.h (882)
Global Const $CONSOLE_TEXTMODE_BUFFER = 1
; Display Mode flags (GetConsoleDisplayMode)
; WinCon.h (922 - 923)
Global Const $CONSOLE_FULLSCREEN = 1 ; fullscreen console
Global Const $CONSOLE_FULLSCREEN_HARDWARE = 2 ; console owns the hardware
; Display Mode flags (SetConsoleDisplayMode)
; WinCon.h (931 - 932)
Global Const $CONSOLE_FULLSCREEN_MODE = 1
Global Const $CONSOLE_WINDOWED_MODE = 2
; ===============================================================================================================================
; #VARIABLES# ===================================================================================================================
; Use this variable to set a global handle to kernel32.dll instead of using parameters
; $__gvKernel32 = DllOpen("kernel32.dll")
Global $__gvKernel32 = "kernel32.dll"
; Use this variable to set a global default for unicode / ANSI (Unicode = true)
Global $__gfUnicode = True
; Determines if running under SciTE or compiled as a CUI app, then uses ConsoleWrite in _Console_WriteConsole function
Global $__gfIsCUI = False ; (_Console_GetStdHandle($STD_OUTPUT_HANDLE) <> 0)
; ===============================================================================================================================
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCHAR_INFO_W
; Description ...: Specifies a Unicode character and its attributes. This structure is used by console functions to read from
; and write to a console screen buffer.
; Fields ........: Char - Unicode character of a screen buffer character cell.
; Attributes - The character attributes. This member can be zero or any combination of the following
; values:
; |FOREGROUND_BLUE - Text color contains blue.
; |FOREGROUND_GREEN - Text color contains green.
; |FOREGROUND_RED - Text color contains red.
; |FOREGROUND_INTENSITY - Text color is intensified.
; |BACKGROUND_BLUE - Background color contains blue.
; |BACKGROUND_GREEN - Background color contains green.
; |BACKGROUND_RED - Background color contains red.
; |BACKGROUND_INTENSITY - Background color is intensified.
; |COMMON_LVB_LEADING_BYTE - Leading byte.
; |COMMON_LVB_TRAILING_BYTE - Trailing byte.
; |COMMON_LVB_GRID_HORIZONTAL - Top horizontal
; |COMMON_LVB_GRID_LVERTICAL - Left vertical.
; |COMMON_LVB_GRID_RVERTICAL - Right vertical.
; |COMMON_LVB_REVERSE_VIDEO - Reverse foreground and background attribute.
; |COMMON_LVB_UNDERSCORE - Underscore.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCHAR_INFO_W = "WCHAR Char; WORD Attributes"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCHAR_INFO_A
; Description ...: Specifies a Ascii character and its attributes. This structure is used by console functions to read from
; and write to a console screen buffer.
; Fields ........: Char - Ascii character of a screen buffer character cell.
; Attributes - The character attributes. This member can be zero or any combination of the following
; values:
; |FOREGROUND_BLUE - Text color contains blue.
; |FOREGROUND_GREEN - Text color contains green.
; |FOREGROUND_RED - Text color contains red.
; |FOREGROUND_INTENSITY - Text color is intensified.
; |BACKGROUND_BLUE - Background color contains blue.
; |BACKGROUND_GREEN - Background color contains green.
; |BACKGROUND_RED - Background color contains red.
; |BACKGROUND_INTENSITY - Background color is intensified.
; |COMMON_LVB_LEADING_BYTE - Leading byte.
; |COMMON_LVB_TRAILING_BYTE - Trailing byte.
; |COMMON_LVB_GRID_HORIZONTAL - Top horizontal
; |COMMON_LVB_GRID_LVERTICAL - Left vertical.
; |COMMON_LVB_GRID_RVERTICAL - Right vertical.
; |COMMON_LVB_REVERSE_VIDEO - Reverse foreground and background attribute.
; |COMMON_LVB_UNDERSCORE - Underscore.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCHAR_INFO_A = "CHAR Char; CHAR; WORD Attributes"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCHAR_INFO
; Description ...: Specifies a character and its attributes. This structure is used by console functions to read from and write
; to a console screen buffer.
; Fields ........: UnicodeChar - Unicode character of a screen buffer character cell.
; Attributes - The character attributes. This member can be zero or any combination of the following
; values.
; |FOREGROUND_BLUE - Text color contains blue.
; |FOREGROUND_GREEN - Text color contains green.
; |FOREGROUND_RED - Text color contains red.
; |FOREGROUND_INTENSITY - Text color is intensified.
; |BACKGROUND_BLUE - Background color contains blue.
; |BACKGROUND_GREEN - Background color contains green.
; |BACKGROUND_RED - Background color contains red.
; |BACKGROUND_INTENSITY - Background color is intensified.
; |COMMON_LVB_LEADING_BYTE - Leading byte.
; |COMMON_LVB_TRAILING_BYTE - Trailing byte.
; |COMMON_LVB_GRID_HORIZONTAL - Top horizontal
; |COMMON_LVB_GRID_LVERTICAL - Left vertical.
; |COMMON_LVB_GRID_RVERTICAL - Right vertical.
; |COMMON_LVB_REVERSE_VIDEO - Reverse foreground and background attribute.
; |COMMON_LVB_UNDERSCORE - Underscore.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCHAR_INFO = $tagCHAR_INFO_W
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_CURSOR_INFO
; Description ...: Contains information about the console cursor.
; Fields ........: Size - The percentage of the character cell that is filled by the cursor. This value is
; between 1 and 100. The cursor appearance varies, ranging from completely filling the
; cell to showing up as a horizontal line at the bottom of the cell.
; Visible - The visibility of the cursor. If the cursor is visible, this member is TRUE.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_CURSOR_INFO = "DWORD Size; BOOL Visible;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_FONT_INFO
; Description ...: Contains information for a console font.
; Fields ........: Font - The index of the font in the system's console font table.
; X - Contains the width of each character in the font, in logical units.
; Y - Contains the height of each character in the font, in logical units.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_FONT_INFO = "DWORD Font; SHORT X; SHORT Y;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_FONT_INFO_EX
; Description ...: Contains extended information for a console font.
; Fields ........: Size - The size of this structure, in bytes.
; Font - The index of the font in the system's console font table.
; X - Contains the width of each character in the font, in logical units.
; Y - Contains the height of each character in the font, in logical units.
; FontFamily - The font family. This parameter can be one of the following values:
; |FF_DECORATIVE
; |FF_DONTCARE
; |FF_MODERN
; |FF_ROMAN
; |FF_SCRIPT
; |FF_SWISS
; FontWeight - The font weight. The weight can range from 100 to 1000, in multiples of 100. For
; example, the normal weight is 400, while 700 is bold.
; FaceName - The name of the typeface (such as Courier or Arial).
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_FONT_INFOEX = "ULONG Size; DWORD Font; SHORT X; SHORT Y; UINT FontFamily; UINT FontWeight; " & _
"wchar[32] FaceName;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_HISTORY_INFO
; Description ...: Contains information about the console history.
; Fields ........: Size - The size of the structure, in bytes. Set this member to
; DllStructGetSize($tCONSOLE_HISTORY_INFO).
; HistoryBufferSize - The number of commands kept in each history buffer.
; NumberOfHistoryBuffers - The number of history buffers kept for this console process.
; Flags - This parameter can be zero or 1. If 1, duplicate entries will not be stored in the
; history buffer.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_HISTORY_INFO = "UINT Size; UINT HistoryBufferSize; UINT NumberOfHistoryBuffers; DWORD Flags;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_READCONSOLE_CONTROL
; Description ...: Contains information for a console read operation.
; Fields ........: Length - The size of the structure. Set this member to
; DllStructGetSize($tCONSOLE_READCONSOLE_CONTROL).
; InitialChars - The number of characters to skip (and thus preserve) before writing newly read input
; in the buffer passed to the _Console_Read function. This value must be less than
; the NumberOfCharsToRead parameter of the _Console_Read function.
; CtrlWakeupMask - A user-defined control character used to signal that the read is complete.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values.
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_READCONSOLE_CONTROL = "ULONG Length; ULONG InitialChars; ULONG CtrlWakeupMask; ULONG ControlKeyState;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_SCREEN_BUFFER_INFO
; Description ...: Contains information about a console screen buffer.
; Fields ........: SizeX - The width of the console screen buffer, in character columns and rows.
; SizeY - The height of the console screen buffer, in character columns and rows.
; CursorPositionX - The column coordinates of the cursor in the console screen buffer.
; CursorPositionY - The row coordinates of the cursor in the console screen buffer.
; Attributes - The attributes of the characters written to a screen buffer by the _Console_WriteFile
; and _Console_WriteConsole functions, or echoed to a screen buffer by the
; _WinApi_ReadFile and _Console_Read functions.
; Left - The distance between the left buffer edge and the edge of the screen.
; Top - The distance between the top buffer edge and the edge of the screen.
; Right - The distance between the right buffer edge and the edge of the screen.
; Bottom - The distance between the top buffer edge and the edge of the screen.
; MaximumWindowSizeX - The maximum width of the console window, in character columns and rows, given the
; current screen buffer size and font and the screen size.
; MaximumWindowSizeY - The maximum height of the console window, in character columns and rows, given the
; current screen buffer size and font and the screen size.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_SCREEN_BUFFER_INFO = "SHORT SizeX; SHORT SizeY; SHORT CursorPositionX;" & _
"SHORT CursorPositionY; SHORT Attributes; SHORT Left; SHORT Top; SHORT Right; SHORT Bottom;" & _
"SHORT MaximumWindowSizeX; SHORT MaximumWindowSizeY"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_SCREEN_BUFFER_INFOEX
; Description ...: Contains extended information about a console screen buffer.
; Fields ........: Size - The size of this structure, in bytes. Should be set to
; DllStructGetSize($tCONSOLE_SCREEN_BUFFER_INFO)
; SizeX - The width of the console screen buffer, in character columns and rows.
; SizeY - The height of the console screen buffer, in character columns and rows.
; CursorPositionX - The column coordinates of the cursor in the console screen buffer.
; CursorPositionY - The row coordinates of the cursor in the console screen buffer.
; Attributes - The attributes of the characters written to a screen buffer by the _Console_WriteFile
; and _Console_WriteConsole functions, or echoed to a screen buffer by the
; _WinApi_ReadFile and _Console_Read functions.
; Left - The distance between the left buffer edge and the edge of the screen.
; Top - The distance between the top buffer edge and the edge of the screen.
; Right - The right edge of the buffer.
; Bottom - The top edge of the buffer.
; MaximumWindowSizeX - The maximum width of the console window, in character columns and rows, given the
; current screen buffer size and font and the screen size.
; MaximumWindowSizeY - The maximum height of the console window, in character columns and rows, given the
; current screen buffer size and font and the screen size.
; PopupAttributes - The fill attribute for console pop-ups.
; FullscreenSupported - If this member is TRUE, full-screen mode is supported; otherwise, it is not.
; ColorTable - An array of COLORREF values that describe the console's color settings.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_SCREEN_BUFFER_INFOEX = "ULONG Size; SHORT SizeX; SHORT SizeY;SHORT CursorPositionX;" & _
"SHORT CursorPositionY; SHORT Attributes; SHORT Left; SHORT Top; SHORT Right; SHORT Bottom;" & _
"SHORT MaximumWindowSizeX; SHORT MaximumWindowSizeY; WORD PopupAttributes; BOOL FullscreenSupported;" & _
"DWORD ColorTable[16];"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagCONSOLE_SELECTION_INFO
; Description ...: Contains information for a console selection.
; Fields ........: Flags - The selection indicator. This member can be one or more of the following values.
; |CONSOLE_MOUSE_DOWN - Mouse is down
; |CONSOLE_MOUSE_SELECTION - Selecting with the mouse
; |CONSOLE_NO_SELECTION - No selection
; |CONSOLE_SELECTION_IN_PROGRESS - Selection has begun
; |CONSOLE_SELECTION_NOT_EMPTY - Selection rectangle is not empty
; X - The X coordinate that specifies the selection anchor, in characters.
; Y - The Y coordinate that specifies the selection anchor, in characters.
; Left - The left edge of the selection rectangle, in characters.
; Top - The top edge of the selection rectangle, in characters.
; Right - The right edge of the selection rectangle, in characters.
; Bottom - The bottom edge of the selection rectangle, in characters.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagCONSOLE_SELECTION_INFO = "DWORD Flags; SHORT X; SHORT Y; SHORT Left; SHORT Top; SHORT Right; SHORT Bottom;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagKEY_EVENT_RECORD_W
; Description ...: Describes a keyboard input event in a console INPUT_RECORD structure (Unicode version)
; Fields ........: KeyDown - If the key is pressed, this member is TRUE. Otherwise, this member is FALSE (the key is
; released).
; RepeatCount - The repeat count, which indicates that a key is being held down. For example, when a
; key is held down, you might get five events with this member equal to 1, one event with
; this member equal to 5, or multiple events with this member greater than or equal to 1.
; VirtualKeyCode - A virtual-key code that identifies the given key in a device-independent manner.
; VirtualScanCode - The virtual scan code of the given key that represents the device-dependent value
; generated by the keyboard hardware.
; Char - Translated Unicode character.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Enhanced keys for the IBM 101- and 102-key keyboards are the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and
; direction keys in the clusters to the left of the keypad; and the divide (/) and ENTER keys in the keypad.
;+
; Keyboard input events are generated when any key, including control keys, is pressed or released. However, the
; ALT key when pressed and released without combining with another character, has special meaning to the system
; and is not passed through to the application. Also, the CTRL+C key combination is not passed through if the
; input handle is in processed mode (ENABLE_PROCESSED_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagKEY_EVENT_RECORD, $tagKEY_EVENT_RECORD_A
; Link ..........: http://msdn.microsoft.com/en-us/library/ms684166
; ===============================================================================================================================
Global Const $tagKEY_EVENT_RECORD_W = "BOOL KeyDown; WORD RepeatCount; WORD VirtualKeyCode; WORD VirtualScanCode;" & _
"WCHAR Char; DWORD ControlKeyState;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagKEY_EVENT_RECORD_A
; Description ...: Describes a keyboard input event in a console INPUT_RECORD structure (ASCII version)
; Fields ........: KeyDown - If the key is pressed, this member is TRUE. Otherwise, this member is FALSE (the key is
; released).
; RepeatCount - The repeat count, which indicates that a key is being held down. For example, when a
; key is held down, you might get five events with this member equal to 1, one event with
; this member equal to 5, or multiple events with this member greater than or equal to 1.
; VirtualKeyCode - A virtual-key code that identifies the given key in a device-independent manner.
; VirtualScanCode - The virtual scan code of the given key that represents the device-dependent value
; generated by the keyboard hardware.
; Char - Translated ASCII character.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Enhanced keys for the IBM 101- and 102-key keyboards are the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and
; direction keys in the clusters to the left of the keypad; and the divide (/) and ENTER keys in the keypad.
;
; Keyboard input events are generated when any key, including control keys, is pressed or released. However, the
; ALT key when pressed and released without combining with another character, has special meaning to the system
; and is not passed through to the application. Also, the CTRL+C key combination is not passed through if the
; input handle is in processed mode (ENABLE_PROCESSED_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagKEY_EVENT_RECORD, $tagKEY_EVENT_RECORD_W
; Link ..........: http://msdn.microsoft.com/en-us/library/ms684166
; ===============================================================================================================================
Global Const $tagKEY_EVENT_RECORD_A = "BOOL KeyDown; WORD RepeatCount; WORD VirtualKeyCode; WORD VirtualScanCode;" & _
"CHAR Char; CHAR; DWORD ControlKeyState;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagKEY_EVENT_RECORD
; Description ...: Describes a keyboard input event in a console INPUT_RECORD structure
; Fields ........: KeyDown - If the key is pressed, this member is TRUE. Otherwise, this member is FALSE (the key is
; released).
; RepeatCount - The repeat count, which indicates that a key is being held down. For example, when a
; key is held down, you might get five events with this member equal to 1, one event with
; this member equal to 5, or multiple events with this member greater than or equal to 1.
; VirtualKeyCode - A virtual-key code that identifies the given key in a device-independent manner.
; VirtualScanCode - The virtual scan code of the given key that represents the device-dependent value
; generated by the keyboard hardware.
; Char - Translated ASCII or Unicode character
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Enhanced keys for the IBM 101- and 102-key keyboards are the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and
; direction keys in the clusters to the left of the keypad; and the divide (/) and ENTER keys in the keypad.
;+
; Keyboard input events are generated when any key, including control keys, is pressed or released. However, the
; ALT key when pressed and released without combining with another character, has special meaning to the system
; and is not passed through to the application. Also, the CTRL+C key combination is not passed through if the
; input handle is in processed mode (ENABLE_PROCESSED_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagKEY_EVENT_RECORD_A, $tagKEY_EVENT_RECORD_W
; Link ..........: http://msdn.microsoft.com/en-us/library/ms684166
; ===============================================================================================================================
Global Const $tagKEY_EVENT_RECORD = $tagKEY_EVENT_RECORD_W
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagMOUSE_EVENT_RECORD
; Description ...: Describes a mouse input event in a console INPUT_RECORD structure.
; Fields ........: MousePositionX - The X coordinate of the location of the cursor, in terms of the console screen buffer's
; character-cell coordinates.
; MousePositionY - The Y coordinate of the location of the cursor, in terms of the console screen buffer's
; character-cell coordinates.
; ButtonState - The status of the mouse buttons. The least significant bit corresponds to the leftmost
; mouse button. The next least significant bit corresponds to the rightmost mouse button.
; The next bit indicates the next-to-leftmost mouse button. The bits then correspond left
; to right to the mouse buttons. A bit is 1 if the button was pressed.
;+
; The following constants are defined for the first five mouse buttons:
; |FROM_LEFT_1ST_BUTTON_PRESSED - The leftmost mouse button.
; |FROM_LEFT_2ND_BUTTON_PRESSED - The second button from the left.
; |FROM_LEFT_3RD_BUTTON_PRESSED - The third button from the left.
; |FROM_LEFT_4TH_BUTTON_PRESSED - The fourth button from the left.
; |RIGHTMOST_BUTTON_PRESSED - The rightmost mouse button.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; EventFlags - The type of mouse event. If this value is zero, it indicates a mouse button being
; pressed or released. Otherwise, this member is one of the following values.
; |DOUBLE_CLICK - The second click (button press) of a double-click occurred. The first
; click is returned as a regular button-press event.
; |MOUSE_HWHEELED - The horizontal mouse wheel was moved. If the high word of the
; ButtonState member contains a positive value, the wheel was rotated
; to the right. Otherwise, the wheel was rotated to the left.
; |MOUSE_MOVED - A change in mouse position occurred.
; |MOUSE_WHEELED - The vertical mouse wheel was moved. If the high word of the
; ButtonState member contains a positive value, the wheel was rotated
; forward, away from the user. Otherwise, the wheel was rotated
; backward, toward the user.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Mouse events are placed in the input buffer when the console is in mouse mode (ENABLE_MOUSE_INPUT).
;+
; Mouse events are generated whenever the user moves the mouse, or presses or releases one of the mouse buttons.
; Mouse events are placed in a console's input buffer only when the console group has the keyboard focus and the
; cursor is within the borders of the console's window.
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagINPUT_RECORD_MOUSE
; Link ..........: http://msdn.microsoft.com/en-us/library/ms684239
; ===============================================================================================================================
Global Const $tagMOUSE_EVENT_RECORD = "SHORT MousePositionX; SHORT MousePositionY; DWORD ButtonState; DWORD ControlKeyState;" & _
"DWORD EventFlags;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagWINDOW_BUFFER_SIZE_RECORD
; Description ...: Describes a change in the size of the console screen buffer.
; Fields ........: SizeX - The width of the console screen buffer, in character cell columns.
; SizeY - The height of the console screen buffer, in character cell rows.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Buffer size events are placed in the input buffer when the console is in window-aware mode
; (ENABLE_WINDOW_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagINPUT_RECORD_SIZE
; Link ..........: http://msdn.microsoft.com/en-us/library/ms687093
; ===============================================================================================================================
Global Const $tagWINDOW_BUFFER_SIZE_RECORD = "SHORT SizeX; SHORT SizeY;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagMENU_EVENT_RECORD
; Description ...: Describes a menu event in a console $tagINPUT_RECORD structure. These events are used internally and should be
; ignored.
; Fields ........: CommandId - Reserved according to MSDN documentation. From testing it seems the only messages sent
; are menu opening (278) and menu closing (287). This is regardless of whether the
; console is window aware or not.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagINPUT_RECORD_MENU
; Link ..........: http://msdn.microsoft.com/en-us/library/ms684213
; ===============================================================================================================================
Global Const $tagMENU_EVENT_RECORD = "UINT CommandId;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagFOCUS_EVENT_RECORD
; Description ...: Describes a focus event in a console tagINPUT_RECORD structure. These events are used internally and should be
; ignored.
; Fields ........: SetFocus - Reserved according to MSDN. True if window is gaining focus, False if it is losing
; focus.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagINPUT_RECORD_FOCUS
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683149
; ===============================================================================================================================
Global Const $tagFOCUS_EVENT_RECORD = "BOOL SetFocus;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD
; Description ...: Describes an input event in the console input buffer. These records can be read from the input buffer by using
; the _Console_ReadInput or _Console_PeekInput function, or written to the input buffer by using the
; _Console_WriteInput function.
; Fields ........: EventType - A handle to the type of input event. This member can be one of the following values:
; |FOCUS_EVENT - This structure is a $tagINPUT_RECORD_FOCUS structure.
; |KEY_EVENT - This structure is a $tagINPUT_RECORD_KEY structure.
; |MENU_EVENT - This structure is a $tagINPUT_RECORD_MENU structure.
; |MOUSE_EVENT - This structure is a $tagINPUT_RECORD_MOUSE structure.
; |WINDOW_BUFFER_SIZE_EVENT - This structure is a $tagINPUT_RECORD_SIZE structure.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; Related .......: $tagINPUT_RECORD_KEY, $tagINPUT_RECORD_MOUSE, $tagINPUT_RECORD_SIZE, $tagINPUT_RECORD_MENU,
; $tagINPUT_RECORD_FOCUS, _Console_ReadInputRecord, _Console_ReadInput
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD = "WORD EventType; BYTE buffer[16];"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_KEY
; Description ...: Describes a keyboard input event in the console INPUT_RECORD structure
; Fields ........: EventType - A handle to the type of input event. This should be set to KEY_EVENT if you are using
; this structure.
; KeyDown - If the key is pressed, this member is TRUE. Otherwise, this member is FALSE (the key is
; released).
; RepeatCount - The repeat count, which indicates that a key is being held down. For example, when a
; key is held down, you might get five events with this member equal to 1, one event with
; this member equal to 5, or multiple events with this member greater than or equal to 1.
; VirtualKeyCode - A virtual-key code that identifies the given key in a device-independent manner.
; VirtualScanCode - The virtual scan code of the given key that represents the device-dependent value
; generated by the keyboard hardware.
; Char - Translated ASCII or Unicode character
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Enhanced keys for the IBM 101- and 102-key keyboards are the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and
; direction keys in the clusters to the left of the keypad; and the divide (/) and ENTER keys in the keypad.
;+
; Keyboard input events are generated when any key, including control keys, is pressed or released. However, the
; ALT key when pressed and released without combining with another character, has special meaning to the system
; and is not passed through to the application. Also, the CTRL+C key combination is not passed through if the
; input handle is in processed mode (ENABLE_PROCESSED_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagKEY_EVENT_RECORD_A, $tagKEY_EVENT_RECORD_W
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_KEY = "WORD EventType; STRUCT; " & $tagKEY_EVENT_RECORD & "ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_KEY_A
; Description ...: Describes a keyboard input event in the console input buffer (ASCII version)
; Fields ........: EventType - A handle to the type of input event. This should be set to KEY_EVENT if you are using
; this structure.
; KeyDown - If the key is pressed, this member is TRUE. Otherwise, this member is FALSE (the key is
; released).
; RepeatCount - The repeat count, which indicates that a key is being held down. For example, when a
; key is held down, you might get five events with this member equal to 1, one event with
; this member equal to 5, or multiple events with this member greater than or equal to 1.
; VirtualKeyCode - A virtual-key code that identifies the given key in a device-independent manner.
; VirtualScanCode - The virtual scan code of the given key that represents the device-dependent value
; generated by the keyboard hardware.
; Char - Translated ASCII character.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Enhanced keys for the IBM 101- and 102-key keyboards are the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and
; direction keys in the clusters to the left of the keypad; and the divide (/) and ENTER keys in the keypad.
;
; Keyboard input events are generated when any key, including control keys, is pressed or released. However, the
; ALT key when pressed and released without combining with another character, has special meaning to the system
; and is not passed through to the application. Also, the CTRL+C key combination is not passed through if the
; input handle is in processed mode (ENABLE_PROCESSED_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD_KEY, $tagINPUT_RECORD_KEY_W
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_KEY_A = "WORD EventType; STRUCT; " & $tagKEY_EVENT_RECORD_A & "ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_KEY_W
; Description ...: Describes a keyboard input event in the console input buffer (Unicode version)
; Fields ........: EventType - A handle to the type of input event. This should be set to KEY_EVENT if you are using
; this structure.
; KeyDown - If the key is pressed, this member is TRUE. Otherwise, this member is FALSE (the key is
; released).
; RepeatCount - The repeat count, which indicates that a key is being held down. For example, when a
; key is held down, you might get five events with this member equal to 1, one event with
; this member equal to 5, or multiple events with this member greater than or equal to 1.
; VirtualKeyCode - A virtual-key code that identifies the given key in a device-independent manner.
; VirtualScanCode - The virtual scan code of the given key that represents the device-dependent value
; generated by the keyboard hardware.
; Char - Translated Unicode character.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Enhanced keys for the IBM 101- and 102-key keyboards are the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and
; direction keys in the clusters to the left of the keypad; and the divide (/) and ENTER keys in the keypad.
;+
; Keyboard input events are generated when any key, including control keys, is pressed or released. However, the
; ALT key when pressed and released without combining with another character, has special meaning to the system
; and is not passed through to the application. Also, the CTRL+C key combination is not passed through if the
; input handle is in processed mode (ENABLE_PROCESSED_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD_KEY, $tagINPUT_RECORD_KEY_A
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_KEY_W = "WORD EventType; STRUCT; " & $tagKEY_EVENT_RECORD_W & "ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_MOUSE
; Description ...: Describes a mouse input event in the console input buffer.
; Fields ........: EventType - A handle to the type of input event. This should be set to MOUSE_EVENT if you are using
; this structure.
; MousePositionX - The X coordinate of the location of the cursor, in terms of the console screen buffer's
; character-cell coordinates.
; MousePositionY - The Y coordinate of the location of the cursor, in terms of the console screen buffer's
; character-cell coordinates.
; ButtonState - The status of the mouse buttons. The least significant bit corresponds to the leftmost
; mouse button. The next least significant bit corresponds to the rightmost mouse button.
; The next bit indicates the next-to-leftmost mouse button. The bits then correspond left
; to right to the mouse buttons. A bit is 1 if the button was pressed.
;+
; The following constants are defined for the first five mouse buttons:
; |FROM_LEFT_1ST_BUTTON_PRESSED - The leftmost mouse button.
; |FROM_LEFT_2ND_BUTTON_PRESSED - The second button from the left.
; |FROM_LEFT_3RD_BUTTON_PRESSED - The third button from the left.
; |FROM_LEFT_4TH_BUTTON_PRESSED - The fourth button from the left.
; |RIGHTMOST_BUTTON_PRESSED - The rightmost mouse button.
; ControlKeyState - The state of the control keys. This member can be one or more of the following values:
; |CAPSLOCK_ON - The CAPS LOCK light is on.
; |ENHANCED_KEY - The key is enhanced.
; |LEFT_ALT_PRESSED - The left ALT key is pressed.
; |LEFT_CTRL_PRESSED - The left CTRL key is pressed.
; |NUMLOCK_ON - The NUM LOCK light is on.
; |RIGHT_ALT_PRESSED - The right ALT key is pressed.
; |RIGHT_CTRL_PRESSED - The right CTRL key is pressed.
; |SCROLLLOCK_ON - The SCROLL LOCK light is on.
; |SHIFT_PRESSED - The SHIFT key is pressed.
; EventFlags - The type of mouse event. If this value is zero, it indicates a mouse button being
; pressed or released. Otherwise, this member is one of the following values.
; |DOUBLE_CLICK - The second click (button press) of a double-click occurred. The first
; click is returned as a regular button-press event.
; |MOUSE_HWHEELED - The horizontal mouse wheel was moved. If the high word of the
; ButtonState member contains a positive value, the wheel was rotated
; to the right. Otherwise, the wheel was rotated to the left.
; |MOUSE_MOVED - A change in mouse position occurred.
; |MOUSE_WHEELED - The vertical mouse wheel was moved. If the high word of the
; ButtonState member contains a positive value, the wheel was rotated
; forward, away from the user. Otherwise, the wheel was rotated
; backward, toward the user.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Mouse events are placed in the input buffer when the console is in mouse mode (ENABLE_MOUSE_INPUT).
;+
; Mouse events are generated whenever the user moves the mouse, or presses or releases one of the mouse buttons.
; Mouse events are placed in a console's input buffer only when the console group has the keyboard focus and the
; cursor is within the borders of the console's window.
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagMOUSE_EVENT_RECORD
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_MOUSE = "WORD EventType; STRUCT; " & $tagMOUSE_EVENT_RECORD & "ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_SIZE
; Description ...: Describes a change in the size of the console screen event in the console input buffer.
; Fields ........: EventType - A handle to the type of input event. This should be set to WINDOW_BUFFER_SIZE_EVENT if
; you are using this structure.
; SizeX - The width of the console screen buffer, in character cell columns.
; SizeY - The height of the console screen buffer, in character cell rows.
; Author ........: Matt Diesel (Mat)
; Remarks .......: Buffer size events are placed in the input buffer when the console is in window-aware mode
; (ENABLE_WINDOW_INPUT).
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagWINDOW_BUFFER_SIZE_RECORD
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_SIZE = "WORD EventType; STRUCT; " & $tagWINDOW_BUFFER_SIZE_RECORD & "BYTE[12]; ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_MENU
; Description ...: Describes a menu event in the console input buffer. These events are used internally and should be ignored.
; Fields ........: EventType - A handle to the type of input event. This should be set to MENU_EVENT if you are using
; this structure.
; CommandId - Reserved according to MSDN documentation. From testing it seems the only messages sent
; are menu opening (278) and menu closing (287). This is regardless of whether the
; console is window aware or not.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagMENU_EVENT_RECORD
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_MENU = "WORD EventType; STRUCT; " & $tagMENU_EVENT_RECORD & "BYTE[12]; ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagINPUT_RECORD_FOCUS
; Description ...: Describes a focus event in the console input buffer. These events are used internally and should be ignored.
; Fields ........: EventType - A handle to the type of input event. This should be set to FOCUS_EVENT if you are using
; this structure.
; SetFocus - Reserved according to MSDN. True if window is gaining focus, False if it is losing
; focus.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; Related .......: _Console_ReadInputRecord, _Console_ReadInput, $tagINPUT_RECORD, $tagFOCUS_EVENT_RECORD
; Link ..........: http://msdn.microsoft.com/en-us/library/ms683499
; ===============================================================================================================================
Global Const $tagINPUT_RECORD_FOCUS = "WORD EventType; STRUCT; " & $tagFOCUS_EVENT_RECORD & "BYTE[12]; ENDSTRUCT;"
; #STRUCTURE# ===================================================================================================================
; Name ..........: $tagSMALL_RECT
; Description ...: Defines the coordinates of the upper left and lower right corners of a rectangle.
; Fields ........: Left - The x-coordinate of the upper left corner of the rectangle.
; Top - The y-coordinate of the upper left corner of the rectangle.
; Right - The x-coordinate of the lower right corner of the rectangle.
; Bottom - The y-coordinate of the lower right corner of the rectangle.
; Author ........: Matt Diesel (Mat)
; Remarks .......: This structure is used by console functions to specify rectangular areas of console screen buffers, where the
; coordinates specify the rows and columns of screen-buffer character cells.
; ===============================================================================================================================
Global Const $tagSMALL_RECT = "SHORT Left; SHORT Top; SHORT Right; SHORT Bottom;"
; #FUNCTION# ====================================================================================================================
; Name ..........: _Console_AddAlias
; Description ...: Defines a console alias for the specified executable.
; Syntax ........: _Console_AddAlias($sSource, $sTarget, $sExeName [, $hDll ] )
; Parameters ....: $sSource - The console alias to be mapped to the text specified by Target.
; $sTarget - The text to be substituted for Source. If this parameter is 0, then the console alias
; is removed.
; $sExeName - The name of the executable file for which the console alias is to be defined. Default
; is the current executable.
; $fUnicode - If 'True' then the unicode version will be used. If 'False' then ANSI is used.
; $hDll - A handle to a dll to use. This prevents constant opening of the dll which could slow it
; down. If you are calling lots of functions from the same dll then this recommended.
; Return values .: Success - True
; Failure - False
; Author ........: Matt Diesel (Mat)
; Modified ......:
; Remarks .......: Console aliases allow programs to define macros for commonly used commands. For example if you frequently need
; to use "cd \a_very_long_path\test" in cmd.exe you can shorten this to just "test" by calling:
; _Console_AddAlias("cd \a_very_long_path\test", "test", "cmd.exe")
; Related .......: _Console_GetAlias, _Console_GetAliases, _Console_GetAliasExes
; Link ..........: http://msdn.microsoft.com/en-us/library/ms681935.aspx
; Example .......: No
; ===============================================================================================================================
Func _Console_AddAlias($sSource, $sTarget, $sExeName = Default, $fUnicode = Default, $hDll = -1)
If $sExeName = Default Then $sExeName = @AutoItExe
If $fUnicode = Default Then $fUnicode = $__gfUnicode
If $hDll = -1 Then $hDll = $__gvKernel32
Local $aResult = DllCall($hDll, "bool", "AddConsoleAlias" & ($fUnicode ? "W" : "A"), _
($fUnicode ? "w" : "") & "str", $sSource, _
($fUnicode ? "w" : "") & "str", $sTarget, _
($fUnicode ? "w" : "") & "str", $sExeName)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] <> 0
EndFunc ;==>_Console_AddAlias
; #FUNCTION# ====================================================================================================================
; Name ..........: _Console_Alloc
; Description ...: Allocates a new console for the calling process.
; Syntax ........: _Console_Alloc( [ $hDll ] )
; Parameters ....: $hDll - A handle to a dll to use. This prevents constant opening of the dll which could slow it
; down. If you are calling lots of functions from the same dll then this recommended.
; Return values .: Success - True