Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

カテゴリー: Input Method

Keyboard Viewerを表示する

Posted on 3月 10, 2019 by Takaaki Naganoya

入力メニューから呼び出すことのできる「キーボードビューア」(ソフトウェアキーボード)を表示するAppleScriptです。

macOSには、成り立ちのことなる2系統のソフトウェアキーボードが搭載されています。

文字入力補助用の「キーボードビューア」

1つが、本Scriptで対象にしている「キーボードビューア」。入力メニューから呼び出すタイプのソフトウェアキーボードです。昔のClassic Macintoshの時代には、ノート型のPowerBookが登場するまで(Macintosh Portableもあったものの、キーボードが取り外し可能でした)本体とキーボード、マウスが分離するタイプのコンピュータであったため、ソフトウェアキーボードの存在は必要なものでした。

キーボード未接続時の緊急用に「キー配列」というキーボードビューアの前進であるソフトウェアを使うことがありました。利用頻度ははとても低いものでした。マウスしかつなげていない時にキー入力するといった程度のものです。

昔、Classic MacOSの時代に、日本語手書きフォントでカタカナにマッピングしていたもの(R研究所の日本語手書きフォントなど)があったので、そうした変則的なフォントを入力するための補助UIとして使ったとかいう記憶はあります。

障害者補助用の「キーボード」スイッチ

もう1つが、アクセシビリティ系の機能で提供されている「キーボード」。システム環境設定>アクセシビリティ>スイッチコントロールで、「ホーム」のスイッチから、「キーボード」ボタンを選択すると表示されるソフトウェアキーボードです。

単なる文字入力だけではなく、キーボード自体が使えないユーザー向けにカーソル移動やマウスの左右クリック、ドラッグ&ドロップ、スクロールや日本語かな漢字変換などの機能を提供しています。

「キーボード」スイッチは、表示位置を変更できるものの、サイズの変更は行えませんとサイズの変更が可能です。キーボードビューアもリサイズが可能です。

昨今ソフトウェアキーボードの存在に注目が集まる

これらソフトウェアキーボード類は、タブレット型のPCでmacOSを動かしたり、Macの外部ディスプレイとしてiPadを用いる利用方法が紹介されるようになって、近年その存在が再注目されつつあります。

本AppleScriptはキーボードビューアを呼び出して表示します。呼び出しにBridgePlusを必要としており、macOS 10.14.x上で実行するためには、AppleScriptをバンドル形式のアプレットとして書き出し、アップレットのバンドル中にBrdgePlusを同梱する必要があります。

AppleScript名:Keyboard Viewerを表示する
— Created 2015-09-16 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use BridgePLus : script "BridgePlus" version "1.2" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

property targInputID : "com.apple.KeyboardViewer"

load framework
set aList to (current application’s SMSForder’s allAvailableInputSourceIDs()) as list
if targInputID is in aList then
  set x to current application’s SMSForder’s changeInputSourceTo:targInputID
  
if x = false then error "Can not change input source."
end if

★Click Here to Open This Script 

(Visited 370 times, 2 visits today)
Posted in Input Method System | Tagged 10.11savvy 10.12savvy 10.13savvy 10.14savvy | Leave a comment

InputManagerでIMを切り換える v2

Posted on 12月 20, 2018 by Takaaki Naganoya

InputManager.frameworkを呼び出して、日本語入力Input Methodの入力文字の切り替えを行うAppleScriptです。

–> Demo Movie

macOS標準装備のスクリプトエディタ上ではControl-Command-Rで実行できましたが、Script Debugger上で動かなかった(メインスレッド上で強制実行する必要があった)ので、切り替えメソッドを強制的にメインスレッド上で実行するように変更してみました。

–> InputManager.framework (To ~/Library/Frameworks)

macOS 10.14上で実行する場合には、(フレームワーク呼び出しの都合上)Script Debugger上で実行してください。

AppleScript名:InputManagerでIMを切り換える v2
— Created 2017-01-22 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "InputManager" –https://github.com/jensnockert/input-manager

–Caution: This script runs on only Japanese language environment

set cList to current application’s CSInputSource’s all()
set dList to (cList’s valueForKey:"localizedName")
set aRes to ((dList’s indexOfObject:"ひらがな") as integer) –"Hiragana" in Japanese
set bRes to ((dList’s indexOfObject:"英字") as integer) –"English Letters" in Japanese

set hiraKey to cList’s objectAtIndex:aRes
set engKey to cList’s objectAtIndex:bRes

repeat 3 times
  my performSelectorOnMainThread:"selectInputCharMode:" withObject:(hiraKey) waitUntilDone:true
  
delay 1
  
my performSelectorOnMainThread:"selectInputCharMode:" withObject:(engKey) waitUntilDone:true
  
delay 1
end repeat

–Force execute on Main Thread
on selectInputCharMode:aModeObj
  aModeObj’s |select|()
end selectInputCharMode:

★Click Here to Open This Script 

(Visited 70 times, 1 visits today)
Posted in Input Method Language | Tagged 10.11savvy 10.12savvy 10.13savvy 10.14savvy | 1 Comment

日本語入力のライブ変換のオン、オフ v2

Posted on 10月 28, 2018 by Takaaki Naganoya

日本語入力Input Methodの「ライブ変換」のOn/Offの状態を変更するAppleScriptのmacOS 10.13/10.14対応版です。

大した箇所ではなく、NSDictionaryの作成が通らなかったのできっちり書きました。こういう些細な表記がOSバージョンごとに変わってくるのがCocoa Scriptingの要注意点でしょうか。

AppleScript名:ライブ変換のオン、オフ v2
—
–  Created by: Takaaki Naganoya
–  Created on: 2018/10/28
—
–  Copyright © 2018 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

makeLiveHenkanEnabled(true) of me –Enable
makeLiveHenkanEnabled(false) of me –Disable

–日本語入力の「ライブ変換」をオン/オフする。Sandbox環境では動作しない
on makeLiveHenkanEnabled(aFlag as boolean)
  set fNumFlag to aFlag as integer
  
  
set aRec to current application’s NSDictionary’s dictionaryWithObjects:{fNumFlag} forKeys:{"JIMPrefLiveConversionKey"}
  
  
current application’s NSDistributedNotificationCenter’s defaultCenter()’s postNotificationName:"com.apple.inputmethod.JIM.PreferencesDidChangeNotification" object:"com.apple.JIMSession" userInfo:aRec options:0
  
  
current application’s NSDistributedNotificationCenter’s defaultCenter()’s postNotificationName:"com.apple.inputmethod.JIM.PreferencesDidChangeNotification" object:"com.apple.JIMPreferences" userInfo:aRec options:0
end makeLiveHenkanEnabled

★Click Here to Open This Script 

(Visited 47 times, 1 visits today)
Posted in Input Method Record System | Tagged 10.11savvy 10.12savvy 10.13savvy 10.14savvy NSDictionary NSDistributedNotificationCenter | Leave a comment

日本語入力のライブ変換のオン、オフ

Posted on 10月 28, 2018 by Takaaki Naganoya

日本語入力Input Methodの「ライブ変換」のOn/Offの状態を変更するAppleScriptです。

Sandbox環境下では動作しないとのこと。Xcode上で作成したMac App Store向けのGUIアプリケーション環境(Sandbox環境下)だと機能しない可能性が高いとのこと。

テストしてみたところ、macOS 10.13/10.14で動作しなかったため、あとで少々書き換えてみました(v2)。

個人的には、日本語入力のライブ変換は真っ先にオフにする心底いらない機能です。

AppleScript名:ライブ変換のオン、オフ.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2018/10/28
—
–  Copyright © 2018 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

makeLiveHenkanEnabled(true) of me –Enable
makeLiveHenkanEnabled(false) of me –Disable

–日本語入力の「ライブ変換」をオン/オフする。Sandbox環境では動作しない
on makeLiveHenkanEnabled(aFlag as boolean)
  set fNumFlag to aFlag as integer
  
  
set aRec to current application’s NSDictionary’s dictionaryWithObjectsAndKeys_((fNumFlag), "JIMPrefLiveConversionKey")
  
current application’s NSDistributedNotificationCenter’s defaultCenter()’s postNotificationName:"com.apple.inputmethod.JIM.PreferencesDidChangeNotification" object:"com.apple.JIMSession" userInfo:aRec options:0
  
  
set bRec to current application’s NSDictionary’s dictionaryWithObjectsAndKeys_((fNumFlag), "JIMPrefLiveConversionKey")
  
current application’s NSDistributedNotificationCenter’s defaultCenter()’s postNotificationName:"com.apple.inputmethod.JIM.PreferencesDidChangeNotification" object:"com.apple.JIMPreferences" userInfo:bRec options:0
end makeLiveHenkanEnabled

★Click Here to Open This Script 

(Visited 100 times, 1 visits today)
Posted in Input Method Record System | Tagged 10.11savvy 10.12savvy NSDictionary NSDistributedNotificationCenter | Leave a comment

日本語入力のライブ変換の状態をBooleanで取得する

Posted on 10月 28, 2018 by Takaaki Naganoya

日本語入力Input Methodの「ライブ変換」のOn/Offの状態を取得するAppleScriptです。

本Scriptは状態を取得する「だけ」で、強制設定などは行いません。

AppleScript名:ライブ変換の状態をBooleanで取得する.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2018/10/28
—
–  Copyright © 2018 Piyomaru Software, All Rights Reserved
–   http://www.mindto01s.com/2017/03/27/9f85c2fb_9f90_4e1b_8e5e_8719f57900eb.html

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set imRes to getLiveHenkanStatus() of me
–> true : 「ライブ変換」On
–> false : 「ライブ変換」Off

on getLiveHenkanStatus()
  set theUD to current application’s NSUserDefaults’s alloc()’s initWithSuiteName:"com.apple.inputmethod.Kotoeri"
  
set imRes to (theUD’s valueForKey:"JIMPrefLiveConversionKey") as boolean
  
return imRes
end getLiveHenkanStatus

★Click Here to Open This Script 

(Visited 57 times, 1 visits today)
Posted in Input Method System | Tagged 10.11savvy 10.12savvy 10.13savvy 10.14savvy NSUserDefaults | Leave a comment

Input Methodのメニュー表示名を取得する

Posted on 2月 20, 2018 by Takaaki Naganoya

–> InputManager.framework

AppleScript名:Input Methodのメニュー表示名を取得する
— Created 2017-01-22 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "InputManager" –https://github.com/jensnockert/input-manager

set cList to (current application’s CSInputSource’s all()’s valueForKey:"localizedName") as list
–>  {​​​​​"ひらがな", ​​​​​"英字", ​​​​​"カタカナ", ​​​​​"日本語", ​​​​​"かなパレット", ​​​​​"com.apple.PressAndHold", ​​​​​"絵文字と記号", ​​​​​"キーボードビューア", ​​​​​"EmojiFunctionRowIM_Extension"​​​}–10.10.x
–> {"ひらがな", "英字", "カタカナ", "日本語", "かなパレット", "com.apple.PressAndHold", "絵文字と記号", "キーボードビューア"}–10.12.x

★Click Here to Open This Script 

(Visited 37 times, 1 visits today)
Posted in Input Method System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

InputManagerでIMを切り換える

Posted on 2月 20, 2018 by Takaaki Naganoya

InputManager.frameworkを呼び出して、日本語入力Input Methodの入力文字の切り替えを行うAppleScriptです。

スクリプトエディタ上でControl-Command-Rにてフロントエンド・プロセスで実行する必要があります。

–> Demo Movie

–> InputManager.framework

AppleScript名:InputManagerでIMを切り換える
— Created 2017-01-22 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "InputManager" –https://github.com/jensnockert/input-manager

–Check If this script runs in foreground
if not (current application’s NSThread’s isMainThread()) as boolean then
  display alert "This script must be run from the main thread (Command-Control-R in Script Editor)." buttons {"Cancel"} as critical
  
error number -128
end if

–Caution: This script runs on only Japanese language environment

set cList to current application’s CSInputSource’s all()
set dList to (cList’s valueForKey:"localizedName")
set aRes to ((dList’s indexOfObject:"ひらがな") as integer) –"Hiragana" in Japanese
set bRes to ((dList’s indexOfObject:"英字") as integer) –"English Letters" in Japanese

set hiraKey to cList’s objectAtIndex:aRes
set engKey to cList’s objectAtIndex:bRes

repeat 10 times
  hiraKey’s |select|()
  
delay 1
  
engKey’s |select|()
  
delay 1
end repeat

★Click Here to Open This Script 

(Visited 37 times, 1 visits today)
Posted in Input Method Require Control-Command-R to run System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

InputManagerのじっけん

Posted on 2月 6, 2018 by Takaaki Naganoya

–> InputManager.framework (To ~/Library/Frameworks)

AppleScript名:InputManagerのじっけん
— Created 2017-01-22 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "InputManager"

set cList to current application’s CSInputSource’s all()
–>  (NSArray) {​​​​​(CSInputSource) <CSInputSource: 0x60000000d310>, ​​​​​(CSInputSource) <CSInputSource: 0x60000000f580>, ​​​​​(CSInputSource) <CSInputSource: 0x60000000bd30>, ​​​​​(CSInputSource) <CSInputSource: 0x600000216d20>, ​​​​​(CSInputSource) <CSInputSource: 0x6000002168d0>, ​​​​​(CSInputSource) <CSInputSource: 0x600000216c50>, ​​​​​(CSInputSource) <CSInputSource: 0x600000012620>, ​​​​​(CSInputSource) <CSInputSource: 0x60000000b010>, ​​​​​(CSInputSource) <CSInputSource: 0x600000217010>​​​}

set dList to (cList’s valueForKey:"localizedName") as list
–>  {​​​​​"ひらがな", ​​​​​"英字", ​​​​​"カタカナ", ​​​​​"日本語", ​​​​​"かなパレット", ​​​​​"com.apple.PressAndHold", ​​​​​"絵文字と記号", ​​​​​"キーボードビューア", ​​​​​"EmojiFunctionRowIM_Extension"​​​}

set c1 to (current application’s CSInputSource’s currentKeyboard()’s localizedName()) as string
–> "ひらがな"
–> "英字"

set c2 to (current application’s CSInputSource’s currentKeyboardLayout()’s localizedName()) as string
–> "U.S."

set err1 to (current application’s CSInputSource’s forLanguage:"ja")’s |select|()
log err1
set err2 to (current application’s CSInputSource’s forLanguage:"en_US")’s |select|()
log err2

★Click Here to Open This Script 

(Visited 31 times, 1 visits today)
Posted in Input Method 未分類 | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

IMのメニュー表示名を取得する

Posted on 2月 6, 2018 by Takaaki Naganoya

–> InputManager.framework

AppleScript名:IMのメニュー表示名を取得する
— Created 2017-01-22 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "InputManager" –https://github.com/jensnockert/input-manager

set cList to (current application’s CSInputSource’s all()’s valueForKey:"localizedName") as list
–>  {​​​​​"ひらがな", ​​​​​"英字", ​​​​​"カタカナ", ​​​​​"日本語", ​​​​​"かなパレット", ​​​​​"com.apple.PressAndHold", ​​​​​"絵文字と記号", ​​​​​"キーボードビューア", ​​​​​"EmojiFunctionRowIM_Extension"​​​}

★Click Here to Open This Script 

(Visited 45 times, 1 visits today)
Posted in Input Method System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

InputMethodで現在選択中のIM名を文字列で取得する

Posted on 2月 6, 2018 by Takaaki Naganoya

–> InputManager.framework

AppleScript名:InputMethodで現在選択中のIM名を文字列で取得する
— Created 2017-01-22 22:11:33 +0900 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "InputManager"

set c2 to (current application’s CSInputSource’s mInputSource()) –>  "英字"
–>  "ひらがな"
–>  "カタカナ"

★Click Here to Open This Script 

(Visited 30 times, 1 visits today)
Posted in Input Method System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • AppleScriptによるWebブラウザ自動操縦ガイド
  • macOS 13, Ventura(継続更新)
  • ドラッグ&ドロップ機能の未来?
  • macOS 12.x上のAppleScriptのトラブルまとめ
  • PFiddlesoft UI Browserが製品終了に
  • macOS 12.3 beta 5、ASの障害が解消される(?)
  • SF Symbolsを名称で指定してPNG画像化
  • 新刊発売:AppleScriptによるWebブラウザ自動操縦ガイド
  • macOS 12.3 beta4、まだ直らないASまわりの障害
  • macOS 12.3上でFinder上で選択中のファイルをそのままオープンできない件
  • Safariで表示中のYouTubeムービーのサムネイル画像を取得
  • macOS 12のスクリプトエディタで、Context Menu機能にバグ
  • Pixelmator Pro v2.4.1で新機能追加+AppleScriptコマンド追加
  • 人類史上初、魔導書の観点から書かれたAppleScript入門書「7つの宝珠」シリーズ開始?!
  • CotEditor v4.1.2でAppleScript系の機能を追加
  • macOS 12.5(21G72)がリリースされた!
  • UI Browserがgithub上でソース公開され、オープンソースに
  • Pages v12に謎のバグ。書類上に11枚しか画像を配置できない→解決
  • 新発売:AppleScriptからSiriを呼び出そう!
  • iWork 12.2がリリースされた

Tags

10.11savvy (1102) 10.12savvy (1243) 10.13savvy (1391) 10.14savvy (586) 10.15savvy (434) 11.0savvy (274) 12.0savvy (174) 13.0savvy (34) CotEditor (60) Finder (47) iTunes (19) Keynote (97) NSAlert (60) NSArray (51) NSBezierPath (18) NSBitmapImageRep (21) NSBundle (20) NSButton (34) NSColor (51) NSDictionary (27) NSFileManager (23) NSFont (18) NSImage (42) NSJSONSerialization (21) NSMutableArray (62) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (118) NSURL (97) NSURLRequest (23) NSUTF8StringEncoding (30) NSUUID (18) NSView (33) NSWorkspace (20) Numbers (55) Pages (36) Safari (41) Script Editor (20) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • drive
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • 登録
  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • 登録
  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC