@@ -93,7 +93,7 @@ public override bool Initialize(IPluginHost host)
9393
9494
9595 /// <summary>
96- /// Provide our menu item to Keepass
96+ /// Provide our menu item to KeePass
9797 /// </summary>
9898 /// <param name="t"></param>
9999 /// <returns></returns>
@@ -281,11 +281,45 @@ private List<UIElement> TraverseControlTree(IntPtr targetWindowHandle, int depth
281281 if ( uiaObject != null )
282282 {
283283 //add the root control element to the list
284+ string ID = string . Empty ;
285+ string Name = ID ;
286+ string Class = ID ;
287+
288+ //attempt each of these resolutions, but if they fail, just ignore
289+ var msg = "!Failed to resolve!" ;
290+ try
291+ {
292+ ID = uiaObject . GetCurrentPropertyValue ( AutomationElement . AutomationIdProperty ) as string ;
293+ }
294+ catch ( Exception ex )
295+ {
296+ Debug ( "Unable to resolve AutomationID: " + ex . ToString ( ) ) ;
297+ ID = msg ;
298+ } ;
299+ try
300+ {
301+ Name = uiaObject . GetCurrentPropertyValue ( AutomationElement . NameProperty ) as string ;
302+ }
303+ catch ( Exception ex )
304+ {
305+ Debug ( "Unable to resolve Name: " + ex . ToString ( ) ) ;
306+ Name = msg ;
307+ } ;
308+ try
309+ {
310+ Class = uiaObject . GetCurrentPropertyValue ( AutomationElement . ClassNameProperty ) as string ;
311+ }
312+ catch ( Exception ex )
313+ {
314+ Debug ( "Unable to resolve ClassName: " + ex . ToString ( ) ) ;
315+ Class = msg ;
316+ } ;
317+
284318 var uiElement = new UIElement ( )
285319 {
286- ID = uiaObject . GetCurrentPropertyValue ( AutomationElement . AutomationIdProperty ) as string ,
287- Name = uiaObject . GetCurrentPropertyValue ( AutomationElement . NameProperty ) as string ,
288- Class = uiaObject . GetCurrentPropertyValue ( AutomationElement . ClassNameProperty ) as string ,
320+ ID = ID ,
321+ Name = Name ,
322+ Class = Class ,
289323 } ;
290324 uiElements . Add ( uiElement ) ;
291325 var indent = " " ;
@@ -545,7 +579,7 @@ private bool MatchOnControlTree(List<UIElement> uiElements, string ctlParam)
545579
546580
547581 /// <summary>
548- /// used to cache and precompute regexes
582+ /// used to cache and precompute regex's
549583 /// </summary>
550584 private static Dictionary < string , Regex > _regexes = new Dictionary < string , Regex > ( ) ;
551585
@@ -699,7 +733,7 @@ private string getExecutableFromHwnd(IntPtr hWnd)
699733 /// </summary>
700734 public override void Terminate ( )
701735 {
702- Debug ( "Keepass terminating" ) ;
736+ Debug ( "KeePass terminating" ) ;
703737
704738 AutoType . SequenceQuery -= AutoType_SequenceQuery ;
705739 AutoType . SequenceQueriesBegin -= AutoType_SequenceQueriesBegin ;
0 commit comments