SimpleHotKey 0.1

SimpleHotKey 0.1

测试已测试
语言语言 Obj-CObjective C
许可证 自定义
发布上次发布2014年12月

shiweifu 维护。



  • 作者:
  • shiweifu

本库只保留了 DDHotKey 的基本功能:

  • 绑定全局快捷键
  • 取消绑定全局快捷键

摘录一段注册全局快捷键的代码(使用了 Carbon):

@implementation HotKey

OSStatus HotKeyHandler(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData) { AppDelegate *delegate = [[NSApplication sharedApplication]delegate]; [delegate displayMenu]; return noErr; }

  • (void) register { EventHotKeyRef gMyHotKeyRef; EventHotKeyID gMyHotKeyID; EventTypeSpec eventType; eventType.eventClass = kEventClassKeyboard; eventType.eventKind = kEventHotKeyPressed;

    InstallApplicationEventHandler(&HotKeyHandler, 1, &eventType, NULL, NULL);

    gMyHotKeyID.signature='htk1'; gMyHotKeyID.id=1;

    RegisterEventHotKey(kVK_ANSI_M, cmdKey+shiftKey, gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef); }

@end

DDHotKey 的GitHub地址:https://github.com/davedelong/DDHotKey