· 5 years ago · Jul 11, 2020, 12:12 PM
1Global EVENT_SYSTEM_MENUPOPUPSTART := 0x0006
2Global EVENT_SYSTEM_MENUSTART := 0x0004
3Global EVENT_OBJECT_DRAGSTART := 0x8021
4Global EVENT_OBJECT_DRAGCOMPLETE:= 0x8023
5;Event Ranges of WinEvent constant values specified by AIA for use across the industry.
6
7EVENT_AIA_START := 0xA000
8EVENT_AIA_END := 0xAFFF
9EVENT_MIN := 0x00000001
10EVENT_MAX := 0x7FFFFFFF
11EVENT_UIA_EVENTID_START := 0x4E00
12EVENT_UIA_EVENTID_END := 0x4EFF
13 ; The range of event constant values reserved for UI Automation event identifiers. For more information, see Allocation of WinEvent IDs.
14
15EVENT_UIA_PROPID_START := 0x7500
16EVENT_UIA_PROPID_END := 0x75FF
17 ; The range of event constant values reserved for UI Automation property-changed event identifiers. For more information, see Allocation of WinEvent IDs.
18
19 ;Events
20
21EVENT_OBJECT_ACCELERATORCHANGE:=0x8012
22 ;An object's KeyboardShortcut property has changed. Server applications send this event for their accessible objects.
23
24EVENT_OBJECT_CLOAKED:=0x8017
25 ;Sent when a window is cloaked. A cloaked window still exists, but is invisible to the user.
26
27EVENT_OBJECT_CONTENTSCROLLED:=0x8015
28 ; A window object's scrolling has ended. Unlike EVENT_SYSTEM_SCROLLEND, this event is associated with the scrolling window. Whether the scrolling is horizontal or vertical scrolling, this event should be sent whenever the scroll action is completed.
29 ; The hwnd parameter of the WinEventProc callback function describes the scrolling window; the idObject parameter is OBJID_CLIENT, and the idChild parameter is CHILDID_SELF.
30
31EVENT_OBJECT_CREATE:=0x8000
32
33 ; An object has been created. The system sends this event for the following user interface elements: caret, header control, list-view control, tab control, toolbar control, tree view control, and window object. Server applications send this event for their accessible objects.
34 ; Before sending the event for the parent object, servers must send it for all of an object's child objects. Servers must ensure that all child objects are fully created and ready to accept IAccessible calls from clients before the parent object sends this event.
35 ; Because a parent object is created after its child objects, clients must make sure that an object's parent has been created before calling IAccessible::get_accParent, particularly if in-context hook functions are used.
36
37EVENT_OBJECT_DEFACTIONCHANGE:=0x8011
38
39 ; An object's DefaultAction property has changed. The system sends this event for dialog boxes. Server applications send this event for their accessible objects.
40
41EVENT_OBJECT_DESCRIPTIONCHANGE:=0x800D
42
43 ; An object's Description property has changed. Server applications send this event for their accessible objects.
44
45EVENT_OBJECT_DESTROY:=0x8001
46
47 ; An object has been destroyed. The system sends this event for the following user interface elements: caret, header control, list-view control, tab control, toolbar control, tree view control, and window object. Server applications send this event for their accessible objects.
48 ; Clients assume that all of an object's children are destroyed when the parent object sends this event.
49 ; After receiving this event, clients do not call an object's IAccessible properties or methods. However, the interface pointer must remain valid as long as there is a reference count on it (due to COM rules), but the UI element may no longer be present. Further calls on the interface pointer may return failure errors; to prevent this, servers create proxy objects and monitor their life spans.
50
51EVENT_OBJECT_DRAGSTART:=0x8021
52
53 ; The user started to drag an element. The hwnd, idObject, and idChild parameters of the WinEventProc callback function identify the object being dragged.
54
55EVENT_OBJECT_DRAGCANCEL:=0x8022
56
57 ; The user has ended a drag operation before dropping the dragged element on a drop target. The hwnd, idObject, and idChild parameters of the WinEventProc callback function identify the object being dragged.
58
59EVENT_OBJECT_DRAGCOMPLETE:=0x8023
60
61 ; The user dropped an element on a drop target. The hwnd, idObject, and idChild parameters of the WinEventProc callback function identify the object being dragged.
62
63EVENT_OBJECT_DRAGENTER:=0x8024
64
65 ; The user dragged an element into a drop target's boundary. The hwnd, idObject, and idChild parameters of the WinEventProc callback function identify the drop target.
66
67EVENT_OBJECT_DRAGLEAVE:=0x8025
68
69 ; The user dragged an element out of a drop target's boundary. The hwnd, idObject, and idChild parameters of the WinEventProc callback function identify the drop target.
70
71EVENT_OBJECT_DRAGDROPPED:=0x8026
72
73 ; The user dropped an element on a drop target. The hwnd, idObject, and idChild parameters of the WinEventProc callback function identify the drop target.
74
75EVENT_OBJECT_END:=0x80FF
76
77 ; The highest object event value.
78
79EVENT_OBJECT_FOCUS:=0x8005
80
81 ; An object has received the keyboard focus. The system sends this event for the following user interface elements: list-view control, menu bar, pop-up menu, switch window, tab control, tree view control, and window object. Server applications send this event for their accessible objects.
82 ; The hwnd parameter of the WinEventProc callback function identifies the window that receives the keyboard focus.
83
84EVENT_OBJECT_HELPCHANGE:=0x8010
85
86 ; An object's Help property has changed. Server applications send this event for their accessible objects.
87
88EVENT_OBJECT_HIDE:=0x8003
89
90 ; An object is hidden. The system sends this event for the following user interface elements: caret and cursor. Server applications send this event for their accessible objects.
91 ; When this event is generated for a parent object, all child objects are already hidden. Server applications do not send this event for the child objects.
92 ; Hidden objects include the STATE_SYSTEM_INVISIBLE flag; shown objects do not include this flag. The EVENT_OBJECT_HIDE event also indicates that the STATE_SYSTEM_INVISIBLE flag is set. Therefore, servers do not send the EVENT_STATE_CHANGE event in this case.
93
94EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED:=0x8020
95
96 ; A window that hosts other accessible objects has changed the hosted objects. A client might need to query the host window to discover the new hosted objects, especially if the client has been monitoring events from the window. A hosted object is an object from an accessibility framework (MSAA or UI Automation) that is different from that of the host. Changes in hosted objects that are from the same framework as the host should be handed with the structural change events, such as EVENT_OBJECT_CREATE for MSAA. For more info see comments within winuser.h.
97
98EVENT_OBJECT_IME_HIDE:=0x8028
99
100 ; An IME window has become hidden.
101
102EVENT_OBJECT_IME_SHOW:=0x8027
103
104 ; An IME window has become visible.
105
106EVENT_OBJECT_IME_CHANGE:=0x8029
107
108 ; The size or position of an IME window has changed.
109
110EVENT_OBJECT_INVOKED:=0x8013
111
112 ; An object has been invoked; for example, the user has clicked a button. This event is supported by common controls and is used by UI Automation.
113 ; For this event, the hwnd, ID, and idChild parameters of the WinEventProc callback function identify the item that is invoked.
114
115EVENT_OBJECT_LIVEREGIONCHANGED:=0x8019
116
117 ; An object that is part of a live region has changed. A live region is an area of an application that changes frequently and/or asynchronously.
118
119EVENT_OBJECT_LOCATIONCHANGE:=0x800B
120
121 ; An object has changed location, shape, or size. The system sends this event for the following user interface elements: caret and window objects. Server applications send this event for their accessible objects.
122 ; This event is generated in response to a change in the top-level object within the object hierarchy; it is not generated for any children that the object might have. For example, if the user resizes a window, the system sends this notification for the window, but not for the menu bar, title bar, scroll bar, or other objects that have also changed.
123 ; The system does not send this event for every non-floating child window when the parent moves. However, if an application explicitly resizes child windows as a result of resizing the parent window, the system sends multiple events for the resized children.
124 ; If an object's State property is set to STATE_SYSTEM_FLOATING, the server sends EVENT_OBJECT_LOCATIONCHANGE whenever the object changes location. If an object does not have this state, servers only trigger this event when the object moves in relation to its parent. For this event notification, the idChild parameter of the WinEventProc callback function identifies the child object that has changed.
125
126EVENT_OBJECT_NAMECHANGE:=0x800C
127
128 ; An object's Name property has changed. The system sends this event for the following user interface elements: check box, cursor, list-view control, push button, radio button, status bar control, tree view control, and window object. Server applications send this event for their accessible objects.
129
130EVENT_OBJECT_PARENTCHANGE:=0x800F
131 ; An object has a new parent object. Server applications send this event for their accessible objects.
132
133EVENT_OBJECT_REORDER:=0x8004
134 ; A container object has added, removed, or reordered its children. The system sends this event for the following user interface elements: header control, list-view control, toolbar control, and window object. Server applications send this event as appropriate for their accessible objects.
135 ; For example, this event is generated by a list-view object when the number of child elements or the order of the elements changes. This event is also sent by a parent window when the Z-order for the child windows changes.
136
137EVENT_OBJECT_SELECTION:=0x8006
138 ; The selection within a container object has changed. The system sends this event for the following user interface elements: list-view control, tab control, tree view control, and window object. Server applications send this event for their accessible objects.
139 ; This event signals a single selection: either a child is selected in a container that previously did not contain any selected children, or the selection has changed from one child to another.
140 ; The hwnd and idObject parameters of the WinEventProc callback function describe the container; the idChild parameter identifies the object that is selected. If the selected child is a window that also contains objects, the idChild parameter is OBJID_WINDOW.
141
142EVENT_OBJECT_SELECTIONADD:=0x8007
143 ; A child within a container object has been added to an existing selection. The system sends this event for the following user interface elements: list box, list-view control, and tree view control. Server applications send this event for their accessible objects.
144 ; The hwnd and idObject parameters of the WinEventProc callback function describe the container. The idChild parameter is the child that is added to the selection.
145
146EVENT_OBJECT_SELECTIONREMOVE:=0x8008
147 ; An item within a container object has been removed from the selection. The system sends this event for the following user interface elements: list box, list-view control, and tree view control. Server applications send this event for their accessible objects.
148 ; This event signals that a child is removed from an existing selection.
149 ; The hwnd and idObject parameters of the WinEventProc callback function describe the container; the idChild parameter identifies the child that has been removed from the selection.
150
151EVENT_OBJECT_SELECTIONWITHIN:=0x8009
152 ; Numerous selection changes have occurred within a container object. The system sends this event for list boxes; server applications send it for their accessible objects.
153 ; This event is sent when the selected items within a control have changed substantially. The event informs the client that many selection changes have occurred, and it is sent instead of several EVENT_OBJECT_SELECTIONADD or EVENT_OBJECT_SELECTIONREMOVE events. The client queries for the selected items by calling the container object's IAccessible::get_accSelection method and enumerating the selected items.
154 ; For this event notification, the hwnd and idObject parameters of the WinEventProc callback function describe the container in which the changes occurred.
155
156EVENT_OBJECT_SHOW:=0x8002
157; A hidden object is shown. The system sends this event for the following user interface elements: caret, cursor, and window object. Server applications send this event for their accessible objects.
158; Clients assume that when this event is sent by a parent object, all child objects are already displayed. Therefore, server applications do not send this event for the child objects.
159; Hidden objects include the STATE_SYSTEM_INVISIBLE flag; shown objects do not include this flag. The EVENT_OBJECT_SHOW event also indicates that the STATE_SYSTEM_INVISIBLE flag is cleared. Therefore, servers do not send the EVENT_STATE_CHANGE event in this case.
160
161EVENT_OBJECT_STATECHANGE:=0x800A
162 ; An object's state has changed. The system sends this event for the following user interface elements: check box, combo box, header control, push button, radio button, scroll bar, toolbar control, tree view control, up-down control, and window object. Server applications send this event for their accessible objects.
163 ; For example, a state change occurs when a button object is clicked or released, or when an object is enabled or disabled.
164 ; For this event notification, the idChild parameter of the WinEventProc callback function identifies the child object whose state has changed.
165
166EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED:=0x8030
167 ; The conversion target within an IME composition has changed. The conversion target is the subset of the IME composition which is actively selected as the target for user-initiated conversions.
168
169EVENT_OBJECT_TEXTSELECTIONCHANGED:=0x8014
170 ; An object's text selection has changed. This event is supported by common controls and is used by UI Automation.
171 ; The hwnd, ID, and idChild parameters of the WinEventProc callback function describe the item that is contained in the updated text selection.
172
173EVENT_OBJECT_UNCLOAKED:=0x8018
174 ; Sent when a window is uncloaked. A cloaked window still exists, but is invisible to the user.
175
176EVENT_OBJECT_VALUECHANGE:=0x800E
177 ; An object's Value property has changed. The system sends this event for the user interface elements that include the scroll bar and the following controls: edit, header, hot key, progress bar, slider, and up-down. Server applications send this event for their accessible objects.
178
179EVENT_OEM_DEFINED_START / EVENT_OEM_DEFINED_END:=0x0101-0x01FF
180 ; The range of event constant values reserved for OEMs. For more information, see Allocation of WinEvent IDs.
181
182EVENT_SYSTEM_ALERT:=0x0002
183 ; An alert has been generated. Server applications should not send this event.
184
185EVENT_SYSTEM_ARRANGMENTPREVIEW:=0x8016
186 ; A preview rectangle is being displayed.
187
188EVENT_SYSTEM_CAPTUREEND:=0x0009
189 ; A window has lost mouse capture. This event is sent by the system, never by servers.
190
191EVENT_SYSTEM_CAPTURESTART:=0x0008
192 ; A window has received mouse capture. This event is sent by the system, never by servers.
193
194EVENT_SYSTEM_CONTEXTHELPEND:=0x000D
195
196 ; A window has exited context-sensitive Help mode. This event is not sent consistently by the system.
197
198EVENT_SYSTEM_CONTEXTHELPSTART:=0x000C
199
200 ; A window has entered context-sensitive Help mode. This event is not sent consistently by the system.
201
202EVENT_SYSTEM_DESKTOPSWITCH:=0x0020
203
204 ; The active desktop has been switched.
205
206EVENT_SYSTEM_DIALOGEND:=0x0011
207
208 ; A dialog box has been closed. The system sends this event for standard dialog boxes; servers send it for custom dialog boxes. This event is not sent consistently by the system.
209
210EVENT_SYSTEM_DIALOGSTART:=0x0010
211
212 ; A dialog box has been displayed. The system sends this event for standard dialog boxes, which are created using resource templates or Win32 dialog box functions. Servers send this event for custom dialog boxes, which are windows that function as dialog boxes but are not created in the standard way.
213 ; This event is not sent consistently by the system.
214
215EVENT_SYSTEM_DRAGDROPEND:=0x000F
216
217 ; An application is about to exit drag-and-drop mode. Applications that support drag-and-drop operations must send this event; the system does not send this event.
218
219EVENT_SYSTEM_DRAGDROPSTART:=0x000E
220
221 ; An application is about to enter drag-and-drop mode. Applications that support drag-and-drop operations must send this event because the system does not send it.
222
223EVENT_SYSTEM_END:=0x00FF
224
225 ; The highest system event value.
226
227EVENT_SYSTEM_FOREGROUND:=0x0003
228
229 ; The foreground window has changed. The system sends this event even if the foreground window has changed to another window in the same thread. Server applications never send this event.
230 ; For this event, the WinEventProc callback function's hwnd parameter is the handle to the window that is in the foreground, the idObject parameter is OBJID_WINDOW, and the idChild parameter is CHILDID_SELF.
231
232EVENT_SYSTEM_MENUPOPUPEND:=0x0007
233
234 ; A pop-up menu has been closed. The system sends this event for standard menus; servers send it for custom menus.
235 ; When a pop-up menu is closed, the client receives this message, and then the EVENT_SYSTEM_MENUEND event.
236 ; This event is not sent consistently by the system.
237
238EVENT_SYSTEM_MENUPOPUPSTART:=0x0006
239
240 ; A pop-up menu has been displayed. The system sends this event for standard menus, which are identified by HMENU, and are created using menu-template resources or Win32 menu functions. Servers send this event for custom menus, which are user interface elements that function as menus but are not created in the standard way. This event is not sent consistently by the system.
241
242EVENT_SYSTEM_MENUEND:=0x0005
243
244 ; A menu from the menu bar has been closed. The system sends this event for standard menus; servers send it for custom menus.
245 ; For this event, the WinEventProc callback function's hwnd, idObject, and idChild parameters refer to the control that contains the menu bar or the control that activates the context menu. The hwnd parameter is the handle to the window that is related to the event. The idObject parameter is OBJID_MENU or OBJID_SYSMENU for a menu, or OBJID_WINDOW for a pop-up menu. The idChild parameter is CHILDID_SELF.
246
247EVENT_SYSTEM_MENUSTART:=0x0004
248
249 ; A menu item on the menu bar has been selected. The system sends this event for standard menus, which are identified by HMENU, created using menu-template resources or Win32 menu API elements. Servers send this event for custom menus, which are user interface elements that function as menus but are not created in the standard way.
250 ; For this event, the WinEventProc callback function's hwnd, idObject, and idChild parameters refer to the control that contains the menu bar or the control that activates the context menu. The hwnd parameter is the handle to the window related to the event. The idObject parameter is OBJID_MENU or OBJID_SYSMENU for a menu, or OBJID_WINDOW for a pop-up menu. The idChild parameter is CHILDID_SELF.
251 ; The system triggers more than one EVENT_SYSTEM_MENUSTART event that does not always correspond with the EVENT_SYSTEM_MENUEND event.
252
253EVENT_SYSTEM_MINIMIZEEND:=0x0017
254
255 ; A window object is about to be restored. This event is sent by the system, never by servers.
256
257EVENT_SYSTEM_MINIMIZESTART:=0x0016
258
259 ; A window object is about to be minimized. This event is sent by the system, never by servers.
260
261EVENT_SYSTEM_MOVESIZEEND:=0x000B
262
263 ; The movement or resizing of a window has finished. This event is sent by the system, never by servers.
264
265EVENT_SYSTEM_MOVESIZESTART:=0x000A
266
267 ; A window is being moved or resized. This event is sent by the system, never by servers.
268
269EVENT_SYSTEM_SCROLLINGEND:=0x0013
270
271 ; Scrolling has ended on a scroll bar. This event is sent by the system for standard scroll bar controls and for scroll bars that are attached to a window. Servers send this event for custom scroll bars, which are user interface elements that function as scroll bars but are not created in the standard way.
272; The idObject parameter that is sent to the WinEventProc callback function is OBJID_HSCROLL for horizontal scroll bars, and OBJID_VSCROLL for vertical scroll bars.
273
274EVENT_SYSTEM_SCROLLINGSTART:=0x0012
275
276 ; Scrolling has started on a scroll bar. The system sends this event for standard scroll bar controls and for scroll bars attached to a window. Servers send this event for custom scroll bars, which are user interface elements that function as scroll bars but are not created in the standard way.
277; The idObject parameter that is sent to the WinEventProc callback function is OBJID_HSCROLL for horizontal scrolls bars, and OBJID_VSCROLL for vertical scroll bars.
278
279EVENT_SYSTEM_SOUND:=0x0001
280
281 ; A sound has been played. The system sends this event when a system sound, such as one for a menu, is played even if no sound is audible (for example, due to the lack of a sound file or a sound card). Servers send this event whenever a custom UI element generates a sound.
282; For this event, the WinEventProc callback function receives the OBJID_SOUND value as the idObject parameter.
283
284EVENT_SYSTEM_SWITCHEND:=0x0015
285
286 ; The user has released ALT+TAB. This event is sent by the system, never by servers. The hwnd parameter of the WinEventProc callback function identifies the window to which the user has switched.
287; If only one application is running when the user presses ALT+TAB, the system sends this event without a corresponding EVENT_SYSTEM_SWITCHSTART event.
288
289EVENT_SYSTEM_SWITCHSTART:=0x0014
290
291 ; The user has pressed ALT+TAB, which activates the switch window. This event is sent by the system, never by servers. The hwnd parameter of the WinEventProc callback function identifies the window to which the user is switching.
292; If only one application is running when the user presses ALT+TAB, the system sends an EVENT_SYSTEM_SWITCHEND event without a corresponding EVENT_SYSTEM_SWITCHSTART event.
293
294
295
296
297
298
299
300
301
302
303hWinEventHook := DllCall("SetWinEventHook", "UInt", EventX, "UInt", EventX, "Ptr", 0, "Ptr", (lpfnWinEventProc := RegisterCallback("OnEventX", "")), "UInt", 0, "UInt", 0, "UInt", WINEVENT_OUTOFCONTEXT := 0x0000 | WINEVENT_SKIPOWNPROCESS := 0x0002)
304
305OnEventX(hWinEventHook, event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime) {
306
307}
308
309
310
311
312OnExit("AtExit")
313
314AtExit() {
315 global hWinEventHook, lpfnWinEventProc
316 if (hWinEventHook)
317 DllCall("UnhookWinEvent", "Ptr", hWinEventHook), hWinEventHook := 0
318 if (lpfnWinEventProc)
319 DllCall("GlobalFree", "Ptr", lpfnWinEventProc, "Ptr"), lpfnWinEventProc := 0
320 return 0
321 }
322
323
324exit