1 | 'api_console.sbp
|
---|
2 |
|
---|
3 | #ifdef UNICODE
|
---|
4 | Const _FuncName_PeekConsoleInput = "PeekConsoleInputW"
|
---|
5 | Const _FuncName_ReadConsoleInput = "ReadConsoleInputW"
|
---|
6 | Const _FuncName_WriteConsoleInput = "WriteConsoleInputW"
|
---|
7 | Const _FuncName_ReadConsoleOutput = "ReadConsoleOutputW"
|
---|
8 | Const _FuncName_WriteConsoleOutput = "WriteConsoleOutputW"
|
---|
9 | Const _FuncName_ReadConsoleOutputCharacter = "ReadConsoleOutputCharacterW"
|
---|
10 | Const _FuncName_WriteConsoleOutputCharacter = "WriteConsoleOutputCharacterW"
|
---|
11 | Const _FuncName_FillConsoleOutputCharacter = "FillConsoleOutputCharacterW"
|
---|
12 | Const _FuncName_ScrollConsoleScreenBuffer = "ScrollConsoleScreenBufferW"
|
---|
13 | Const _FuncName_GetConsoleTitle = "GetConsoleTitleW"
|
---|
14 | Const _FuncName_SetConsoleTitle = "SetConsoleTitleW"
|
---|
15 | Const _FuncName_ReadConsole = "ReadConsoleW"
|
---|
16 | Const _FuncName_WriteConsole = "WriteConsoleW"
|
---|
17 | #else
|
---|
18 | Const _FuncName_PeekConsoleInput = "PeekConsoleInputA"
|
---|
19 | Const _FuncName_ReadConsoleInput = "ReadConsoleInputA"
|
---|
20 | Const _FuncName_WriteConsoleInput = "WriteConsoleInputA"
|
---|
21 | Const _FuncName_ReadConsoleOutput = "ReadConsoleOutputA"
|
---|
22 | Const _FuncName_WriteConsoleOutput = "WriteConsoleOutputA"
|
---|
23 | Const _FuncName_ReadConsoleOutputCharacter = "ReadConsoleOutputCharacterA"
|
---|
24 | Const _FuncName_WriteConsoleOutputCharacter = "WriteConsoleOutputCharacterA"
|
---|
25 | Const _FuncName_FillConsoleOutputCharacter = "FillConsoleOutputCharacterA"
|
---|
26 | Const _FuncName_ScrollConsoleScreenBuffer = "ScrollConsoleScreenBufferA"
|
---|
27 | Const _FuncName_GetConsoleTitle = "GetConsoleTitleA"
|
---|
28 | Const _FuncName_SetConsoleTitle = "SetConsoleTitleA"
|
---|
29 | Const _FuncName_ReadConsole = "ReadConsoleA"
|
---|
30 | Const _FuncName_WriteConsole = "WriteConsoleA"
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | Type COORD
|
---|
34 | X As Integer
|
---|
35 | Y As Integer
|
---|
36 | End Type
|
---|
37 | TypeDef PCOORD = *COORD
|
---|
38 |
|
---|
39 | Type SMALL_RECT
|
---|
40 | Left As Integer
|
---|
41 | Top As Integer
|
---|
42 | Right As Integer
|
---|
43 | Bottom As Integer
|
---|
44 | End Type
|
---|
45 | TypeDef PSMALL_RECT = *SMALL_RECT
|
---|
46 |
|
---|
47 | Type KEY_EVENT_RECORD
|
---|
48 | bKeyDown As BOOL
|
---|
49 | wRepeatCount As Word
|
---|
50 | wVirtualKeyCode As Word
|
---|
51 | wVirtualScanCode As Word
|
---|
52 | uChar As WCHAR
|
---|
53 | dwControlKeyState As DWord
|
---|
54 | End Type
|
---|
55 | TypeDef PKEY_EVENT_RECORD = *KEY_EVENT_RECORD
|
---|
56 |
|
---|
57 | Const RIGHT_ALT_PRESSED = &H0001
|
---|
58 | Const LEFT_ALT_PRESSED = &H0002
|
---|
59 | Const RIGHT_CTRL_PRESSED = &H0004
|
---|
60 | Const LEFT_CTRL_PRESSED = &H0008
|
---|
61 | Const SHIFT_PRESSED = &H0010
|
---|
62 | Const NUMLOCK_ON = &H0020
|
---|
63 | Const SCROLLLOCK_ON = &H0040
|
---|
64 | Const CAPSLOCK_ON = &H0080
|
---|
65 | Const ENHANCED_KEY = &H0100
|
---|
66 | Const NLS_DBCSCHAR = &H00010000
|
---|
67 | Const NLS_ALPHANUMERIC = &H00000000
|
---|
68 | Const NLS_KATAKANA = &H00020000
|
---|
69 | Const NLS_HIRAGANA = &H00040000
|
---|
70 | Const NLS_ROMAN = &H00400000
|
---|
71 | Const NLS_IME_CONVERSION = &H00800000
|
---|
72 | Const NLS_IME_DISABLE = &H20000000
|
---|
73 |
|
---|
74 | Type MOUSE_EVENT_RECORD
|
---|
75 | dwMousePosition As COORD
|
---|
76 | dwButtonState As DWord
|
---|
77 | dwControlKeyState As DWord
|
---|
78 | dwEventFlags As DWord
|
---|
79 | End Type
|
---|
80 | TypeDef PMOUSE_EVENT_RECORD = *MOUSE_EVENT_RECORD
|
---|
81 |
|
---|
82 | Const FROM_LEFT_1ST_BUTTON_PRESSED = &H0001
|
---|
83 | Const RIGHTMOST_BUTTON_PRESSED = &H0002
|
---|
84 | Const FROM_LEFT_2ND_BUTTON_PRESSED = &H0004
|
---|
85 | Const FROM_LEFT_3RD_BUTTON_PRESSED = &H0008
|
---|
86 | Const FROM_LEFT_4TH_BUTTON_PRESSED = &H0010
|
---|
87 |
|
---|
88 | Const MOUSE_MOVED = &H0001
|
---|
89 | Const DOUBLE_CLICK = &H0002
|
---|
90 | Const MOUSE_WHEELED = &H0004
|
---|
91 |
|
---|
92 | Type WINDOW_BUFFER_SIZE_RECORD
|
---|
93 | dwSize As COORD
|
---|
94 | End Type
|
---|
95 | TypeDef PWINDOW_BUFFER_SIZE_RECORD = *WINDOW_BUFFER_SIZE_RECORD
|
---|
96 |
|
---|
97 | Type MENU_EVENT_RECORD
|
---|
98 | dwCommandId As DWord
|
---|
99 | End Type
|
---|
100 | TypeDef PMENU_EVENT_RECORD = *MENU_EVENT_RECORD
|
---|
101 |
|
---|
102 | Type FOCUS_EVENT_RECORD
|
---|
103 | bSetFocus As BOOL
|
---|
104 | End Type
|
---|
105 | TypeDef PFOCUS_EVENT_RECORD = *FOCUS_EVENT_RECORD
|
---|
106 |
|
---|
107 | Type INPUT_RECORD
|
---|
108 | EventType As Word
|
---|
109 | ' Union Event
|
---|
110 | KeyEvent As KEY_EVENT_RECORD
|
---|
111 | ' MouseEvent As MOUSE_EVENT_RECORD
|
---|
112 | ' WindowBufferSizeEvent As WINDOW_BUFFER_SIZE_RECORD
|
---|
113 | ' MenuEvent As MENU_EVENT_RECORD
|
---|
114 | ' FocusEvent As FOCUS_EVENT_RECORD
|
---|
115 | ' End Union
|
---|
116 | End Type
|
---|
117 | TypeDef PINPUT_RECORD = *INPUT_RECORD
|
---|
118 |
|
---|
119 | Const KEY_EVENT = &H0001
|
---|
120 | Const MOUSE_EVENT = &H0002
|
---|
121 | Const WINDOW_BUFFER_SIZE_EVENT = &H0004
|
---|
122 | Const MENU_EVENT = &H0008
|
---|
123 | Const FOCUS_EVENT = &H0010
|
---|
124 |
|
---|
125 | Type CHAR_INFO
|
---|
126 | ' Union Char
|
---|
127 | ' UnicodeChar As WCHAR
|
---|
128 | AsciiChar[1] As SByte
|
---|
129 | ' End Union
|
---|
130 | Attributes As Word
|
---|
131 | End Type
|
---|
132 | TypeDef PCHAR_INFO = *CHAR_INFO
|
---|
133 |
|
---|
134 | Const FOREGROUND_BLUE = &H0001
|
---|
135 | Const FOREGROUND_GREEN = &H0002
|
---|
136 | Const FOREGROUND_RED = &H0004
|
---|
137 | Const FOREGROUND_INTENSITY = &H0008
|
---|
138 | Const BACKGROUND_BLUE = &H0010
|
---|
139 | Const BACKGROUND_GREEN = &H0020
|
---|
140 | Const BACKGROUND_RED = &H0040
|
---|
141 | Const BACKGROUND_INTENSITY = &H0080
|
---|
142 | Const COMMON_LVB_LEADING_BYTE = &H0100
|
---|
143 | Const COMMON_LVB_TRAILING_BYTE = &H0200
|
---|
144 | Const COMMON_LVB_GRID_HORIZONTAL = &H0400
|
---|
145 | Const COMMON_LVB_GRID_LVERTICAL = &H0800
|
---|
146 | Const COMMON_LVB_GRID_RVERTICAL = &H1000
|
---|
147 | Const COMMON_LVB_REVERSE_VIDEO = &H4000
|
---|
148 | Const COMMON_LVB_UNDERSCORE = &H8000
|
---|
149 | Const COMMON_LVB_SBCSDBCS = &H0300
|
---|
150 |
|
---|
151 | Type CONSOLE_SCREEN_BUFFER_INFO
|
---|
152 | dwSize As COORD
|
---|
153 | dwCursorPosition As COORD
|
---|
154 | wAttributes As Word
|
---|
155 | srWindow As SMALL_RECT
|
---|
156 | dwMaximumWindowSize As COORD
|
---|
157 | End Type
|
---|
158 | TypeDef PCONSOLE_SCREEN_BUFFER_INFO = *CONSOLE_SCREEN_BUFFER_INFO
|
---|
159 |
|
---|
160 | Type CONSOLE_CURSOR_INFO
|
---|
161 | dwSize As DWord
|
---|
162 | bVisible As BOOL
|
---|
163 | End Type
|
---|
164 | TypeDef PCONSOLE_CURSOR_INFO = *CONSOLE_CURSOR_INFO
|
---|
165 |
|
---|
166 | TypeDef PHANDLER_ROUTINE = *Function(CtrlType As DWord) As BOOL
|
---|
167 |
|
---|
168 | Const CTRL_C_EVENT = 0
|
---|
169 | Const CTRL_BREAK_EVENT = 1
|
---|
170 | Const CTRL_CLOSE_EVENT = 2
|
---|
171 | Const CTRL_LOGOFF_EVENT = 5
|
---|
172 | Const CTRL_SHUTDOWN_EVENT = 6
|
---|
173 |
|
---|
174 | Const ENABLE_PROCESSED_INPUT = &H0001
|
---|
175 | Const ENABLE_LINE_INPUT = &H0002
|
---|
176 | Const ENABLE_ECHO_INPUT = &H0004
|
---|
177 | Const ENABLE_WINDOW_INPUT = &H0008
|
---|
178 | Const ENABLE_MOUSE_INPUT = &H0010
|
---|
179 | Const ENABLE_PROCESSED_OUTPUT = &H0001
|
---|
180 | Const ENABLE_WRAP_AT_EOL_OUTPUT = &H0002
|
---|
181 |
|
---|
182 | Declare Function PeekConsoleInput Lib "kernel32" Alias _FuncName_PeekConsoleInput (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
|
---|
183 | Declare Function ReadConsoleInput Lib "kernel32" Alias _FuncName_ReadConsoleInput (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
|
---|
184 | Declare Function WriteConsoleInput Lib "kernel32" Alias _FuncName_WriteConsoleInput (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsWritten As DWord) As BOOL
|
---|
185 | Declare Function ReadConsoleOutput Lib "kernel32" Alias _FuncName_ReadConsoleOutput (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpReadRegion As SMALL_RECT) As BOOL
|
---|
186 | Declare Function WriteConsoleOutput Lib "kernel32" Alias _FuncName_WriteConsoleOutput (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpWriteRegion As SMALL_RECT) As BOOL
|
---|
187 | Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias _FuncName_ReadConsoleOutputCharacter (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfCharsRead As DWord) As BOOL
|
---|
188 | Declare Function ReadConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfAttrsRead As DWord) As BOOL
|
---|
189 | Declare Function WriteConsoleOutputCharacter Lib "kernel32" Alias _FuncName_WriteConsoleOutputCharacter (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
|
---|
190 | Declare Function WriteConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
|
---|
191 | Declare Function FillConsoleOutputCharacter Lib "kernel32" Alias _FuncName_FillConsoleOutputCharacter (hConsoleOutput As HANDLE, cCharacter As Char, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
|
---|
192 | Declare Function FillConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttribute As Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
|
---|
193 | Declare Function GetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, ByRef lpMode As DWord) As BOOL
|
---|
194 | Declare Function GetNumberOfConsoleInputEvents Lib "kernel32" (hConsoleInput As HANDLE, ByRef lpNumberOfEvents As DWord) As BOOL
|
---|
195 | Declare Function GetConsoleScreenBufferInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As BOOL
|
---|
196 | Declare Function GetLargestConsoleWindowSize Lib "kernel32" (hConsoleOutput As HANDLE) As DWord
|
---|
197 | Declare Function GetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
|
---|
198 | Declare Function GetNumberOfConsoleMouseButtons Lib "kernel32" (ByRef lpNumberOfMouseButtons As DWord) As BOOL
|
---|
199 | Declare Function SetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, dwMode As DWord) As BOOL
|
---|
200 | Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
|
---|
201 | Declare Function FlushConsoleInputBuffer Lib "kernel32" (hConsoleInput As HANDLE) As BOOL
|
---|
202 | Declare Function SetConsoleScreenBufferSize Lib "kernel32" (hConsoleOutput As HANDLE, dwSize As DWord) As BOOL
|
---|
203 | Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
|
---|
204 | Declare Function SetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
|
---|
205 | Declare Function ScrollConsoleScreenBuffer Lib "kernel32" Alias _FuncName_ScrollConsoleScreenBuffer (hConsoleOutput As HANDLE, ByRef lpScrollRectangle As SMALL_RECT, lpClipRectangle As *SMALL_RECT, ByRef dwDestinationOrigin As COORD, lpFill As *CHAR_INFO) As BOOL
|
---|
206 | Declare Function SetConsoleWindowInfo Lib "kernel32" (hConsoleOutput As HANDLE, bAbsolute As BOOL, ByRef lpConsoleWindow As SMALL_RECT) As BOOL
|
---|
207 | Declare Function SetConsoleTextAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttributes As Word) As BOOL
|
---|
208 | Declare Function SetConsoleCtrlHandler Lib "kernel32" (HandlerRoutine As PHANDLER_ROUTINE, Add As BOOL) As BOOL
|
---|
209 | Declare Function GenerateConsoleCtrlEvent Lib "kernel32" (dwCtrlEvent As DWord, dwProcessGroupId As DWord) As BOOL
|
---|
210 | Declare Function AllocConsole Lib "kernel32" () As BOOL
|
---|
211 | Declare Function FreeConsole Lib "kernel32" () As BOOL
|
---|
212 | Declare Function GetConsoleTitle Lib "kernel32" Alias _FuncName_GetConsoleTitle (lpConsoleTitle As LPSTR, nSize As DWord) As DWord
|
---|
213 | Declare Function SetConsoleTitle Lib "kernel32" Alias _FuncName_SetConsoleTitle (lpConsoleTitle As LPSTR) As BOOL
|
---|
214 | Declare Function ReadConsole Lib "kernel32" Alias _FuncName_ReadConsole (hConsoleInput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef lpNumberOfCharsRead As DWord, lpReserved As VoidPtr) As BOOL
|
---|
215 | Declare Function WriteConsole Lib "kernel32" Alias _FuncName_WriteConsole (hConsoleOutput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef lpNumberOfCharsWritten As DWord, lpReserved As VoidPtr) As BOOL
|
---|
216 |
|
---|
217 | Const CONSOLE_TEXTMODE_BUFFER = 1
|
---|
218 |
|
---|
219 | Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, lpSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, lpScreenBufferData As VoidPtr) As HANDLE
|
---|
220 | Declare Function GetConsoleCP Lib "kernel32" () As DWord
|
---|
221 | Declare Function SetConsoleCP Lib "kernel32" (wCodePageID As DWord) As BOOL
|
---|
222 | Declare Function GetConsoleOutputCP Lib "kernel32" () As DWord
|
---|
223 | Declare Function SetConsoleOutputCP Lib "kernel32" (wCodePageID As DWord) As BOOL
|
---|