use AppleScript version "2.5" -- (10.12) or later
use framework "Foundation"
use scripting additions
property NSString : a reference to current application's NSString
property NSStringTransformLatinToHiragana : a reference to current application's NSStringTransformLatinToHiragana
selectString()
set latin to the clipboard
set hiragana to alphabetToHiragana(latin)
set the clipboard to hiragana
pasteString()
henkan()
on selectString()
tell current application
tell application "System Events"
keystroke "ac" using {command down}
end tell
end tell
end selectString
on pasteString()
tell current application
tell application "System Events"
keystroke "v" using {command down}
end tell
end tell
end pasteString
on alphabetToHiragana(aStr)
set aString to NSString's stringWithString:aStr
return (aString's stringByApplyingTransform:(NSStringTransformLatinToHiragana) |reverse|:false) as string
end alphabetToHiragana
on henkan()
tell current application
tell application "System Events"
keystroke "a" using {command down}
key code 104
key code 104
end tell
end tell
end henkan
use AppleScript version "2.5" -- (10.12) or later
use framework "Foundation"
use scripting additions
property NSString : a reference to current application's NSString
property NSStringTransformLatinToHiragana : a reference to current application's NSStringTransformLatinToHiragana
selectString()
set latin to the clipboard
set hiragana to alphabetToHiragana(latin)
set the clipboard to hiragana
pasteString()
henkan()
on selectString()
tell current application
tell application "System Events"
keystroke "ac" using {command down}
end tell
end tell
end selectString
on pasteString()
tell current application
tell application "System Events"
keystroke "v" using {command down}
end tell
end tell
end pasteString
on alphabetToHiragana(aStr)
set aString to NSString's stringWithString:aStr
return (aString's stringByApplyingTransform:(NSStringTransformLatinToHiragana) |reverse|:false) as string
end alphabetToHiragana
on henkan()
tell current application
tell application "System Events"
keystroke "a" using {command down}
key code 104
key code 104
end tell
end tell
end henkan