Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // AppController.m
- // GlobalEvents
- //
- // Created by John Carlyle on 4/14/10.
- // Copyright 2010 __MyCompanyName__. All rights reserved.
- //
- #import "AppController.h"
- #import <Carbon/Carbon.h>
- OSStatus myHotKeyHandler(EventHandlerCallRef nextHandler, EventRef anEvent, void *userData);
- @implementation AppController
- - (void)awakeFromNib
- {
- EventHotKeyRef myHotKeyRef;
- EventHotKeyID myHotKeyID;
- EventTypeSpec eventType;
- eventType.eventClass=kEventClassKeyboard;
- eventType.eventKind=kEventHotKeyPressed;
- InstallApplicationEventHandler(&myHotKeyHandler,1,&eventType,NULL,NULL);
- myHotKeyID.signature='mhk1';
- myHotKeyID.id=1;
- RegisterEventHotKey(0x1a, cmdKey+optionKey+shiftKey+controlKey, myHotKeyID, GetApplicationEventTarget(), 0, &myHotKeyRef);
- }
- OSStatus myHotKeyHandler(EventHandlerCallRef nextHandler, EventRef anEvent, void *userData)
- {
- NSLog(@"GLOBAL HOTKEY PRESSERATED");
- return noErr;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement