jwawinable.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. {******************************************************************************}
  2. { }
  3. { Hooking mechanism to receive system events interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: winable.h, released June 2000. The original Pascal }
  9. { code is: WinAble.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaWinAble.pas,v 1.8 2005/09/06 16:36:50 marquardt Exp $
  43. unit JwaWinAble;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "WinAble.h"'}
  47. {$HPPEMIT ''}
  48. {$I jediapilib.inc}
  49. interface
  50. uses
  51. JwaWindows;
  52. //
  53. // This gets GUI information out of context. If you pass in a NULL thread ID,
  54. // we will get the 'global' information, using the foreground thread. This
  55. // is guaranteed to be the real active window, focus window, etc. Yes, you
  56. // could do it yourself by calling GetForegorundWindow, getting the thread ID
  57. // of that window via GetWindowThreadProcessId, then passing the ID into
  58. // GetGUIThreadInfo(). However, that takes three calls and aside from being
  59. // a pain, anything could happen in the middle. So passing in NULL gets
  60. // you stuff in one call and hence also works right.
  61. //
  62. type
  63. LPGUITHREADINFO = ^GUITHREADINFO;
  64. {$EXTERNALSYM LPGUITHREADINFO}
  65. tagGUITHREADINFO = record
  66. cbSize: DWORD;
  67. flags: DWORD;
  68. hwndActive: HWND;
  69. hwndFocus: HWND;
  70. hwndCapture: HWND;
  71. hwndMenuOwner: HWND;
  72. hwndMoveSize: HWND;
  73. hwndCaret: HWND;
  74. rcCaret: RECT;
  75. end;
  76. {$EXTERNALSYM tagGUITHREADINFO}
  77. GUITHREADINFO = tagGUITHREADINFO;
  78. {$EXTERNALSYM GUITHREADINFO}
  79. TGuiThreadInfo = GUITHREADINFO;
  80. PGuiThreadInfo = LPGUITHREADINFO;
  81. const
  82. GUI_CARETBLINKING = $00000001;
  83. {$EXTERNALSYM GUI_CARETBLINKING}
  84. GUI_INMOVESIZE = $00000002;
  85. {$EXTERNALSYM GUI_INMOVESIZE}
  86. GUI_INMENUMODE = $00000004;
  87. {$EXTERNALSYM GUI_INMENUMODE}
  88. GUI_SYSTEMMENUMODE = $00000008;
  89. {$EXTERNALSYM GUI_SYSTEMMENUMODE}
  90. GUI_POPUPMENUMODE = $00000010;
  91. {$EXTERNALSYM GUI_POPUPMENUMODE}
  92. function GetGUIThreadInfo(idThread: DWORD; var lpgui: GUITHREADINFO): BOOL; stdcall;
  93. {$EXTERNALSYM GetGUIThreadInfo}
  94. function GetWindowModuleFileNameW(hwnd: HWND; lpFileName: LPWSTR; cchFileName: UINT): UINT; stdcall;
  95. {$EXTERNALSYM GetWindowModuleFileNameW}
  96. function GetWindowModuleFileNameA(hwnd: HWND; lpFileName: LPSTR; cchFileName: UINT): UINT; stdcall;
  97. {$EXTERNALSYM GetWindowModuleFileNameA}
  98. function GetWindowModuleFileName(hwnd: HWND; lpFileName: LPTSTR; cchFileName: UINT): UINT; stdcall;
  99. {$EXTERNALSYM GetWindowModuleFileName}
  100. //
  101. // This returns FALSE if the caller doesn't have permissions to do this
  102. // esp. if someone else is dorking with input. I.E., if some other thread
  103. // disabled input, and thread 2 tries to diable/enable it, the call will
  104. // fail since thread 1 has the cookie.
  105. //
  106. function BlockInput(fBlockIt: BOOL): BOOL; stdcall;
  107. {$EXTERNALSYM BlockInput}
  108. //
  109. // Note that the dwFlags field uses the same flags as keybd_event and
  110. // mouse_event, depending on what type of input this is.
  111. //
  112. type
  113. LPMOUSEINPUT = ^MOUSEINPUT;
  114. {$EXTERNALSYM LPMOUSEINPUT}
  115. PMOUSEINPUT = ^MOUSEINPUT;
  116. {$EXTERNALSYM PMOUSEINPUT}
  117. tagMOUSEINPUT = record
  118. dx: LONG;
  119. dy: LONG;
  120. mouseData: DWORD;
  121. dwFlags: DWORD;
  122. time: DWORD;
  123. dwExtraInfo: DWORD;
  124. end;
  125. {$EXTERNALSYM tagMOUSEINPUT}
  126. MOUSEINPUT = tagMOUSEINPUT;
  127. {$EXTERNALSYM MOUSEINPUT}
  128. TMouseInput = MOUSEINPUT;
  129. LPKEYBDINPUT = ^KEYBDINPUT;
  130. {$EXTERNALSYM LPKEYBDINPUT}
  131. PKEYBDINPUT = ^KEYBDINPUT;
  132. {$EXTERNALSYM PKEYBDINPUT}
  133. tagKEYBDINPUT = record
  134. wVk: WORD;
  135. wScan: WORD;
  136. dwFlags: DWORD;
  137. time: DWORD;
  138. dwExtraInfo: DWORD;
  139. end;
  140. {$EXTERNALSYM tagKEYBDINPUT}
  141. KEYBDINPUT = tagKEYBDINPUT;
  142. {$EXTERNALSYM KEYBDINPUT}
  143. TKeybdInput = KEYBDINPUT;
  144. LPHARDWAREINPUT = ^HARDWAREINPUT;
  145. {$EXTERNALSYM LPHARDWAREINPUT}
  146. PHARDWAREINPUT = ^HARDWAREINPUT;
  147. {$EXTERNALSYM PHARDWAREINPUT}
  148. tagHARDWAREINPUT = record
  149. uMsg: DWORD;
  150. wParamL: WORD;
  151. wParamH: WORD;
  152. dwExtraInfo: DWORD;
  153. end;
  154. {$EXTERNALSYM tagHARDWAREINPUT}
  155. HARDWAREINPUT = tagHARDWAREINPUT;
  156. {$EXTERNALSYM HARDWAREINPUT}
  157. THardwareInput = HARDWAREINPUT;
  158. const
  159. INPUT_MOUSE = 0;
  160. {$EXTERNALSYM INPUT_MOUSE}
  161. INPUT_KEYBOARD = 1;
  162. {$EXTERNALSYM INPUT_KEYBOARD}
  163. INPUT_HARDWARE = 2;
  164. {$EXTERNALSYM INPUT_HARDWARE}
  165. type
  166. LPINPUT = ^INPUT;
  167. {$EXTERNALSYM LPINPUT}
  168. PINPUT = ^INPUT;
  169. {$EXTERNALSYM PINPUT}
  170. tagINPUT = record
  171. type_: DWORD;
  172. case Integer of
  173. 0: (mi: MOUSEINPUT);
  174. 1: (ki: KEYBDINPUT);
  175. 2: (hi: HARDWAREINPUT);
  176. end;
  177. {$EXTERNALSYM tagINPUT}
  178. INPUT = tagINPUT;
  179. {$EXTERNALSYM INPUT}
  180. TInput = INPUT;
  181. //
  182. // This returns the number of inputs played back. It will disable input
  183. // first, play back as many as possible, then reenable input. In the middle
  184. // it will pulse the RIT to make sure that the fixed input queue doesn't
  185. // fill up.
  186. //
  187. function SendInput(cInputs: UINT; pInputs: LPINPUT; cbSize: Integer): UINT; stdcall;
  188. {$EXTERNALSYM SendInput}
  189. const
  190. CCHILDREN_FRAME = 7;
  191. {$EXTERNALSYM CCHILDREN_FRAME}
  192. //
  193. // This generates a notification that anyone watching for it will get.
  194. // This call is superfast if nobody is hooking anything.
  195. //
  196. procedure NotifyWinEvent(event: DWORD; hwnd: HWND; idObject, idChild: LONG); stdcall;
  197. {$EXTERNALSYM NotifyWinEvent}
  198. //
  199. // hwnd + idObject can be used with OLEACC.DLL's OleGetObjectFromWindow()
  200. // to get an interface pointer to the container. indexChild is the item
  201. // within the container in question. Setup a VARIANT with vt VT_I4 and
  202. // lVal the indexChild and pass that in to all methods. Then you
  203. // are raring to go.
  204. //
  205. //
  206. // Common object IDs (cookies, only for sending WM_GETOBJECT to get at the
  207. // thing in question). Positive IDs are reserved for apps (app specific),
  208. // negative IDs are system things and are global, 0 means "just little old
  209. // me".
  210. //
  211. const
  212. CHILDID_SELF = 0;
  213. {$EXTERNALSYM CHILDID_SELF}
  214. // Reserved IDs for system objects
  215. OBJID_WINDOW = DWORD($00000000);
  216. {$EXTERNALSYM OBJID_WINDOW}
  217. OBJID_SYSMENU = DWORD($FFFFFFFF);
  218. {$EXTERNALSYM OBJID_SYSMENU}
  219. OBJID_TITLEBAR = DWORD($FFFFFFFE);
  220. {$EXTERNALSYM OBJID_TITLEBAR}
  221. OBJID_MENU = DWORD($FFFFFFFD);
  222. {$EXTERNALSYM OBJID_MENU}
  223. OBJID_CLIENT = DWORD($FFFFFFFC);
  224. {$EXTERNALSYM OBJID_CLIENT}
  225. OBJID_VSCROLL = DWORD($FFFFFFFB);
  226. {$EXTERNALSYM OBJID_VSCROLL}
  227. OBJID_HSCROLL = DWORD($FFFFFFFA);
  228. {$EXTERNALSYM OBJID_HSCROLL}
  229. OBJID_SIZEGRIP = DWORD($FFFFFFF9);
  230. {$EXTERNALSYM OBJID_SIZEGRIP}
  231. OBJID_CARET = DWORD($FFFFFFF8);
  232. {$EXTERNALSYM OBJID_CARET}
  233. OBJID_CURSOR = DWORD($FFFFFFF7);
  234. {$EXTERNALSYM OBJID_CURSOR}
  235. OBJID_ALERT = DWORD($FFFFFFF6);
  236. {$EXTERNALSYM OBJID_ALERT}
  237. OBJID_SOUND = DWORD($FFFFFFF5);
  238. {$EXTERNALSYM OBJID_SOUND}
  239. //
  240. // System Alerts (indexChild of system ALERT notification)
  241. //
  242. ALERT_SYSTEM_INFORMATIONAL = 1; // MB_INFORMATION
  243. {$EXTERNALSYM ALERT_SYSTEM_INFORMATIONAL}
  244. ALERT_SYSTEM_WARNING = 2; // MB_WARNING
  245. {$EXTERNALSYM ALERT_SYSTEM_WARNING}
  246. ALERT_SYSTEM_ERROR = 3; // MB_ERROR
  247. {$EXTERNALSYM ALERT_SYSTEM_ERROR}
  248. ALERT_SYSTEM_QUERY = 4; // MB_QUESTION
  249. {$EXTERNALSYM ALERT_SYSTEM_QUERY}
  250. ALERT_SYSTEM_CRITICAL = 5; // HardSysErrBox
  251. {$EXTERNALSYM ALERT_SYSTEM_CRITICAL}
  252. CALERT_SYSTEM = 6;
  253. {$EXTERNALSYM CALERT_SYSTEM}
  254. type
  255. HWINEVENTHOOK = DWORD;
  256. {$EXTERNALSYM HWINEVENTHOOK}
  257. WINEVENTPROC = procedure(
  258. hEvent: HWINEVENTHOOK;
  259. event: DWORD;
  260. hwnd: HWND;
  261. idObject: LONG;
  262. idChild: LONG;
  263. idEventThread: DWORD;
  264. dwmsEventTime: DWORD); stdcall;
  265. {$EXTERNALSYM WINEVENTPROC}
  266. TWinEventProc = WINEVENTPROC;
  267. const
  268. WINEVENT_OUTOFCONTEXT = $0000; // Events are ASYNC
  269. {$EXTERNALSYM WINEVENT_OUTOFCONTEXT}
  270. WINEVENT_SKIPOWNTHREAD = $0001; // Don't call back for events on installer's thread
  271. {$EXTERNALSYM WINEVENT_SKIPOWNTHREAD}
  272. WINEVENT_SKIPOWNPROCESS = $0002; // Don't call back for events on installer's process
  273. {$EXTERNALSYM WINEVENT_SKIPOWNPROCESS}
  274. WINEVENT_INCONTEXT = $0004; // Events are SYNC, this causes your dll to be injected into every process
  275. {$EXTERNALSYM WINEVENT_INCONTEXT}
  276. WINEVENT_32BITCALLER = $8000; // ;Internal
  277. {$EXTERNALSYM WINEVENT_32BITCALLER}
  278. WINEVENT_VALID = $8007; // ;Internal
  279. {$EXTERNALSYM WINEVENT_VALID}
  280. function SetWinEventHook(eventMin, eventMax: DWORD; hmodWinEventProc: HMODULE;
  281. lpfnWinEventProc: WINEVENTPROC; idProcess, idThread, dwFlags: DWORD): HWINEVENTHOOK; stdcall;
  282. {$EXTERNALSYM SetWinEventHook}
  283. //
  284. // Returns zero on failure, or a DWORD ID if success. We will clean up any
  285. // event hooks installed by the current process when it goes away, if it
  286. // hasn't cleaned the hooks up itself. But to dynamically unhook, call
  287. // UnhookWinEvents().
  288. //
  289. function UnhookWinEvent(hEvent: HWINEVENTHOOK): BOOL; stdcall;
  290. {$EXTERNALSYM UnhookWinEvent}
  291. //
  292. // If idProcess isn't zero but idThread is, will hook all threads in that
  293. // process.
  294. // If idThread isn't zero but idProcess is, will hook idThread only.
  295. // If both are zero, will hook everything
  296. //
  297. //
  298. // EVENT DEFINITION
  299. //
  300. const
  301. EVENT_MIN = $00000001;
  302. {$EXTERNALSYM EVENT_MIN}
  303. EVENT_MAX = $7FFFFFFF;
  304. {$EXTERNALSYM EVENT_MAX}
  305. //
  306. // EVENT_SYSTEM_SOUND
  307. // Sent when a sound is played. Currently nothing is generating this, we
  308. // are going to be cleaning up the SOUNDSENTRY feature in the control panel
  309. // and will use this at that time. Applications implementing WinEvents
  310. // are perfectly welcome to use it. Clients of IAccessible* will simply
  311. // turn around and get back a non-visual object that describes the sound.
  312. //
  313. EVENT_SYSTEM_SOUND = $0001;
  314. {$EXTERNALSYM EVENT_SYSTEM_SOUND}
  315. //
  316. // EVENT_SYSTEM_ALERT
  317. // Sent when an alert needs to be given to the user. MessageBoxes generate
  318. // alerts for example.
  319. //
  320. EVENT_SYSTEM_ALERT = $0002;
  321. {$EXTERNALSYM EVENT_SYSTEM_ALERT}
  322. //
  323. // EVENT_SYSTEM_FOREGROUND
  324. // Sent when the foreground (active) window changes, even if it is changing
  325. // to another window in the same thread as the previous one.
  326. //
  327. EVENT_SYSTEM_FOREGROUND = $0003;
  328. {$EXTERNALSYM EVENT_SYSTEM_FOREGROUND}
  329. //
  330. // EVENT_SYSTEM_MENUSTART
  331. // EVENT_SYSTEM_MENUEND
  332. // Sent when entering into and leaving from menu mode (system, app bar, and
  333. // track popups).
  334. //
  335. EVENT_SYSTEM_MENUSTART = $0004;
  336. {$EXTERNALSYM EVENT_SYSTEM_MENUSTART}
  337. EVENT_SYSTEM_MENUEND = $0005;
  338. {$EXTERNALSYM EVENT_SYSTEM_MENUEND}
  339. //
  340. // EVENT_SYSTEM_MENUPOPUPSTART
  341. // EVENT_SYSTEM_MENUPOPUPEND
  342. // Sent when a menu popup comes up and just before it is taken down. Note
  343. // that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
  344. // followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
  345. // being shown.
  346. //
  347. EVENT_SYSTEM_MENUPOPUPSTART = $0006;
  348. {$EXTERNALSYM EVENT_SYSTEM_MENUPOPUPSTART}
  349. EVENT_SYSTEM_MENUPOPUPEND = $0007;
  350. {$EXTERNALSYM EVENT_SYSTEM_MENUPOPUPEND}
  351. //
  352. // EVENT_SYSTEM_CAPTURESTART
  353. // EVENT_SYSTEM_CAPTUREEND
  354. // Sent when a window takes the capture and releases the capture.
  355. //
  356. EVENT_SYSTEM_CAPTURESTART = $0008;
  357. {$EXTERNALSYM EVENT_SYSTEM_CAPTURESTART}
  358. EVENT_SYSTEM_CAPTUREEND = $0009;
  359. {$EXTERNALSYM EVENT_SYSTEM_CAPTUREEND}
  360. //
  361. // EVENT_SYSTEM_MOVESIZESTART
  362. // EVENT_SYSTEM_MOVESIZEEND
  363. // Sent when a window enters and leaves move-size dragging mode.
  364. //
  365. EVENT_SYSTEM_MOVESIZESTART = $000A;
  366. {$EXTERNALSYM EVENT_SYSTEM_MOVESIZESTART}
  367. EVENT_SYSTEM_MOVESIZEEND = $000B;
  368. {$EXTERNALSYM EVENT_SYSTEM_MOVESIZEEND}
  369. //
  370. // EVENT_SYSTEM_CONTEXTHELPSTART
  371. // EVENT_SYSTEM_CONTEXTHELPEND
  372. // Sent when a window enters and leaves context sensitive help mode.
  373. //
  374. EVENT_SYSTEM_CONTEXTHELPSTART = $000C;
  375. {$EXTERNALSYM EVENT_SYSTEM_CONTEXTHELPSTART}
  376. EVENT_SYSTEM_CONTEXTHELPEND = $000D;
  377. {$EXTERNALSYM EVENT_SYSTEM_CONTEXTHELPEND}
  378. //
  379. // EVENT_SYSTEM_DRAGDROPSTART
  380. // EVENT_SYSTEM_DRAGDROPEND
  381. // Sent when a window enters and leaves drag drop mode. Note that it is up
  382. // to apps and OLE to generate this, since the system doesn't know. Like
  383. // EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
  384. //
  385. EVENT_SYSTEM_DRAGDROPSTART = $000E;
  386. {$EXTERNALSYM EVENT_SYSTEM_DRAGDROPSTART}
  387. EVENT_SYSTEM_DRAGDROPEND = $000F;
  388. {$EXTERNALSYM EVENT_SYSTEM_DRAGDROPEND}
  389. //
  390. // EVENT_SYSTEM_DIALOGSTART
  391. // EVENT_SYSTEM_DIALOGEND
  392. // Sent when a dialog comes up and just before it goes away.
  393. //
  394. EVENT_SYSTEM_DIALOGSTART = $0010;
  395. {$EXTERNALSYM EVENT_SYSTEM_DIALOGSTART}
  396. EVENT_SYSTEM_DIALOGEND = $0011;
  397. {$EXTERNALSYM EVENT_SYSTEM_DIALOGEND}
  398. //
  399. // EVENT_SYSTEM_SCROLLINGSTART
  400. // EVENT_SYSTEM_SCROLLINGEND
  401. // Sent when beginning and ending the tracking of a scrollbar in a window,
  402. // and also for scrollbar controls.
  403. //
  404. EVENT_SYSTEM_SCROLLINGSTART = $0012;
  405. {$EXTERNALSYM EVENT_SYSTEM_SCROLLINGSTART}
  406. EVENT_SYSTEM_SCROLLINGEND = $0013;
  407. {$EXTERNALSYM EVENT_SYSTEM_SCROLLINGEND}
  408. //
  409. // EVENT_SYSTEM_SWITCHSTART
  410. // EVENT_SYSTEM_SWITCHEND
  411. // Sent when beginning and ending alt-tab mode with the switch window.
  412. //
  413. EVENT_SYSTEM_SWITCHSTART = $0014;
  414. {$EXTERNALSYM EVENT_SYSTEM_SWITCHSTART}
  415. EVENT_SYSTEM_SWITCHEND = $0015;
  416. {$EXTERNALSYM EVENT_SYSTEM_SWITCHEND}
  417. //
  418. // EVENT_SYSTEM_MINIMIZESTART
  419. // EVENT_SYSTEM_MINIMIZEEND
  420. // Sent when a window minimizes and just before it restores.
  421. //
  422. EVENT_SYSTEM_MINIMIZESTART = $0016;
  423. {$EXTERNALSYM EVENT_SYSTEM_MINIMIZESTART}
  424. EVENT_SYSTEM_MINIMIZEEND = $0017;
  425. {$EXTERNALSYM EVENT_SYSTEM_MINIMIZEEND}
  426. //
  427. // Object events
  428. //
  429. // The system AND apps generate these. The system generates these for
  430. // real windows. Apps generate these for objects within their window which
  431. // act like a separate control, e.g. an item in a list view.
  432. //
  433. // For all events, if you want detailed accessibility information, callers
  434. // should
  435. // * Call AccessibleObjectFromWindow() with the hwnd, idObject parameters
  436. // of the event, and IID_IAccessible as the REFIID, to get back an
  437. // IAccessible* to talk to
  438. // * Initialize and fill in a VARIANT as VT_I4 with lVal the idChild
  439. // parameter of the event.
  440. // * If idChild isn't zero, call get_accChild() in the container to see
  441. // if the child is an object in its own right. If so, you will get
  442. // back an IDispatch* object for the child. You should release the
  443. // parent, and call QueryInterface() on the child object to get its
  444. // IAccessible*. Then you talk directly to the child. Otherwise,
  445. // if get_accChild() returns you nothing, you should continue to
  446. // use the child VARIANT. You will ask the container for the properties
  447. // of the child identified by the VARIANT. In other words, the
  448. // child in this case is accessible but not a full-blown object.
  449. // Like a button on a titlebar which is 'small' and has no children.
  450. //
  451. //
  452. EVENT_OBJECT_CREATE = $8000; // hwnd + ID + idChild is created item
  453. {$EXTERNALSYM EVENT_OBJECT_CREATE}
  454. EVENT_OBJECT_DESTROY = $8001; // hwnd + ID + idChild is destroyed item
  455. {$EXTERNALSYM EVENT_OBJECT_DESTROY}
  456. EVENT_OBJECT_SHOW = $8002; // hwnd + ID + idChild is shown item
  457. {$EXTERNALSYM EVENT_OBJECT_SHOW}
  458. EVENT_OBJECT_HIDE = $8003; // hwnd + ID + idChild is hidden item
  459. {$EXTERNALSYM EVENT_OBJECT_HIDE}
  460. EVENT_OBJECT_REORDER = $8004; // hwnd + ID + idChild is parent of zordering children
  461. {$EXTERNALSYM EVENT_OBJECT_REORDER}
  462. //
  463. // NOTE:
  464. // Minimize the number of notifications!
  465. //
  466. // When you are hiding a parent object, obviously all child objects are no
  467. // longer visible on screen. They still have the same "visible" status,
  468. // but are not truly visible. Hence do not send HIDE notifications for the
  469. // children also. One implies all. The same goes for SHOW.
  470. //
  471. EVENT_OBJECT_FOCUS = $8005; // hwnd + ID + idChild is focused item
  472. {$EXTERNALSYM EVENT_OBJECT_FOCUS}
  473. EVENT_OBJECT_SELECTION = $8006; // hwnd + ID + idChild is selected item (if only one), or idChild is OBJID_WINDOW if complex
  474. {$EXTERNALSYM EVENT_OBJECT_SELECTION}
  475. EVENT_OBJECT_SELECTIONADD = $8007; // hwnd + ID + idChild is item added
  476. {$EXTERNALSYM EVENT_OBJECT_SELECTIONADD}
  477. EVENT_OBJECT_SELECTIONREMOVE = $8008; // hwnd + ID + idChild is item removed
  478. {$EXTERNALSYM EVENT_OBJECT_SELECTIONREMOVE}
  479. EVENT_OBJECT_SELECTIONWITHIN = $8009; // hwnd + ID + idChild is parent of changed selected items
  480. {$EXTERNALSYM EVENT_OBJECT_SELECTIONWITHIN}
  481. //
  482. // NOTES:
  483. // There is only one "focused" child item in a parent. This is the place
  484. // keystrokes are going at a given moment. Hence only send a notification
  485. // about where the NEW focus is going. A NEW item getting the focus already
  486. // implies that the OLD item is losing it.
  487. //
  488. // SELECTION however can be multiple. Hence the different SELECTION
  489. // notifications. Here's when to use each:
  490. //
  491. // (1) Send a SELECTION notification in the simple single selection
  492. // case (like the focus) when the item with the selection is
  493. // merely moving to a different item within a container. hwnd + ID
  494. // is the container control, idChildItem is the new child with the
  495. // selection.
  496. //
  497. // (2) Send a SELECTIONADD notification when a new item has simply been added
  498. // to the selection within a container. This is appropriate when the
  499. // number of newly selected items is very small. hwnd + ID is the
  500. // container control, idChildItem is the new child added to the selection.
  501. //
  502. // (3) Send a SELECTIONREMOVE notification when a new item has simply been
  503. // removed from the selection within a container. This is appropriate
  504. // when the number of newly selected items is very small, just like
  505. // SELECTIONADD. hwnd + ID is the container control, idChildItem is the
  506. // new child removed from the selection.
  507. //
  508. // (4) Send a SELECTIONWITHIN notification when the selected items within a
  509. // control have changed substantially. Rather than propagate a large
  510. // number of changes to reflect removal for some items, addition of
  511. // others, just tell somebody who cares that a lot happened. It will
  512. // be faster an easier for somebody watching to just turn around and
  513. // query the container control what the new bunch of selected items
  514. // are.
  515. //
  516. EVENT_OBJECT_STATECHANGE = $800A; // hwnd + ID + idChild is item w/ state change
  517. {$EXTERNALSYM EVENT_OBJECT_STATECHANGE}
  518. EVENT_OBJECT_LOCATIONCHANGE = $800B; // hwnd + ID + idChild is moved/sized item
  519. {$EXTERNALSYM EVENT_OBJECT_LOCATIONCHANGE}
  520. EVENT_OBJECT_NAMECHANGE = $800C; // hwnd + ID + idChild is item w/ name change
  521. {$EXTERNALSYM EVENT_OBJECT_NAMECHANGE}
  522. EVENT_OBJECT_DESCRIPTIONCHANGE = $800D; // hwnd + ID + idChild is item w/ desc change
  523. {$EXTERNALSYM EVENT_OBJECT_DESCRIPTIONCHANGE}
  524. EVENT_OBJECT_VALUECHANGE = $800E; // hwnd + ID + idChild is item w/ value change
  525. {$EXTERNALSYM EVENT_OBJECT_VALUECHANGE}
  526. EVENT_OBJECT_PARENTCHANGE = $800F; // hwnd + ID + idChild is item w/ new parent
  527. {$EXTERNALSYM EVENT_OBJECT_PARENTCHANGE}
  528. EVENT_OBJECT_HELPCHANGE = $8010; // hwnd + ID + idChild is item w/ help change
  529. {$EXTERNALSYM EVENT_OBJECT_HELPCHANGE}
  530. EVENT_OBJECT_DEFACTIONCHANGE = $8011; // hwnd + ID + idChild is item w/ def action change
  531. {$EXTERNALSYM EVENT_OBJECT_DEFACTIONCHANGE}
  532. EVENT_OBJECT_ACCELERATORCHANGE = $8012; // hwnd + ID + idChild is item w/ keybd accel change
  533. {$EXTERNALSYM EVENT_OBJECT_ACCELERATORCHANGE}
  534. implementation
  535. uses
  536. JwaWinDLLNames;
  537. {$IFDEF DYNAMIC_LINK}
  538. var
  539. _GetGUIThreadInfo: Pointer;
  540. function GetGUIThreadInfo;
  541. begin
  542. GetProcedureAddress(_GetGUIThreadInfo, user32, 'GetGUIThreadInfo');
  543. asm
  544. MOV ESP, EBP
  545. POP EBP
  546. JMP [_GetGUIThreadInfo]
  547. end;
  548. end;
  549. var
  550. _GetWindowModuleFileNameW: Pointer;
  551. function GetWindowModuleFileNameW;
  552. begin
  553. GetProcedureAddress(_GetWindowModuleFileNameW, user32, 'GetWindowModuleFileNameW');
  554. asm
  555. MOV ESP, EBP
  556. POP EBP
  557. JMP [_GetWindowModuleFileNameW]
  558. end;
  559. end;
  560. var
  561. _GetWindowModuleFileNameA: Pointer;
  562. function GetWindowModuleFileNameA;
  563. begin
  564. GetProcedureAddress(_GetWindowModuleFileNameA, user32, 'GetWindowModuleFileNameA');
  565. asm
  566. MOV ESP, EBP
  567. POP EBP
  568. JMP [_GetWindowModuleFileNameA]
  569. end;
  570. end;
  571. var
  572. _GetWindowModuleFileName: Pointer;
  573. function GetWindowModuleFileName;
  574. begin
  575. GetProcedureAddress(_GetWindowModuleFileName, user32, 'GetWindowModuleFileName' + AWSuffix);
  576. asm
  577. MOV ESP, EBP
  578. POP EBP
  579. JMP [_GetWindowModuleFileName]
  580. end;
  581. end;
  582. var
  583. _BlockInput: Pointer;
  584. function BlockInput;
  585. begin
  586. GetProcedureAddress(_BlockInput, user32, 'BlockInput');
  587. asm
  588. MOV ESP, EBP
  589. POP EBP
  590. JMP [_BlockInput]
  591. end;
  592. end;
  593. var
  594. _SendInput: Pointer;
  595. function SendInput;
  596. begin
  597. GetProcedureAddress(_SendInput, user32, 'SendInput');
  598. asm
  599. MOV ESP, EBP
  600. POP EBP
  601. JMP [_SendInput]
  602. end;
  603. end;
  604. var
  605. _NotifyWinEvent: Pointer;
  606. procedure NotifyWinEvent;
  607. begin
  608. GetProcedureAddress(_NotifyWinEvent, user32, 'NotifyWinEvent');
  609. asm
  610. MOV ESP, EBP
  611. POP EBP
  612. JMP [_NotifyWinEvent]
  613. end;
  614. end;
  615. var
  616. _SetWinEventHook: Pointer;
  617. function SetWinEventHook;
  618. begin
  619. GetProcedureAddress(_SetWinEventHook, user32, 'SetWinEventHook');
  620. asm
  621. MOV ESP, EBP
  622. POP EBP
  623. JMP [_SetWinEventHook]
  624. end;
  625. end;
  626. var
  627. _UnhookWinEvent: Pointer;
  628. function UnhookWinEvent;
  629. begin
  630. GetProcedureAddress(_UnhookWinEvent, user32, 'UnhookWinEvent');
  631. asm
  632. MOV ESP, EBP
  633. POP EBP
  634. JMP [_UnhookWinEvent]
  635. end;
  636. end;
  637. {$ELSE}
  638. function GetGUIThreadInfo; external user32 name 'GetGUIThreadInfo';
  639. function GetWindowModuleFileNameW; external user32 name 'GetWindowModuleFileNameW';
  640. function GetWindowModuleFileNameA; external user32 name 'GetWindowModuleFileNameA';
  641. function GetWindowModuleFileName; external user32 name 'GetWindowModuleFileName' + AWSuffix;
  642. function BlockInput; external user32 name 'BlockInput';
  643. function SendInput; external user32 name 'SendInput';
  644. procedure NotifyWinEvent; external user32 name 'NotifyWinEvent';
  645. function SetWinEventHook; external user32 name 'SetWinEventHook';
  646. function UnhookWinEvent; external user32 name 'UnhookWinEvent';
  647. {$ENDIF DYNAMIC_LINK}
  648. end.