Skip to content

Commit

Permalink
fix: check file exists before activating application
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
socsieng committed Jan 4, 2021
1 parent 5019461 commit 94cda37
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/SendKeysLib/SendKeysCli.swift
Expand Up @@ -34,14 +34,6 @@ public struct SendKeysCli: ParsableCommand {
fputs("WARNING: Accessibility preferences must be enabled to use this tool. If running from the terminal, make sure that your terminal app has accessibility permissiions enabled.\n\n", stderr)
}

if !(applicationName ?? "").isEmpty {
try AppActivator(appName: applicationName!).activate()
}

if (initialDelay > 0) {
Sleeper.sleep(seconds: initialDelay)
}

let commandProcessor = CommandsProcessor(defaultPause: delay)
var commandString: String?

Expand All @@ -55,6 +47,14 @@ public struct SendKeysCli: ParsableCommand {
commandString = characters
}

if !(applicationName ?? "").isEmpty {
try AppActivator(appName: applicationName!).activate()
}

if (initialDelay > 0) {
Sleeper.sleep(seconds: initialDelay)
}

if !(commandString ?? "").isEmpty {
commandProcessor.process(commandString!)
} else if !isTty() {
Expand Down

0 comments on commit 94cda37

Please sign in to comment.