2

スティッキーキーがオンになっている場合にのみ、スクリプトが5キー(マウスの左クリックをトリガーする)をスパムできるように、Applescriptを介してマウスキーの状態を確認できるようにしたいと思います。これにより、ショートカットを使用してスティッキーキーをオフにする(optionキーを5回押す)スクリプトをオフにすることができます。

これまでの私のコード:

on idle
    tell application "System Preferences"
        activate
        set current pane to pane id "com.apple.preference.universalaccess"
    end tell

tell application "System Events"
    tell process "System Preferences"
        click menu item 6 of menu 1 --pseudocode
        if value of checkbox "Enable Mouse Keys" is 1 then
            key code 87 --press the "5" key, triggers mouse press
        end if
    end tell

    end tell

    set rn to (random number from 0.8 to 1.0) as text
    return rn
end idle

私の問題はclick menu item 6 of menu 1、アクセシビリティペインの「マウスとキーボード」セクションにアクセスするための回線と方法にあります。それがまだ明らかでない場合、私はapplescriptの経験がほとんどありません。> _>

ここに画像の説明を入力してください

4

2 に答える 2

1

prefpaneを開く必要がなくなります。ユニバーサルアクセス設定ファイルから値を直接読み取ることによって

set plistFile to (path to preferences from user domain) & "com.apple.universalaccess.plist" as string -- Get the  Universal Access plist path of this use
tell application "System Events" to set mouseDriver to value of property list item "mouseDriver" of contents of property list file plistFile -- read only the value for mouse keys

オンかどうかに応じて、trueまたはfalseを返します。

plistを直接読み取る際の注意点の1つは、ユーザーインターフェイスで行われた変更がファイルに書き込まれるまでに約5秒かかる場合があることです。

あなたはここでプロパティリストアイテムについてもっと読むことができます

于 2013-03-09T14:48:06.660 に答える