From 22e657a042d653e5abcdb876d843bb80343e9053 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 13:36:32 -0500 Subject: Make click work from hotkey in NSUserDefaults Get the shortcut saved from the windows application in our daemon and if there is one, use that as the hotkey to activate the mouse click. Yay! This is coming together! --- Low Battery Yup d/AppDelegate.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Low Battery Yup d/AppDelegate.m b/Low Battery Yup d/AppDelegate.m index 7aa29fe..c47df18 100644 --- a/Low Battery Yup d/AppDelegate.m +++ b/Low Battery Yup d/AppDelegate.m @@ -9,6 +9,7 @@ #import "AppDelegate.h" #import "DDHotKeyCenter.h" #import +#import "Constants.h" @implementation AppDelegate @@ -22,12 +23,17 @@ { _mouse = [[Mouse alloc] init]; - DDHotKeyCenter *hotkey_center = [DDHotKeyCenter sharedHotKeyCenter]; - [hotkey_center registerHotKeyWithKeyCode:kVK_ANSI_0 - modifierFlags:(NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask) - target:self - action:@selector(dismissLowBatteryWarning:) - object:nil]; + [[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.teddywing.Low-Battery-Yup"]; + NSDictionary *shortcut = [[NSUserDefaults standardUserDefaults] objectForKey:kPreferenceGlobalShortcut]; + + if (shortcut) { + DDHotKeyCenter *hotkey_center = [DDHotKeyCenter sharedHotKeyCenter]; + [hotkey_center registerHotKeyWithKeyCode:[[shortcut objectForKey:@"keyCode"] unsignedIntegerValue] + modifierFlags:[[shortcut objectForKey:@"modifierFlags"] unsignedIntegerValue] + target:self + action:@selector(dismissLowBatteryWarning:) + object:nil]; + } } - (void)dismissLowBatteryWarning:(NSEvent *)hotKeyEvent -- cgit v1.2.3