根据这个帖子:RegisterEventHotKey CMD + TAB在山狮
ShortcutRecorder record CMD+Tab
呼吁ShortCutRecorder控制setCanCaptureGlobalHotKeys:YES
应该让你捕捉CMD + TAB。但是,它似乎并不奏效。如果我使用cmdKey + optionKey
,那么它的工作
OSStatus myHotKeyHandler(EventHandlerCallRef nextHandler, EventRef anEvent, void *userData)
{
NSLog(@"YEAY WE DID A GLOBAL HOTKEY");
return noErr;
}
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
EventHotKeyRef myHotKeyRef;
EventHotKeyID myHotKeyID;
EventTypeSpec eventType;
eventType.eventClass = kEventClassKeyboard;
eventType.eventKind = kEventHotKeyPressed;
myHotKeyID.signature = 'mhk1';
myHotKeyID.id = 1;
InstallApplicationEventHandler(&myHotKeyHandler, 1, &eventType, NULL, NULL);
OSStatus status = RegisterEventHotKey(kVK_Tab,
cmdKey,
myHotKeyID,
GetApplicationEventTarget(),
0,
&myHotKeyRef);
NSLog(@"status:%d", status);
}
@end
:我创造了这个小应用自己看看怎么回事。
是否有另一种方式捕捉我自己的应用程序在山狮的CMD + TAB? CMD + OPTION + TAB对我来说不够好。