Merge pull request #206 from jamesrhurst/autotype-fixes

Make autotype work in more situations
This commit is contained in:
Michael Starke
2014-08-05 11:52:08 +02:00
2 changed files with 7 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ NSString *const kMPWindowTitleKey = @"windowTitle";
NSString *const kMPApplciationNameKey = @"applicationName";
/*
Enabel to activate autotype
Enable to activate autotype
#define MP_AUTOTYPE
*/

View File

@@ -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];