mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 14:02:28 +00:00
{DELAY} now get corret values assinged
This commit is contained in:
@@ -166,24 +166,47 @@
|
|||||||
|
|
||||||
+ (void)appendCommandForString:(NSString *)commandString toCommands:(NSMutableArray *)commands activeModifer:(CGEventFlags)flags {
|
+ (void)appendCommandForString:(NSString *)commandString toCommands:(NSMutableArray *)commands activeModifer:(CGEventFlags)flags {
|
||||||
if(nil == commandString) {
|
if(nil == commandString) {
|
||||||
return;
|
return; // Nothing to parse
|
||||||
}
|
}
|
||||||
/* TODO: Test for special Commands */
|
/* Simple Special Press */
|
||||||
/* TODO: fall back to paste if nothing matches */
|
|
||||||
|
|
||||||
NSString *delayPrefix = [[NSString alloc] initWithFormat:@"{%@", kKPKAutotypeDelay];
|
|
||||||
NSNumber *keyCodeNumber = [self keypressCommands][commandString];
|
NSNumber *keyCodeNumber = [self keypressCommands][commandString];
|
||||||
|
|
||||||
if(nil != keyCodeNumber) {
|
if(nil != keyCodeNumber) {
|
||||||
CGKeyCode keyCode = [keyCodeNumber keyCodeValue];
|
CGKeyCode keyCode = [keyCodeNumber keyCodeValue];
|
||||||
[commands addObject:[[MPAutotypeKeyPress alloc] initWithModifierMask:flags keyCode:keyCode]];
|
[commands addObject:[[MPAutotypeKeyPress alloc] initWithModifierMask:flags keyCode:keyCode]];
|
||||||
|
return; // Done
|
||||||
}
|
}
|
||||||
else if([kKPKAutotypeClearField isEqualToString:commandString]) {
|
/* Clearfield */
|
||||||
|
if([kKPKAutotypeClearField isEqualToString:commandString]) {
|
||||||
[commands addObject:[[MPAutotypeClear alloc] init]];
|
[commands addObject:[[MPAutotypeClear alloc] init]];
|
||||||
|
return; // Done
|
||||||
}
|
}
|
||||||
else if([commandString hasPrefix:delayPrefix]){
|
// TODO: add {APPLICATION <appname>}
|
||||||
[commands addObject:[[MPAutotypeDelay alloc] initWithDelay:5]];
|
/* Delay */
|
||||||
/* TODO: find the delay */
|
NSString *delayPattern = [[NSString alloc] initWithFormat:@"\\{(%@|%@|)[:|=]+([0-9])+\\}",
|
||||||
|
kKPKAutotypeDelay,
|
||||||
|
kKPKAutotypeVirtualKey/*,
|
||||||
|
kKPKAutotypeVirtualExtendedKey,
|
||||||
|
kKPKAutotypeVirtualNonExtendedKey*/];
|
||||||
|
NSRegularExpression *delayRegExp = [[NSRegularExpression alloc] initWithPattern:delayPattern options:NSRegularExpressionCaseInsensitive error:0];
|
||||||
|
NSAssert(delayRegExp, @"Regex for delay should work!");
|
||||||
|
NSTextCheckingResult *result = [delayRegExp firstMatchInString:commandString options:0 range:NSMakeRange(0, [commandString length])];
|
||||||
|
if(result && (result.numberOfRanges == 3)) {
|
||||||
|
NSString *command = [commandString substringWithRange:[result rangeAtIndex:1]];
|
||||||
|
NSString *valueString = [commandString substringWithRange:[result rangeAtIndex:2]];
|
||||||
|
NSScanner *numberScanner = [[NSScanner alloc] initWithString:valueString];
|
||||||
|
NSInteger value;
|
||||||
|
if([numberScanner scanInteger:&value]) {
|
||||||
|
if([kKPKAutotypeDelay isEqualToString:command]) {
|
||||||
|
[commands addObject:[[MPAutotypeDelay alloc] initWithDelay:value]];
|
||||||
|
return; // Done
|
||||||
|
}
|
||||||
|
else if([kKPKAutotypeVirtualKey isEqualToString:command]) {
|
||||||
|
// TODO add key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSLog(@"Unable to determine delay!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[self appendPasteCommandForContent:commandString toCommands:commands];
|
[self appendPasteCommandForContent:commandString toCommands:commands];
|
||||||
|
|||||||
@@ -56,6 +56,9 @@
|
|||||||
XCTAssert([commands[2] isKindOfClass:[MPAutotypePaste class]]);
|
XCTAssert([commands[2] isKindOfClass:[MPAutotypePaste class]]);
|
||||||
XCTAssert([commands[3] isKindOfClass:[MPAutotypeKeyPress class]]);
|
XCTAssert([commands[3] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||||
|
|
||||||
|
context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"{DELAY=5}{VKEY-NX 1}{VKEY-EX 200}{DELAY 5}{VKEY 300}"];
|
||||||
|
commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
|
|
||||||
context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"];
|
context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"];
|
||||||
commands = [MPAutotypeCommand commandsForContext:context];
|
commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user