You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
720 B
21 lines
720 B
import Foundation
|
|
import Cocoa
|
|
|
|
class TestTimer {
|
|
private var timerSource: DispatchSourceTimer?
|
|
|
|
func start() {
|
|
let queue = DispatchQueue(label: "com.test.timer", qos: .userInteractive)
|
|
let timer = DispatchSource.makeTimerSource(queue: queue)
|
|
timer.schedule(deadline: .now(), repeating: .milliseconds(50))
|
|
timer.setEventHandler {
|
|
if let (elem, app) = FocusedInputSync.shared.getFocusedElement() {
|
|
if let state = FocusedInputSync.shared.inspectCurrentState() {
|
|
print("Live State detected: '\(state.text)' in \(state.app)")
|
|
}
|
|
}
|
|
}
|
|
timer.resume()
|
|
self.timerSource = timer
|
|
}
|
|
}
|