diff --git a/MacPass/MPAutotypeCommand.m b/MacPass/MPAutotypeCommand.m index 738bf537..b201ffb8 100644 --- a/MacPass/MPAutotypeCommand.m +++ b/MacPass/MPAutotypeCommand.m @@ -290,7 +290,7 @@ static CGKeyCode kMPFunctionKeyCodes[] = { kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F } // TODO: add {APPLICATION } /* Delay */ - NSString *delayPattern = [[NSString alloc] initWithFormat:@"\\{(%@|%@|)[ |=]+([0-9])+\\}", + NSString *delayPattern = [[NSString alloc] initWithFormat:@"\\{(%@|%@)[ |=]+([0-9]+)\\}", kKPKAutotypeDelay, kKPKAutotypeVirtualKey/*, kKPKAutotypeVirtualExtendedKey, diff --git a/MacPass/MPAutotypeDelay.h b/MacPass/MPAutotypeDelay.h index 2dd74c44..3ebc749e 100644 --- a/MacPass/MPAutotypeDelay.h +++ b/MacPass/MPAutotypeDelay.h @@ -9,7 +9,13 @@ #import "MPAutotypeCommand.h" @interface MPAutotypeDelay : MPAutotypeCommand - +/** + * Creates an DelayCommand that delays the execution for n milliseconds + * + * @param delay Delay in milliseconds + * + * @return <#return value description#> + */ - (instancetype)initWithDelay:(NSUInteger)delay; @end diff --git a/MacPass/MPAutotypeDelay.m b/MacPass/MPAutotypeDelay.m index 243dd734..f25575f3 100644 --- a/MacPass/MPAutotypeDelay.m +++ b/MacPass/MPAutotypeDelay.m @@ -22,7 +22,7 @@ } - (NSString *)description { - return [[NSString alloc] initWithFormat:@"%@ delay: %ld ms", [self class], _delay]; + return [[NSString alloc] initWithFormat:@"%@ delay: %ld ms", self.class, _delay]; } - (instancetype)initWithDelay:(NSUInteger)delay { @@ -35,7 +35,8 @@ } - (void)execute { - usleep((useconds_t)(_delay*NSEC_PER_MSEC)); + /* milliseconds * 10000 = microseconds */ + usleep((useconds_t)(_delay*1000)); } @end diff --git a/MacPassTests/MPTestAutotype.m b/MacPassTests/MPTestAutotype.m index a8ba3ac4..e1e621aa 100644 --- a/MacPassTests/MPTestAutotype.m +++ b/MacPassTests/MPTestAutotype.m @@ -233,4 +233,5 @@ } + @end