Created
March 30, 2020 04:04
-
-
Save kawaz/3643468aab25c7a8c7bcf80db9cdb10e to your computer and use it in GitHub Desktop.
macOSでIME(日本語入力)の情報を取得する
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
#!/usr/bin/swift | |
import Carbon | |
// Carbon.h -> HIToolbox.h -> TextInputSources.h | |
// grep "extern const" /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/TextInputSources.h | |
let props: [CFString] = [ | |
kTISPropertyInputSourceCategory, | |
kTISPropertyInputSourceType, | |
kTISPropertyInputSourceIsASCIICapable, | |
kTISPropertyInputSourceIsEnableCapable, | |
kTISPropertyInputSourceIsSelectCapable, | |
kTISPropertyInputSourceIsEnabled, | |
kTISPropertyInputSourceIsSelected, | |
kTISPropertyInputSourceID, | |
kTISPropertyBundleID, | |
kTISPropertyInputModeID, | |
kTISPropertyLocalizedName, | |
kTISPropertyInputSourceLanguages, | |
kTISPropertyUnicodeKeyLayoutData, | |
kTISPropertyIconRef, | |
kTISPropertyIconImageURL, | |
kTISCategoryKeyboardInputSource, | |
kTISCategoryPaletteInputSource, | |
kTISCategoryInkInputSource, | |
kTISTypeKeyboardLayout, | |
kTISTypeKeyboardInputMethodWithoutModes, | |
kTISTypeKeyboardInputMethodModeEnabled, | |
kTISTypeKeyboardInputMode, | |
kTISTypeCharacterPalette, | |
kTISTypeKeyboardViewer, | |
kTISTypeInk, | |
kTISNotifySelectedKeyboardInputSourceChanged, | |
kTISNotifyEnabledKeyboardInputSourcesChanged | |
] | |
let inputSourceRef = TISCopyCurrentKeyboardInputSource().takeUnretainedValue() | |
for p in props { | |
if let v = TISGetInputSourceProperty(inputSourceRef, p) { | |
let v2 = Unmanaged<AnyObject>.fromOpaque(v).takeUnretainedValue() | |
print(p, v2) | |
} | |
} |
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
TISPropertyInputSourceCategory TISCategoryKeyboardInputSource | |
TISPropertyInputSourceType TISTypeKeyboardInputMode | |
TISPropertyInputSourceIsASCIICapable 1 | |
TISPropertyInputSourceIsEnableCapable 1 | |
TISPropertyInputSourceIsSelectCapable 1 | |
TSMInputSourcePropertyIsEnabled 1 | |
TSMInputSourcePropertyIsSelected 1 | |
TISPropertyInputSourceID com.google.inputmethod.Japanese.Roman | |
TSMInputSourcePropertyBundleID com.google.inputmethod.Japanese | |
TSMInputSourcePropertyInputMode com.apple.inputmethod.Roman | |
TSMInputSourcePropertyLocalizedName Alphanumeric (Google) | |
TISPropertyInputSourceLanguages ( | |
en | |
) | |
TISPropertyIconImageURL Contents/Resources/direct.tiff -- file:///Library/Input%20Methods/GoogleJapaneseInput.app/ |
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
TISPropertyInputSourceCategory TISCategoryKeyboardInputSource | |
TISPropertyInputSourceType TISTypeKeyboardInputMode | |
TISPropertyInputSourceIsASCIICapable 0 | |
TISPropertyInputSourceIsEnableCapable 1 | |
TISPropertyInputSourceIsSelectCapable 1 | |
TSMInputSourcePropertyIsEnabled 1 | |
TSMInputSourcePropertyIsSelected 1 | |
TISPropertyInputSourceID com.google.inputmethod.Japanese.base | |
TSMInputSourcePropertyBundleID com.google.inputmethod.Japanese | |
TSMInputSourcePropertyInputMode com.apple.inputmethod.Japanese | |
TSMInputSourcePropertyLocalizedName Hiragana (Google) | |
TISPropertyInputSourceLanguages ( | |
ja | |
) | |
TISPropertyIconImageURL Contents/Resources/hiragana.tiff -- file:///Library/Input%20Methods/GoogleJapaneseInput.app/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment