回答:
AutomatorおよびOS Xサービス機能を使用して、ショートカットでキーボードビューアーを起動できます。
キーボードビューアプログラムは、/System/Library/Input Methods/KeyboardViewer.app(Lionより前のバージョンでは/System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/KeyboardViewerServer.app)にあります。Automatorを使用して簡単なランチャーサービスを作成し、ホットキーで開きます。
Run AppleScriptアクションをワークフローに追加し、テキストを次の行に置き換えます。
if application "KeyboardViewer" is running then
quit application "KeyboardViewer"
end if
activate application "KeyboardViewer"
-- wait until the window has been closed, then end the KeyboardViewer process
set numberOfWindows to 1
repeat until numberOfWindows = 0
delay 5
tell application "System Events"
tell process "KeyboardViewer"
set numberOfWindows to count windows
end tell
end tell
end repeat
quit application "KeyboardViewer"
いくつかのメモ:
repeatKeyboard Viewerに開いているウィンドウがあるかどうかループが5秒ごとにチェックし、そうでない場合は終了します処理する。KeyboardViewerとKeyboardViewerServer。これをテストするのに便利なライオンズ以前のものはありません(誰か他の人がコメントで報告できるなら、それは素晴らしいことです。/System/Library/Input Methods/KeyboardViewer.appカタリナには存在しません。すべてのアプリケーションを開いたが/System/Library/Input Methods、どれもキーボードビューアを開かなかった。何か案は?
QuicksilverのExtra Scriptsプラグインは、Show Keyboard Viewer.scptを提供することでこの機能を提供します。
また、アクションRunを使用してShow Keyboard Viewer.scptの Quicksilver Triggerを作成すると、グローバルKeyboard Viewerホットキーが取得されます。
スクリプトのソースは次のとおりです。
property theApplication : "KeyboardViewer"
property thePath : "/System/Library/Input Methods/KeyboardViewer.app"
set HFSPath to ((POSIX file thePath) as string)
tell application "System Events" to ¬
set isRunning to 0 < (count (application processes whose name is theApplication))
if isRunning then
tell application HFSPath to quit
else
ignoring application responses
tell application HFSPath to activate
end ignoring
end if
KeyboardViewerがAppleScriptまたはで開かれopen、メインウィンドウが閉じられた場合、Keyboard Viewerプロセスは開いたままで、約0〜20%のCPUを使用し続けます。
このスレッドを見つけてよかった。上記の回答に基づいて、キーボードビューアーを切り替えるAlfred拡張スクリプトを作成しました。
https://dl.dropbox.com/u/29440342/linkedFiles/Keyboard%20Viewer.alfredextension
次のapplescriptを実行して、キーボードビューアーのオンとオフを切り替えるalfredキーワード「kv」を提供します。
-- adapted from http://apple.stackexchange.com/a/62532
if application "KeyboardViewer" is running then
quit application "KeyboardViewer"
else
activate application "KeyboardViewer"
end if
(*
-- adapted from http://apple.stackexchange.com/a/59986
tell application "System Events" to tell process "SystemUIServer"
tell (menu bar item 1 where description is "text input") of menu bar 1
click
click (menu item 1 where title ends with "Keyboard Viewer") of menu 1
end tell
end tell
*)
-- icon ripped from osx /System/Library/PreferencePanes Keyboard.prefPane/Contents/Resources/Keyboard.icns
回避すべきパフォーマンスの問題が発生した場合に備えて、別の実装をコメントアウトしました。
私はBetterTouchToolを介して次のことを行う方法を見つけました:
プラットフォーム:rMBP Mountain Lion OSX 10.8
ショートカットでキーボードビューアーをアクティブにする
これで、追加のスクリプトなしでビューアをアクティブ化するキーボードショートカットができました。
しかし、赤いXボタンを押しても実際にアプリケーションが終了するわけではないことに気付きました。つまり、キーボードビューアは一度しかアクティブになりません。そのため、プログラムを終了するスクリプトを作成する必要があります。
この問題を修正するには:
別のキーボードショートカットでキーボードビューアーを閉じる
quit application "KeyboardViewer" これで、KeyBoardビューアを有効にすると、終了する方法があります。赤いXボタンの代わりに使用します。Xボタンを押してもキーボードビューアが完全に終了しない理由がわかるまで、これが解決策です。
編集
キーボードビューアをトグルする方法を見つけました!!
1つのキーボードショートカットでキーボードビューアを切り替え
前と同じプロセスですが、コードが変更されます:
if application "KeyboardViewer" is running then quit application "KeyboardViewer" else activate application "KeyboardViewer" end if
これでキーボードビューアが切り替わり、複数のショートカットを割り当てる必要すらありません!
AppleScriptのリンク
上記のコーディング手順全体を実行するのではなく、高速アクセスのためにアプリをオンラインでアップロードしました(BetterTouchToolを介してこのアプリをアクティブ化するだけです)。したがって、身元不明の出版社からアプリを実行したくない場合は、上記の手順に従って独自のアプリを作成してください!
ファイルへのリンク:https : //www.box.com/s/e2461c91e30e0af025e7
それが私を助けたので、それが誰にも役立つことを願っています:)
これは、閉じるボタンをクリックしてメインウィンドウを閉じた後でも機能します。
if application "KeyboardViewer" is running then
tell application "System Events" to number of windows of process "KeyboardViewer"
if result is 0 then
quit application "KeyboardViewer"
delay 0.1
launch application "KeyboardViewer"
else
quit application "KeyboardViewer"
end if
else
launch application "KeyboardViewer"
end if
キーボードビューアをAppleScriptで開いた場合open -a KeyboardViewer、またはメインウィンドウを閉じた場合、プロセスは開いたままで、約0〜15%のCPUを使用し続けます。入力メニューから[キーボードビューアを表示]を選択した場合は発生しません。したがって、より良いオプションは、メニュー項目をクリックすることです。
tell application "System Events" to tell process "SystemUIServer"
tell (menu bar item 1 where description is "text input") of menu bar 1
click
click (menu item 1 where title ends with "Keyboard Viewer") of menu 1
end tell
end tell
どちらのスクリプトも、アクセシビリティ設定ペインで支援デバイスを有効にする必要があります。
これは一筆書きのショートカットではありませんが、メニューバーの右側にある「ステータスメニュー」アイコンにフォーカスを設定するための「非マウス」ソリューションはFn+ Ctrl+ です。(セクション4)F8
矢印を使用すると、キーボード設定アイコンと表示/非表示オプションに移動します。Fn+ Ctrl+ を入力するF8と、メニューバーの右半分にある[ステータスメニュー]アイコンの最も左側にあるアイコンが強調表示されます。選択したら、を使用しRight Arrow →て目的の場所に移動します。を使用しDown Arrow ↓てメニューを開き、必要なオプションを選択します。ことに注意してくださいOptionキーは「ステータスメニュー」の一部で異なるメニューオプションが利用できるようになります。
注目すべきは、Fn+ Ctrl+ F2は左側のアップルメニューアイコンactivateをアクティブにすることです。そこからRight Arrow →、アプリケーションメニューにアクセスできます。これらのオプションは、システム環境設定>>キーボード>>ショートカット::キーボードで利用できます:
ファンクションキーの設定方法に応じて、これFnはオプションです。
macOS Sierraでは、Siriを使用してこれを支援することもできます。System Preferences >> Siri :: Keyboard Shortcutから選択したキーボードショートカットでSiriを起動します。例:Option+Spacebar
...「キーボードビューアを有効にする」と言う
...そして出来上がり:
残念ながら、Siriはキーボードビューアを閉じず、Command⌘+w
Automatorですべてを実行できます。
次は、キーボードを閉じることです。
「その他」を選択し、/ System / Library / Input MethodsのKeyboardViewerファイルに移動します
「キーボードを終了」などの名前で保存します。試して。
これで、オープン用とクローズ用の2つのファイルが作成されます。
必要なのは、マウスボタンを関連付けてこれらの2つのファイルを起動することだけです!
たとえば、Microsoft Bluetooth Notebook Mouse 5000とそれを使用しています
10.9.1でうまく機能します
アクティビティモニター、KeyboardViewer.appの起動元
Finderの場所: /システム/ライブラリ/入力方法/ KeyboardViewer.app。
通常の使用:メニューバーから開き、マウスホバーから閉じて、(x)閉じるボタンをクリックできるウィンドウボタンを表示します。メニューバーパネル、システム環境設定、キーボード、キーボードタブを有効にするには、メニューバーでキーボードと絵文字ビューアを表示を選択します。
KeyboardViewerアプレットは制限的な動作を示します。
次のAutomatorスクリプトは、1回のクリックで KeyboardViewer.app を開閉するアプリケーションとして保存でき(アクティビティモニターはこの開閉アクティビティも表示します)、Dockに配置したときに適切に機能します。
Automator:New、Application、AppleScriptを実行、このスクリプトを保存
-- see above post, Render
on run {input, parameters}
if application "KeyboardViewer" is running then
quit application "KeyboardViewer"
else
activate application "KeyboardViewer"
end if
return input
end run
-- icon /System/Library/PreferencePanes Keyboard.prefPane/Contents/Resources/Keyboard.icns
残念ながら、これはキーボードショートカットを追加しません。ただし、ワンクリックの回避策を提供します。Automatorを使用してキーボードショートカットを追加する方法がいくつかあります。一般的なショートカットスクリプトは次のようになります(ただし、組み込む方法はわかりません)。
tell application "System Events"
set application "KeyboardViewer" to keystroke "K" using control down
end tell
(MP 6,1上のmacOS Sierra 10.12.6)