Used to programmatically control the mouse & keyboard. A library for manipulating macOS with Swift.
This repository is implemented with reference to pyautogui.
SwiftAutoGUI is available through Swift Package Manager.
Package.swift add the following:
dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/NakaokaRei/SwiftAutoGUI", branch: "master") ], targets: [ .target( name: "MyProject", dependencies: [..., "SwiftAutoGUI"] ) ... ]
Keyboard and Mouse Control
See Keycode.swift for supported keys. If it is not a US keyboard, This may not work properly.
import SwiftAutoGUI // Send ctrl + ← SwiftAutoGUI.sendKeyShortcut([.control, .leftArrow]) // Send sound up SwiftAutoGUI.keyDown(.soundUp) SwiftAutoGUI.keyUp(.soundUp) // Move mouse by dx, dy from the current location SwiftAutoGUI.moveMouse(dx: 10, dy: 10) // Click where the mouse is located SwiftAutoGUI.leftClick()
MIT license. See the LICENSE file for details.