如何使用AppleScript的更改preference窗格滑块值? [英] How to use Applescript to Change Preference Pane Slider value?

查看:244
本文介绍了如何使用AppleScript的更改preference窗格滑块值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的输入音量在输入的 声音在菜单下类别的系统preferences

I'm trying to create an AppleScript for setting the value of Input Volume of the Input category under the Sound menu in System Preferences.

怎样才能改变一个滑块的价值?

How does one change the value of a Slider?

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
if UI elements enabled then
    try
        tell application process "System Preferences"
            tell tab group 1 of window "Sound"
                click radio button "Input"
                select row 1 of table 1 of scroll area 1
                set selected of row 1 of table 1 of scroll area 1 to true
                set deviceselected to "Microphone"
                set slider "Input Volume" of group "Input Volume" of tab group "Input" to 0
                select row 2 of table 1 of scroll area 1
                set selected of row 2 of table 1 of scroll area 1 to true
                set deviceselected to "Microphone"
                set slider "Input Volume" of group "Input Volume" of tab group "Input" to 0


            end tell
        end tell
    end try
end if
end tell

这似乎并没有工作。
我使用也尝试过的辅助检查,以了解如何分层访问的元素以下列方式,

This doesn't seem to work. I also tried using Accessibility Inspector to find out how to hierarchically access the elements in the following manner,

 value of slider of group "Input volume" of tab group "Input" of window "Sound" 

这似乎没有任何要以正确的方式。

That doesn't seem to be a correct way either.

什么是错在这里?

修改

set content of slider "Input volume" of tab group "Input" of window "Sound" of tab group     1 of window "Sound" of application process "System Preferences" to 0
        --> error number -1700 from content of slider "Input volume" of tab group "Input" of window "Sound" of tab group 1 of window "Sound" of application  **

所以返回一个错误。我找不到错误code -1700任何说明,这是什么意思?

So it returns an error. I couldn't find any description for error code -1700, what does it mean?

推荐答案

您可以直接在不使用GUI脚本访问音量设置。这些命令是在AppleScript的标准添加osax。要查看音量设置,您可以更改使用本。请注意,它需要在命令中单词得到。

You can access the volume settings directly without using gui scripting. These commands are in the standard additions osax of applescript. To see the volume settings you can change use this. Notice it requires the word "get" in the command.

get volume settings

看着那些你可以看到输入音量是可以访问的音量设置之一的结果。这是一个从0到100的数值,以下是如何设置它...

Looking at those results you can see that the input volume is one of the volume settings you can access. It's a value from 0 to 100. Here's how you can set it...

set volume input volume 64

上面的命令是一个有些奇怪,因为没有到字的命令。你没有设置音量到东西所以它的奇怪。总之祝你好运!

The above command is a little strange because there is no "to" word in that command. You're not setting the volume "to" something so it's strange. Anyway Good luck!

修改下面是如何使用GUI脚本来访问它。此外,如果你想知道错误codeS,我贴一个脚本在这里 >。看帖子#9最新的版本。

Here's how to access it using gui scripting. Also if you want to know the error codes, I posted a script for that here. See post #9 for the latest version.

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events"
    tell application process "System Preferences"
        tell tab group 1 of window "Sound"
            click radio button "Input"
            get value of slider 1 of group 2
        end tell
    end tell
end tell

这篇关于如何使用AppleScript的更改preference窗格滑块值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆