2013-03-01 95 views
6

我遇到問題。我的Mac中有兩種鍵盤佈局,因爲我必須在與不同的人進行通信時輸入兩種不同的語言。我使用鍵盤快捷鍵Cmd+Space從一種佈局(語言)切換到另一種佈局。Mac OS X:攔截鍵盤佈局更改

不知我是否可以在按下Cmd+Space時運行自定義腳本?我知道有一個名爲Punto Switcher的應用程序可以做到這一點。

我的想法是更改鍵盤突出顯示級別以指示當前的語言。

  • 明亮=德國(或俄語或其他)
  • 昏暗=英語

的問題是在哪裏可以找到API,可以在Mac OS X

  1. 攔截鍵盤佈局
  2. 改變鍵盤亮點的亮點

enter image description here

+0

花式圖片!! – Klaas 2016-08-02 23:23:15

回答

1

我發現阿米特·辛格,他給主意,因爲在無證的API,他用C,對於這一點,你一定能找到某種從這個幫助的博客。

Experimenting With Light

或者你可以用這些代碼嘗試:

UInt64 lightInsideGetLEDBrightness(){ 
    kern_return_t kr = 0; 
    IOItemCount scalarInputCount = 1; 
    IOItemCount scalarOutputCount = 1; 
    UInt64  in_unknown = 0, out_brightness; 
    kr = IOConnectCallScalarMethod(dataPort, kGetLEDBrightnessID, &in_unknown, scalarInputCount, &out_brightness, &scalarOutputCount); 
    return out_brightness; 
} 
5

整潔指針從@Anoop維迪LED亮度的東西 - 看起來很有趣!

當輸入法更改時,系統發送通知。

首先,聲明一個功能,以接收所述通知:

void theKeyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { 
    NSLog(@"Keyboard/input method changed."); 
} 

然後註冊變更通知:

CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), 
    myContextInfo, theKeyboardChanged, 
    kTISNotifySelectedKeyboardInputSourceChanged, NULL, 
    CFNotificationSuspensionBehaviorDeliverImmediately);