From 8a29a94f8f48ee6f314e47c8ec90c47d2de32359 Mon Sep 17 00:00:00 2001 From: James Hurst Date: Mon, 4 Aug 2014 16:33:29 -0400 Subject: [PATCH] Make autotype work in more situations The entry title will first be searched for within the window title. If the window title does not contain the entry title, then the window title will be searched for within the entry title. --- MacPass/MPAutotypeDaemon.m | 2 +- MacPass/MPDocument+Autotype.m | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MacPass/MPAutotypeDaemon.m b/MacPass/MPAutotypeDaemon.m index b0a0839f..4c8bd0ac 100644 --- a/MacPass/MPAutotypeDaemon.m +++ b/MacPass/MPAutotypeDaemon.m @@ -27,7 +27,7 @@ NSString *const kMPWindowTitleKey = @"windowTitle"; NSString *const kMPApplciationNameKey = @"applicationName"; /* - Enabel to activate autotype + Enable to activate autotype #define MP_AUTOTYPE */ diff --git a/MacPass/MPDocument+Autotype.m b/MacPass/MPDocument+Autotype.m index 6d711986..482f878c 100644 --- a/MacPass/MPDocument+Autotype.m +++ b/MacPass/MPDocument+Autotype.m @@ -37,8 +37,12 @@ NSArray *autotypeEntries = [self.root autotypeableChildEntries]; NSMutableArray *contexts = [[NSMutableArray alloc] initWithCapacity:MAX(1,ceil([autotypeEntries count] / 4.0))]; for(KPKEntry *entry in autotypeEntries) { - /* Test for title */ - NSRange titleRange = [entry.title rangeOfString:windowTitle options:NSCaseInsensitiveSearch]; + /* Test for entry title in window title */ + NSRange titleRange = [windowTitle rangeOfString:entry.title options:NSCaseInsensitiveSearch]; + /* Test for window title in entry title */ + if (titleRange.location == NSNotFound || titleRange.length == 0) { + titleRange = [entry.title rangeOfString:windowTitle options:NSCaseInsensitiveSearch]; + } MPAutotypeContext *context; if(titleRange.location != NSNotFound && titleRange.length != 0) { context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:entry.autotype.defaultKeystrokeSequence];