Skip to content

Instantly share code, notes, and snippets.

@DanielDe
Created February 14, 2020 00:27
Show Gist options
  • Save DanielDe/6873a83499998461403a038f88986d4a to your computer and use it in GitHub Desktop.
Save DanielDe/6873a83499998461403a038f88986d4a to your computer and use it in GitHub Desktop.
import Cocoa
import SwiftUI
import AppKit
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var window: NSWindow!
func applicationDidFinishLaunching(_ aNotification: Notification) {
var axUIElement: AXUIElement? = nil
let copyElementResponse = AXUIElementCopyElementAtPosition(
AXUIElementCreateSystemWide(),
Float(NSScreen.screens.first!.frame.size.width + NSScreen.screens.last!.frame.size.width / 2),
Float(NSScreen.screens.last!.frame.size.height / 2),
&axUIElement
)
print("response: \(copyElementResponse)")
print("element: \(axUIElement)")
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment