-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from aivanovski/feature/add-keyboard-emulation…
…-via-apple-script Add keyboard emulation via AppleScript
- Loading branch information
Showing
7 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/github/ai/autokpass/domain/autotype/OsaScriptAutotypeExecutor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.ai.autokpass.domain.autotype | ||
|
||
import com.github.ai.autokpass.model.AutotypeSequence | ||
import com.github.ai.autokpass.model.AutotypeSequenceItem | ||
import com.github.ai.autokpass.presentation.process.ProcessExecutor | ||
|
||
class OsaScriptAutotypeExecutor( | ||
private val processExecutor: ProcessExecutor, | ||
private val threadThrottler: ThreadThrottler | ||
) : AutotypeExecutor { | ||
|
||
override fun execute(sequence: AutotypeSequence) { | ||
sequence.items.forEach { item -> | ||
when (item) { | ||
is AutotypeSequenceItem.Enter -> { | ||
processExecutor.executeWithBash( | ||
"echo \"tell application \\\"System Events\\\" to key code 36\" | osascript" | ||
) | ||
} | ||
is AutotypeSequenceItem.Tab -> { | ||
processExecutor.executeWithBash( | ||
"echo \"tell application \\\"System Events\\\" to key code 48\" | osascript" | ||
) | ||
} | ||
is AutotypeSequenceItem.Text -> { | ||
processExecutor.executeWithBash( | ||
"echo \"tell application \\\"System Events\\\" to keystroke \\\"${item.text}\\\"\" | osascript" | ||
) | ||
} | ||
is AutotypeSequenceItem.Delay -> { | ||
threadThrottler.sleep(item.millis) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters