Files
MacPass/MacPass/MPAutotypeKeyPress.m
2014-02-11 20:58:27 +01:00

32 lines
683 B
Objective-C

//
// MPAutotypeSpecialKey.m
// MacPass
//
// Created by Michael Starke on 24/11/13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPAutotypeKeyPress.h"
#import "MPKeyMapper.h"
@implementation MPAutotypeKeyPress
- (void)execute {
if(![self isValid]) {
return; // no valid command. Stop.
}
CGKeyCode mappedKey = [self _transformKeyCode];
[self sendPressKey:mappedKey modifierFlags:self.modifierMask];
}
- (BOOL)isValid {
return ([self _transformKeyCode] != kMPUnknownKeyCode);
}
- (CGKeyCode)_transformKeyCode {
NSString *key = [MPKeyMapper stringForKey:self.keyCode];
return [MPKeyMapper keyCodeForCharacter:key];
}
@end