Skip to content

Commit 0a3cc38

Browse files
author
Darin Higgins
committed
Resolved intermittent issue that could occur while scanning through target app controls.
1 parent 3b2a874 commit 0a3cc38

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

Disambiguator/DisambiguatorExt.cs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

Disambiguator/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[assembly: AssemblyConfiguration("")]
88
[assembly: AssemblyCompany("drventure")]
99
[assembly: AssemblyProduct("KeePass Plugin")]
10-
[assembly: AssemblyCopyright("Copyright © 2023 drventure")]
10+
[assembly: AssemblyCopyright("Copyright © 2023-2024 drventure")]
1111
[assembly: AssemblyTrademark("")]
1212
[assembly: AssemblyCulture("")]
1313

@@ -18,6 +18,6 @@
1818
[assembly: Guid("28241D0D-62D3-43A9-9355-B4016AA2F91E")]
1919

2020
// Assembly version information
21-
[assembly: AssemblyVersion("1.0.5.0")]
21+
[assembly: AssemblyVersion("1.0.6.0")]
2222

23-
[assembly: AssemblyFileVersion("1.0.5.0")]
23+
[assembly: AssemblyFileVersion("1.0.6.0")]

Readme.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ Bugs can be reported using the issue tracker, for anything else, a wiki is avail
166166

167167

168168
Changelog
169+
--------
170+
v1.0.6.0
171+
Improved handling of failures when attempting to resolve control details via the MSAA layer.
172+
Even if the ID, Class, or Name can't be determined, if the other elements can, then we can still
173+
use the control for disambiguation.
174+
169175
--------
170176
v1.0.5.0
171177
Corrected problem with CTL tag matching.
905 KB
Binary file not shown.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
:
2-
The Disambiguator:1.0.5
2+
The Disambiguator:1.0.6
33
:

0 commit comments

Comments
 (0)