-
Notifications
You must be signed in to change notification settings - Fork 72
/
class_WinStructs.ahk
364 lines (335 loc) · 8.61 KB
/
class_WinStructs.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
/*
WinStructs - A class to hold Window Structure Definitions
STYLE GUIDE
===========
ALWAYS Put a link to the MSDN page for the STRUCT
ALWAYS Use the same name as the Struct.
ALWAYS Use the EXACT same name for properties. If it has a lower-case prefix, keep it.
The reasons for this are two-fold.
1) The immediately obvious thing to do is to strip the lower case prefixes, however in some cases this would not be possible.
eg: KBDLLHOOKSTRUCT has vkCode and scanCode - you could not have two properties called "Code".
2) Consistency. Seeing as we cannot achieve consistency by stripping lower case prefixes, the next best solution is to keep them exactly as on MSDN.
Some properties on MSDN have prefixes, some do not. MSDN may not be consistent, be WinStructs is (With MSDN).
ToDo
====
* Some way of bundling defines with struct definition?
*/
Class WinStructs {
; Define locations - used to check validity of Structures by looking up the actual size from the specified windows header file.
; Set to 1 for default header file of "Windows.h"
; Set to -1 to not check (un-named sub-structs etc)
static Defines := { KBDLLHOOKSTRUCT: 1
, POINT: 1
, MSLLHOOKSTRUCT: 1
, RAWINPUTDEVICELIST: 1
, RID_DEVICE_INFO_MOUSE: 1
, RID_DEVICE_INFO_KEYBOARD: 1
, RID_DEVICE_INFO_HID: 1
, RID_DEVICE_INFO: 1
, HIDP_CAPS: ["Hidusage.h", "Hidpi.h"]
, RAWINPUTDEVICE: 1
, HIDP_BUTTON_CAPS_Range: -1
, HIDP_BUTTON_CAPS_NotRange: -1
, HIDP_BUTTON_CAPS: ["Hidusage.h", "Hidpi.h"]
, HIDP_VALUE_CAPS_Range: -1
, HIDP_VALUE_CAPS_NotRange: -1
, HIDP_VALUE_CAPS: ["Hidusage.h", "Hidpi.h"]
, RAWMOUSE: 1
, RAWKEYBOARD: 1
, RAWHID: 1
, RAWINPUTHEADER: 1
, RAWINPUT: 1
, STARTUPINFO: 1 }
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645568%28v=vs.85%29.aspx
static RAWINPUTDEVICELIST := "
(
HANDLE hDevice; // A handle to the raw input device.
DWORD dwType; // The type of device. This can be one of the following values
// RIM_TYPEHID 2 - The device is an HID that is not a keyboard and not a mouse
// RIM_TYPEKEYBOARD 1 - The device is a keyboard.
// RIM_TYPEMOUSE 0 - The device is a mouse.
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645589(v=vs.85).aspx
static RID_DEVICE_INFO_MOUSE := "
(
DWORD dwId;
DWORD dwNumberOfButtons;
DWORD dwSampleRate;
BOOL fHasHorizontalWheel;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645587(v=vs.85).aspx
static RID_DEVICE_INFO_KEYBOARD := "
(
DWORD dwType;
DWORD dwSubType;
DWORD dwKeyboardMode;
DWORD dwNumberOfFunctionKeys;
DWORD dwNumberOfIndicators;
DWORD dwNumberOfKeysTotal;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645584%28v=vs.85%29.aspx
static RID_DEVICE_INFO_HID := "
(
DWORD dwVendorId;
DWORD dwProductId;
DWORD dwVersionNumber;
USHORT usUsagePage;
USHORT usUsage;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645581%28v=vs.85%29.aspx
static RID_DEVICE_INFO := "
(
DWORD cbSize;
DWORD dwType;
{
WinStructs.RID_DEVICE_INFO_MOUSE mouse;
WinStructs.RID_DEVICE_INFO_KEYBOARD keyboard;
WinStructs.RID_DEVICE_INFO_HID hid;
}
)"
; https://msdn.microsoft.com/en-us/library/windows/hardware/ff539697(v=vs.85).aspx
static HIDP_CAPS := "
(
USHORT Usage;
USHORT UsagePage;
USHORT InputReportByteLength;
USHORT OutputReportByteLength;
USHORT FeatureReportByteLength;
USHORT Reserved[17];
USHORT NumberLinkCollectionNodes;
USHORT NumberInputButtonCaps;
USHORT NumberInputValueCaps;
USHORT NumberInputDataIndices;
USHORT NumberOutputButtonCaps;
USHORT NumberOutputValueCaps;
USHORT NumberOutputDataIndices;
USHORT NumberFeatureButtonCaps;
USHORT NumberFeatureValueCaps;
USHORT NumberFeatureDataIndices;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645565(v=vs.85).aspx
static RAWINPUTDEVICE := "
(
USHORT usUsagePage;
USHORT usUsage;
DWORD dwFlags;
HWND hwndTarget;
)"
; https://msdn.microsoft.com/en-gb/library/windows/hardware/ff539693(v=vs.85).aspx
static HIDP_BUTTON_CAPS_Range := "
(
USHORT UsageMin;
USHORT UsageMax;
USHORT StringMin;
USHORT StringMax;
USHORT DesignatorMin;
USHORT DesignatorMax;
USHORT DataIndexMin;
USHORT DataIndexMax;
)"
static HIDP_BUTTON_CAPS_NotRange := "
(
USHORT Usage;
USHORT Reserved1;
USHORT StringIndex;
USHORT Reserved2;
USHORT DesignatorIndex;
USHORT Reserved3;
USHORT DataIndex;
USHORT Reserved4;
)"
static HIDP_BUTTON_CAPS := "
(
USHORT UsagePage;
UCHAR ReportID;
BOOLEAN IsAlias;
USHORT BitField;
USHORT LinkCollection;
USHORT LinkUsage;
USHORT LinkUsagePage;
BOOLEAN IsRange;
BOOLEAN IsStringRange;
BOOLEAN IsDesignatorRange;
BOOLEAN IsAbsolute;
ULONG Reserved[10];
{
WinStructs.HIDP_BUTTON_CAPS_Range Range;
WinStructs.HIDP_BUTTON_CAPS_NotRange NotRange;
};
)"
; https://msdn.microsoft.com/en-us/library/windows/hardware/ff539832(v=vs.85).aspx
static HIDP_VALUE_CAPS_Range := "
(
USAGE UsageMin;
USAGE UsageMax;
USHORT StringMin;
USHORT StringMax;
USHORT DesignatorMin;
USHORT DesignatorMax;
USHORT DataIndexMin;
USHORT DataIndexMax;
)"
static HIDP_VALUE_CAPS_NotRange := "
(
USAGE Usage;
USAGE Reserved1;
USHORT StringIndex;
USHORT Reserved2;
USHORT DesignatorIndex;
USHORT Reserved3;
USHORT DataIndex;
USHORT Reserved4;
)"
static HIDP_VALUE_CAPS := "
(
USAGE UsagePage;
UCHAR ReportID;
BOOLEAN IsAlias;
USHORT BitField;
USHORT LinkCollection;
USAGE LinkUsage;
USAGE LinkUsagePage;
BOOLEAN IsRange;
BOOLEAN IsStringRange;
BOOLEAN IsDesignatorRange;
BOOLEAN IsAbsolute;
BOOLEAN HasNull;
UCHAR Reserved;
USHORT BitSize;
USHORT ReportCount;
USHORT Reserved2[5];
ULONG UnitsExp;
ULONG Units;
LONG LogicalMin;
LONG LogicalMax;
LONG PhysicalMin;
LONG PhysicalMax;
{
WinStructs.HIDP_VALUE_CAPS_Range Range;
WinStructs.HIDP_VALUE_CAPS_NotRange NotRange;
};
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645578(v=vs.85).aspx
static RAWMOUSE := "
(
USHORT usFlags;
{
ULONG ulButtons;
{
USHORT usButtonFlags;
USHORT usButtonData;
};
};
ULONG ulRawButtons;
LONG lLastX;
LONG lLastY;
ULONG ulExtraInformation;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645575(v=vs.85).aspx
static RAWKEYBOARD := "
(
USHORT MakeCode;
USHORT Flags;
USHORT Reserved;
USHORT VKey;
UINT Message;
ULONG ExtraInformation;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645549(v=vs.85).aspx
static RAWHID := "
(
DWORD dwSizeHid;
DWORD dwCount;
BYTE bRawData[1];
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645571(v=vs.85).aspx
static RAWINPUTHEADER := "
(
DWORD dwType;
DWORD dwSize;
HANDLE hDevice;
WPARAM wParam;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645562(v=vs.85).aspx
static RAWINPUT := "
(
WinStructs.RAWINPUTHEADER header;
{
WinStructs.RAWMOUSE mouse;
WinStructs.RAWKEYBOARD keyboard;
WinStructs.RAWHID hid;
}
BYTE buffer[49]; // buffer as the structure might differe for devices. ToDo: check on x64
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms644967(v=vs.85).aspx
static KBDLLHOOKSTRUCT := "
(
DWORD vkCode;
DWORD scanCode;
DWORD flags;
DWORD time;
ULONG_PTR dwExtraInfo;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms644970(v=vs.85).aspx
static MSLLHOOKSTRUCT := "
(
WinStructs.POINT pt;
{
DWORD mouseData;
struct {
WORD mouseData_low;
WORD mouseData_high;
};
};
DWORD flags;
DWORD time;
ULONG_PTR dwExtraInfo;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/dd162805(v=vs.85).aspx
static POINT := "
(
LONG x;
LONG y;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx
static RECT := "
(
LONG left;
LONG top;
LONG right;
LONG bottom;
)"
; https://msdn.microsoft.com/en-us/library/windows/desktop/bb787537(v=vs.85).aspx
static SCROLLINFO := "
(
UINT cbSize;
UINT fMask;
int nMin;
int nMax;
UINT nPage;
int nPos;
int nTrackPos;
)"
; https://msdn.microsoft.com/en-us/library/ms686331(v=vs.85).aspx
static STARTUPINFO := "
(
DWORD cb;
LPSTR lpReserved;
LPTSTR lpDesktop;
LPTSTR lpTitle;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
WORD wShowWindow;
WORD cbReserved2;
LPBYTE lpReserved2;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
)"
}