Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/SendKeysLib/KeyPresser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public class KeyPresser {
let keyDownEvent = try! createKeyEvent(key: key, modifiers: modifiers, keyDown: true)

if self.application == nil {
keyDownEvent?.post(tap: CGEventTapLocation.cghidEventTap)
keyDownEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
} else {
if #available(OSX 10.11, *) {
keyDownEvent?.postToPid(self.application!.processIdentifier)
} else {
keyDownEvent?.post(tap: CGEventTapLocation.cghidEventTap)
keyDownEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
}
}

Expand All @@ -37,12 +37,12 @@ public class KeyPresser {
let keyUpEvent = try! createKeyEvent(key: key, modifiers: modifiers, keyDown: false)

if self.application == nil {
keyUpEvent?.post(tap: CGEventTapLocation.cghidEventTap)
keyUpEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
} else {
if #available(OSX 10.11, *) {
keyUpEvent?.postToPid(self.application!.processIdentifier)
} else {
keyUpEvent?.post(tap: CGEventTapLocation.cghidEventTap)
keyUpEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
}
}

Expand All @@ -54,12 +54,12 @@ public class KeyPresser {
key: key, modifiers: modifiers, keyDown: false, parentEventSource: CGEventSource(event: event))

if self.application == nil {
keyUpEvent?.post(tap: CGEventTapLocation.cghidEventTap)
keyUpEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
} else {
if #available(OSX 10.11, *) {
keyUpEvent?.postToPid(self.application!.processIdentifier)
} else {
keyUpEvent?.post(tap: CGEventTapLocation.cghidEventTap)
keyUpEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
}
}

Expand Down
16 changes: 8 additions & 8 deletions Sources/SendKeysLib/MouseController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ class MouseController {
mouseEventSource: nil, mouseType: downMouseType, mouseCursorPosition: resolvedLocation, mouseButton: button)
downEvent?.setIntegerValueField(.mouseEventClickState, value: Int64(clickCount))
downEvent?.flags = flags
downEvent?.post(tap: CGEventTapLocation.cghidEventTap)
downEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
let eventSource = CGEventSource(event: downEvent)

let upEvent = CGEvent(
mouseEventSource: eventSource, mouseType: upMouseType, mouseCursorPosition: resolvedLocation,
mouseButton: button)
upEvent?.post(tap: CGEventTapLocation.cghidEventTap)
upEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
}

func down(_ location: CGPoint?, button: CGMouseButton, flags: CGEventFlags) {
Expand All @@ -83,7 +83,7 @@ class MouseController {
let downEvent = CGEvent(
mouseEventSource: nil, mouseType: downMouseType, mouseCursorPosition: resolvedLocation, mouseButton: button)
downEvent?.flags = flags
downEvent?.post(tap: CGEventTapLocation.cghidEventTap)
downEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)

downButtons.insert(button)
}
Expand All @@ -95,7 +95,7 @@ class MouseController {
let upEvent = CGEvent(
mouseEventSource: nil, mouseType: upMouseType, mouseCursorPosition: resolvedLocation,
mouseButton: button)
upEvent?.post(tap: CGEventTapLocation.cghidEventTap)
upEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
downButtons.remove(button)
}

Expand All @@ -118,7 +118,7 @@ class MouseController {
mouseEventSource: nil, mouseType: downMouseType, mouseCursorPosition: resolvedStart, mouseButton: button
)
downEvent?.flags = flags
downEvent?.post(tap: CGEventTapLocation.cghidEventTap)
downEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
eventSource = CGEventSource(event: downEvent)
}

Expand All @@ -127,7 +127,7 @@ class MouseController {
if !downButtons.contains(button) {
let upEvent = CGEvent(
mouseEventSource: eventSource, mouseType: upMouseType, mouseCursorPosition: end, mouseButton: button)
upEvent?.post(tap: CGEventTapLocation.cghidEventTap)
upEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ class MouseController {
event?.setIntegerValueField(field, value: Int64(amount * -1))
event?.flags = flags

event?.post(tap: CGEventTapLocation.cghidEventTap)
event?.post(tap: CGEventTapLocation.cgSessionEventTap)
} else {
fatalError("Scrolling is only available on 10.13 or later\n")
}
Expand All @@ -207,7 +207,7 @@ class MouseController {
mouseEventSource: eventSource, mouseType: moveType, mouseCursorPosition: location,
mouseButton: button ?? CGMouseButton.left)
moveEvent?.flags = flags
moveEvent?.post(tap: CGEventTapLocation.cghidEventTap)
moveEvent?.post(tap: CGEventTapLocation.cgSessionEventTap)
}

private func getEventType(_ mouseType: mouseEventType, _ button: CGMouseButton? = nil) -> CGEventType {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SendKeysLib/MousePosition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class MousePosition: ParsableCommand {

guard
let eventTap = CGEvent.tapCreate(
tap: .cghidEventTap, place: .tailAppendEventTap, options: .defaultTap,
tap: .cgSessionEventTap, place: .tailAppendEventTap, options: .defaultTap,
eventsOfInterest: CGEventMask(eventMask),
callback: {
(proxy: CGEventTapProxy, eventType: CGEventType, event: CGEvent, refcon: UnsafeMutableRawPointer?)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SendKeysLib/TerminationListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TerminationListener {

guard
let eventTap = CGEvent.tapCreate(
tap: .cghidEventTap, place: .tailAppendEventTap, options: .defaultTap,
tap: .cgSessionEventTap, place: .tailAppendEventTap, options: .defaultTap,
eventsOfInterest: CGEventMask(eventMask),
callback: {
(proxy: CGEventTapProxy, eventType: CGEventType, event: CGEvent, refcon: UnsafeMutableRawPointer?)
Expand Down