Thread: [Mwinapi-commits] SF.net SVN: mwinapi:[122] trunk/ManagedWinapi/Accessibility/ AccessibleObjectList
Status: Beta
Brought to you by:
schierlm
From: <zi...@us...> - 2014-11-25 17:35:40
|
Revision: 122 http://sourceforge.net/p/mwinapi/code/122 Author: ziewer Date: 2014-11-25 17:35:37 +0000 (Tue, 25 Nov 2014) Log Message: ----------- Improved AccessibleEventListener.GetAccessibleObject(): Return parent or window on failure IAccessible implementation of object and/or child is missing. This avoids exceptions for HTML content in Internet Explorer Modified Paths: -------------- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs Modified: trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs =================================================================== --- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2014-11-25 15:49:44 UTC (rev 121) +++ trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2014-11-25 17:35:37 UTC (rev 122) @@ -161,6 +161,18 @@ IAccessible iacc; object child; uint result = AccessibleObjectFromEvent(e.HWnd, e.ObjectID, e.ChildID, out iacc, out child); + + // Note: AccessibleObjectFromEvent() sometimes fails due to missing IAccessible implementation of object and/or child + // This often happens for HTML content in Internet Explorer (e.g. for any <DIV> w/o 'role' attribute set). + // Try again without using ChildID and/or ObjectID, + // i.e. ChildID==0 will return the parent object; ObjectID==0 will return the parent window + if (result != 0 && e.ChildID != 0) + // second chance: try to receive object instead of child + result = AccessibleObjectFromEvent(e.HWnd, e.ObjectID, 0, out iacc, out child); + if (result != 0) + // third chance: try to receive window instead of object or child + result = AccessibleObjectFromEvent(e.HWnd, 0, 0, out iacc, out child); + if (result != 0) throw new Exception("AccessibleObjectFromPoint returned " + result); return new SystemAccessibleObject(iacc, (int)child); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sch...@us...> - 2015-12-08 22:10:08
|
Revision: 131 http://sourceforge.net/p/mwinapi/code/131 Author: schierlm Date: 2015-12-08 22:10:07 +0000 (Tue, 08 Dec 2015) Log Message: ----------- added property 'HookFlags' to 'AccessibleEventListener' % pushed from GitHub % Author: fk <enoon1 at arcor.de> % Date: Fri Dec 4 12:08:31 2015 +0100 Modified Paths: -------------- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs Modified: trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs =================================================================== --- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2015-07-07 15:14:52 UTC (rev 130) +++ trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2015-12-08 22:10:07 UTC (rev 131) @@ -27,6 +27,7 @@ /// <summary> /// Listens to events from the Windows accessibility system. These events are useful /// if you want to write a screenreader or similar program. + /// For more information search the MSDN-documentation for the keyword 'WinEvents'. /// </summary> public class AccessibleEventListener : Component { @@ -43,6 +44,7 @@ private GCHandle gch; private UInt32 processId = 0; private UInt32 threadId = 0; + private AccessibleEventFlags hookFlags = AccessibleEventFlags.OUTOFCONTEXT; /// <summary> /// Initializes a new instance of this class with the specified container. @@ -119,6 +121,30 @@ set { threadId = value; updateListener(); } } + /// <summary> + /// The location of the hook function and of the events to be skipped. + /// </summary> + public AccessibleEventFlags HookFlags + { + get { return hookFlags; } + set + { + if (!( + value == AccessibleEventFlags.INCONTEXT || + value == AccessibleEventFlags.OUTOFCONTEXT || + value == (AccessibleEventFlags.OUTOFCONTEXT | AccessibleEventFlags.SKIPOWNPROCESS) || + value == (AccessibleEventFlags.OUTOFCONTEXT | AccessibleEventFlags.SKIPOWNTHREAD) || + value == (AccessibleEventFlags.INCONTEXT | AccessibleEventFlags.SKIPOWNPROCESS) || + value == (AccessibleEventFlags.INCONTEXT | AccessibleEventFlags.SKIPOWNTHREAD) + )) + { + throw new ArgumentException("Invalid flags."); + } + hookFlags = value; + updateListener(); + } + } + private void updateListener() { if (handle != IntPtr.Zero) @@ -128,7 +154,7 @@ } if (enabled) { - handle = SetWinEventHook(min, max, IntPtr.Zero, internalDelegate, processId, threadId, 0); + handle = SetWinEventHook(min, max, IntPtr.Zero, internalDelegate, processId, threadId, (uint)hookFlags); } } @@ -292,7 +318,33 @@ } } + /// <summary> + /// This enumeration lists Flag values that specify the location of the hook function and of the events to be skipped. + /// </summary> + [Flags] + public enum AccessibleEventFlags + { + + /// <summary> + /// The callback function is not mapped into the address space of the process that generates the event. + /// </summary> + OUTOFCONTEXT = 0x0000, + /// <summary> + /// Prevents this instance of the hook from receiving the events that are generated by the thread that is registering this hook. + /// </summary> + SKIPOWNTHREAD = 0x0001, + /// <summary> + /// Prevents this instance of the hook from receiving the events that are generated by threads in this process. This flag does not prevent threads from generating events. + /// </summary> + SKIPOWNPROCESS = 0x0002, + /// <summary> + /// The DLL that contains the callback function is mapped into the address space of the process that generates the event. + /// </summary> + INCONTEXT = 0x0004 + } + + /// <summary> /// This enumeration lists known accessible event types. /// </summary> public enum AccessibleEventType This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sch...@us...> - 2015-12-08 22:10:16
|
Revision: 132 http://sourceforge.net/p/mwinapi/code/132 Author: schierlm Date: 2015-12-08 22:10:13 +0000 (Tue, 08 Dec 2015) Log Message: ----------- removed INCONTEXT from AccessibleEventFlags because this mode was not needed and not tested % pushed from GitHub % Author: fk <enoon1 at arcor.de> % Date: Tue Dec 8 11:22:13 2015 +0100 Modified Paths: -------------- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs Modified: trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs =================================================================== --- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2015-12-08 22:10:07 UTC (rev 131) +++ trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2015-12-08 22:10:13 UTC (rev 132) @@ -130,12 +130,9 @@ set { if (!( - value == AccessibleEventFlags.INCONTEXT || value == AccessibleEventFlags.OUTOFCONTEXT || value == (AccessibleEventFlags.OUTOFCONTEXT | AccessibleEventFlags.SKIPOWNPROCESS) || - value == (AccessibleEventFlags.OUTOFCONTEXT | AccessibleEventFlags.SKIPOWNTHREAD) || - value == (AccessibleEventFlags.INCONTEXT | AccessibleEventFlags.SKIPOWNPROCESS) || - value == (AccessibleEventFlags.INCONTEXT | AccessibleEventFlags.SKIPOWNTHREAD) + value == (AccessibleEventFlags.OUTOFCONTEXT | AccessibleEventFlags.SKIPOWNTHREAD) )) { throw new ArgumentException("Invalid flags."); @@ -337,11 +334,7 @@ /// <summary> /// Prevents this instance of the hook from receiving the events that are generated by threads in this process. This flag does not prevent threads from generating events. /// </summary> - SKIPOWNPROCESS = 0x0002, - /// <summary> - /// The DLL that contains the callback function is mapped into the address space of the process that generates the event. - /// </summary> - INCONTEXT = 0x0004 + SKIPOWNPROCESS = 0x0002 } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |