Send key events to any running macOS application.

Related tags

Security KeySender
Overview

KeySender

An extremely simple micro package that enables you to send key events to any running application.

Install

Add the following to your Package.swift file:

import PackageDescription

let package = Package(
    name: "PackageName",
    dependencies: [
        .package(url: "https://github.com/jordanbaird/KeySender", from: "0.0.1")
    ],
    targets: [
        .target(
            name: "PackageName",
            dependencies: ["KeySender"]
        )
    ]
)

Usage

To create a key sender, call one of its initializers. You can create an instance with multiple key events that will be sent in succession, a single key event, a key and some modifiers, or a string. You then call one of the send(to:) or trySend(to:) methods to send the event to a running application of your choice, or sendGlobally() to send the event to the system.

When sending to an application, as long as it can accept the keys that you send and is currently running, the effect will be the same as if the keys had been entered manually.

When sending globally, the effect will also be the same as if the keys had been entered manually.

let sender = KeySender(key: .c, modifiers: .command)
try sender.send(to: "TextEdit")

let sender = KeySender(string: "Hello")
sender.trySend(to: "TextEdit")

let sender = KeySender(key. space, modifiers: .command)
sender.sendGlobally()

Note: As KeySender is under active development, source stability is not guaranteed between releases.

You might also like...
Safe and easy to use crypto for iOS and macOS

Swift-Sodium Swift-Sodium provides a safe and easy to use interface to perform common cryptographic operations on macOS, iOS, tvOS and watchOS. It lev

Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.

KeychainAccess KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs extremely easy and much mor

Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works.

Valet Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. It’s easy.

Native and encrypted password manager for iOS and macOS.
Native and encrypted password manager for iOS and macOS.

Open Sesame Native and encrypted password manager for iOS and macOS. What is it? OpenSesame is a free and powerful password manager that lets you mana

Partial rewrite of the `plutil` utility on macOS
Partial rewrite of the `plutil` utility on macOS

SwiftPlist Description This tool is a partial rewrite of the plutil utility on macOS. It allows you to view property list (plist) files in any format

Find who executes a target binary inside your MacOS.

whoexec Whoexec is a tool that will monitor every exec call inside MacOS by using the latest Endpoint Security Framework, with this it's able to detec

A super simple tool for macOS Swift developers to check validity of a Gumroad-issued software license keys

Gumroad License Validator Overview A super simple tool for macOS Swift developers to check validity of a Gumroad-issued software license keys Requirem

A wrapper to make it really easy to deal with iOS, macOS, watchOS and Linux Keychain and store your user's credentials securely.

A wrapper (written only in Swift) to make it really easy to deal with iOS, macOS, watchOS and Linux Keychain and store your user's credentials securely.

RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

AppKitFocusOverlay - Add hotkey(s) to display the key focus path for any window in your (running) AppKit application
AppKitFocusOverlay - Add hotkey(s) to display the key focus path for any window in your (running) AppKit application

AppKitFocusOverlay A simple package for displaying the current focus target path

Send email to any SMTP server like a boss, in Swift and cross-platform
Send email to any SMTP server like a boss, in Swift and cross-platform

Hedwig is a Swift package which supplies a set of high level APIs to allow you sending email to an SMTP server easily. If you are planning to send ema

Tool for running macOS guest virtual machines in macOS 12 host or higher on M1 arm64 Macs

macosvm macosvm is a command line tool which allows creating and running of virtual machines on macOS 12 (Monterey) using the new Virtualization frame

Pic-To-Send iOS Application Repository
Pic-To-Send iOS Application Repository

PicToSend_G03_iOS_Project Pic-To-Send iOS Application Repository Application User Interface How to run the application: Pre-requisite: Xcode 13 or lat

This is a simple chat application made in Swift using send and receive interface.

Flash Chat πŸ’πŸ½β€β™‚οΈ Overview This is a simple chat application made in Swift using send and receive interface. βš™οΈ How it works The user needs to first

Mac menu bar tool to view the architecture of the running application
Mac menu bar tool to view the architecture of the running application

Silicon Info About Silicon Info is a tiny menu bar application allows the user to quickly view the architecture of the currently running application.

TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.

Please star this github repository to stay up to date. TraceLog Introduction TraceLog is a highly configurable, flexible, portable, and simple to use

3D Shoot'em Up written with OpenGL ES 1.1/2.0 running on iOS, Android, Windows and MacOS X.
3D Shoot'em Up written with OpenGL ES 1.1/2.0 running on iOS, Android, Windows and MacOS X.

SHMUP This is the source code of "SHMUP" a 3D Shoot 'em up that I wrote in 2009. It is very inspired of Treasure Ikaruga, the engine runs on iOS, Andr

Swift sample app for running privileged operations on macOS using a helper tool
Swift sample app for running privileged operations on macOS using a helper tool

SwiftAuthorizationSample demonstrates how to run privileged operations on macOS using a helper tool managed by launchd. This sample was created with t

Comments
  • Does not work for me

    Does not work for me

    Hey @jordanbaird, your package is exactly what I was looking for. Thanks a lot. But unfortunately it doesn't work for me. I created a minimal console application to give it a try. I expect this line to open TextEdit and put the string "Hello".

    try KeySender(for: "Hello World").openApplicationAndSend("TextEdit")

    But unfortunately only TextEdit opens but not text appears. I already grant accessibility permissions for my console application. Do you have any idea what else could be missing?

    EDIT 1: I found out that the behaviour described is related to that: https://stackoverflow.com/q/63094246. The conclusion is that adding a sleep after the line above helps. Does anyone knows a better solution?

    Cheers mahush

    opened by mahush 1
Releases(0.0.5)
Owner
Jordan Baird
Jordan Baird
RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

Kitura 122 Dec 16, 2022
Send email to any SMTP server like a boss, in Swift and cross-platform

Hedwig is a Swift package which supplies a set of high level APIs to allow you sending email to an SMTP server easily. If you are planning to send ema

Wei Wang 1.1k Jan 3, 2023
A key value store for storing per-developer environment and application keys

A key value store for enviroment and application keys. Its good security practice to keep production keys out of developer hands. CocoaPods-keys makes

Orta Therox 1.5k Dec 20, 2022
To Practice UINavigationController, transition, ViewController Life Cycle, send data to different page, asset catalogs

LED Board Check Point ! StackView μ—¬λŸ¬κ°œμ˜ view λ₯Ό set 으둜 λ§Œλ“€μ–΄ μ£ΌλŠ” μ—­ν™œμ„ 함 μΌμ •ν•œ κ·œμΉ™μ— λ”°λΌμ„œ stack view μ•ˆμ— μ›€μ§μ΄λŠ”κ²ƒμž„ 이미지 λ„£κΈ° ν”„λ‘œμ νŠΈ 내에 Assets 폴더 내에 Image Set 을 μΆ”κ°€ν•˜μ—¬ 1x, 2x

Jacob Ko 0 Dec 5, 2021
Virgil Core SDK allows developers to get up and running with Virgil Cards Service API quickly and add end-to-end security to their new or existing digital solutions to become HIPAA and GDPR compliant and more.

Virgil Core SDK Objective-C/Swift Introduction | SDK Features | Installation | Configure SDK | Usage Examples | Docs | Support Introduction Virgil Sec

Virgil Security, Inc. 27 Jul 26, 2022
A really simple key-value wrapper for keychain.

PlainKeychain A really simple key-value wrapper for keychain. Features βœ… Key-value pairs using kSecClassGenericPassword. ❌ Internet passwords (kSecCla

Benjamin Barnard 0 Nov 27, 2021
Swift RSA Key Loader

Swift RSA Key Loader Requirements iOS 9.0+ Installation See the subsections below for details about the different installation methods. Swift Package

Dmytrii Golovanov 1 Jun 13, 2022
Swift Key Derivation

KeyDerivation This package implements key derivation system based of 5 levels: m / purpose' / coin_type' / account' / role / index As described in CIP

Arnot 1 Mar 5, 2022
Framework for biometric authentication (via TouchID) in your application

Features Requirements Communication Installation Usage Intro Biometric authentication availability Feature enabled/disabled for biometric authenticati

Igor Vasilenko 29 Sep 16, 2022
Pass for iOS - an iOS client compatible with Pass command line application.

Pass is an iOS client compatible with ZX2C4's Pass command line application. It is a password manager using GPG for encryption and Git for version control.

Mingshen Sun 1.3k Dec 26, 2022