Created
June 27, 2010 16:22
-
-
Save mkhl/455002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ctrl-f1 | |
* ------- | |
* Query or toggle the "Full Keyboard Access" hotkey, Ctrl-F1 | |
* | |
* make CC=clang CFLAGS="-framework Carbon" ctrl-f1 | |
*/ | |
#include <Carbon/Carbon.h> | |
/* Undocumented Goodness extracted from CGSHotKeys.h */ | |
typedef enum { | |
kCGSHotKeyToggleFullKeyboardAccess = 12, | |
kCGSHotKeyFocusMenubar = 7, | |
kCGSHotKeyFocusDock = 8, | |
kCGSHotKeyFocusNextGlobalWindow = 9, | |
kCGSHotKeyFocusToolbar = 10, | |
kCGSHotKeyFocusFloatingWindow = 11, | |
kCGSHotKeyFocusApplicationWindow = 27, | |
kCGSHotKeyFocusNextControl = 13, | |
kCGSHotKeyFocusDrawer = 51, | |
kCGSHotKeyFocusStatusItems = 57, | |
kCGSHotKeyScreenshot = 28, | |
kCGSHotKeyScreenshotToClipboard = 29, | |
kCGSHotKeyScreenshotRegion = 30, | |
kCGSHotKeyScreenshotRegionToClipboard = 31, | |
kCGSHotKeyToggleZoom = 15, | |
kCGSHotKeyZoomOut = 19, | |
kCGSHotKeyZoomIn = 17, | |
kCGSHotKeyZoomToggleSmoothing = 23, | |
kCGSHotKeyIncreaseContrast = 25, | |
kCGSHotKeyDecreaseContrast = 26, | |
kCGSHotKeyInvertScreen = 21, | |
kCGSHotKeyDecreaseDisplayBrightness = 53, | |
kCGSHotKeyIncreaseDisplayBrightness = 54, | |
kCGSHotKeyToggleVoiceOver = 59, | |
kCGSHotKeyExposeAllWindows = 32, | |
kCGSHotKeyExposeAllWindowsSlow = 34, | |
kCGSHotKeyExposeApplicationWindows = 33, | |
kCGSHotKeyExposeApplicationWindowsSlow = 35, | |
kCGSHotKeyExposeDesktop = 36, | |
kCGSHotKeyExposeDesktopsSlow = 37, | |
kCGSHotKeyDashboard = 62, | |
kCGSHotKeyDashboardSlow = 63, | |
kCGSHotKeySpaces = 75, | |
kCGSHotKeySpacesSlow = 76, | |
kCGSHotKeySpaceLeft = 79, | |
kCGSHotKeySpaceLeftSlow = 80, | |
kCGSHotKeySpaceRight = 81, | |
kCGSHotKeySpaceRightSlow = 82, | |
kCGSHotKeySpaceDown = 83, | |
kCGSHotKeySpaceDownSlow = 84, | |
kCGSHotKeySpaceUp = 85, | |
kCGSHotKeySpaceUpSlow = 86, | |
kCGSHotKeyToggleCharacterPallette = 50, | |
kCGSHotKeySelectPreviousInputSource = 60, | |
kCGSHotKeySelectNextInputSource = 61, | |
kCGSHotKeySpotlightSearchField = 64, | |
kCGSHotKeySpotlightWindow = 65, | |
kCGSHotKeyToggleDockAutohide = 52, | |
kCGSHotKeyToggleFrontRow = 73, | |
kCGSHotKeyLookUpWordInDictionary = 70, | |
kCGSHotKeyHelp = 98, | |
} CGSSymbolicHotKey; | |
extern bool CGSIsSymbolicHotKeyEnabled(CGSSymbolicHotKey hotKey); | |
extern CGError CGSSetSymbolicHotKeyEnabled(CGSSymbolicHotKey hotKey, bool isEnabled); | |
void get(void) { | |
printf("Full Keyboard Access is: %s\n", CGSIsSymbolicHotKeyEnabled(kCGSHotKeyToggleFullKeyboardAccess) ? "enabled" : "disabled"); | |
} | |
void set(const bool enabled) { | |
CGSSetSymbolicHotKeyEnabled(kCGSHotKeyToggleFullKeyboardAccess, enabled); | |
get(); | |
} | |
void usage(char *const self) { | |
printf("Usage: %s [-q|-t|-f]\n", self); | |
} | |
int main(int argc, char *const argv[]) { | |
int opt; | |
while ((opt = getopt(argc, argv, "qtf")) != -1) { | |
switch (opt) { | |
case 'q': | |
get(); | |
break; | |
case 't': | |
set(TRUE); | |
break; | |
case 'f': | |
set(FALSE); | |
break; | |
default: | |
usage(argv[0]); | |
return -1; | |
} | |
} | |
if (argc == 1) { | |
get(); | |
usage(argv[0]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to karstenBriksoft for the tip!
http://twitter.com/_karsten_/statuses/17152088894