I'm trying to get pid_t of using a specific window (CGWindowListCopyWindowInfo). After fighting the casting of the Swift, the end of the window can be obtained Onrpiaidi
var window Onrpiaidiarf = Siafafeediaget value (Vindoinforaf, unsecured Adedof (Kesijiwaindo Onrpiaidi)) Version window Oinder PID = insecure bit Cast (window Onrpiaidiaraf, Oobakt.af)
AXUIElement = AXUIElementCreateApplication (testPid) .takeRetainedValue ()now I Smar to windowOwnerPID cast variables AnyObject Oh
var need to pid_t to feed appRef>
But it does not know how to do. Anyone have experience with this issue?
According to,
value kCGWindowOwnerPID
keyCFNumberRef for < / Code> type (
kCFNumberIntType
as encoded) that contains the application ID of the application that owns the window.CoreFoundation Using toll- free bridging between the foundation types and Foundation and swift way, should do the following:
letlist = CGWindowListCopyWindowInfo (CGWindowListOption (kCGWindowListOptionScreenOnly ), 0) .takeRetainedValue () as a list of wdict [[string: Onobaj]] {that's as PD = wdict [kCGWindowOwnerPID]? Int {println (pid) // pid is an int here. If necessary, pid = pid_t (pid)}}
The Convert pid_t (so with
unsecured know ()
andunprotected bitcast ()
Swift 1.2 (Xcode 6.3 beta)string CFStringRef
requires> with a clear conversion (thanks to Rob for not required ).reaction Napier):
to wlist = CGWindowListCopyWindowInfo (CGWindowListOption (kCGWindowListOptionOnScreenOnly), 0) as (.takeRetainedValue to wdict in wlist to)! [[String: Oibbad]] {if Pwyd = Vadikt [String (KCG windowOnPID)] as? Int {println (pid)}}
No comments:
Post a Comment