osx - OS X. How to get TISInputSourceRef (keyboard layout) of current active window of all system in daemon? -


Is

I want to get the keyboard layout in Windows like GetKeyboardLayout (threadId) Thread id application with the active window I I I want to describe the virtual key code around the current language.

Now I use the TISCopyCurrentKeyboardInputSource () function, but it does not have the criteria and it is only "U.S." Returns Language I think this is the layout of the daemon. Besides, I can not change the code with TISInputSourceRef of the TISCopyInputSourceForLanguage (language) function. It only returns US characters. Update

When: Okay I found a solution to change the key code I with 0 equal to Zest call function UCKeyTranslate parameter modifier. But how can I not get the active source of the active window or just any running app?

Update 2: is the plist path / library / launch events

   & Lt; / Dict & gt; & Lt; / Plist & gt;  

whenever you want to use the status of a user session from a daemon You are doing this wrong ™ it can not be done to work reliably.

The standard solution is to use user agents which are launched every user session.

See for more information.


Update:

The above technical is relevant to understand why you can not do it with a daemon. To

agent, it distributed to inspection should use Notification Center KTISNotifySelectedKeyboardInputSourceChanged and information to learn when selected keyboard input changes the source keyboard input source is You can call TISCopyCurrentKeyboardInputSource () to know it. To

To get the information agent, made him want to run the run loop in your main thread as in a normal Cocoa app in the normal mode, it is part of the main event loop for you is. In a different program, you have to do it yourself.

  should be Bull: KeepRunning = Yes; // global ... [[NSDistributedNotificationCenter defaultCenter] addObserver: self selector: @selector (myMethod :) Name: (__ bridge NSString *) kTISNotifySelectedKeyboardInputSourceChanged object: zero Nilnbnkhana: NSNotificationSuspensionBehaviorDeliverImmediately]; While (Chahiapackejing and amp; [[NSRunLoop currentRunLoop] Rnmod: NSDefaultRunLoopMode beforeDate: [NSDate distantFuture]]) / * nothing * /; ... - (zero) myMethod: (NSNotification *) Notes {TISInputSourceRef Input Source = TISCopyCurrentKeyboardInputSource (); // something with inputSource ...}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -