Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Toggle muting by AppleScript

Toggle muting by AppleScript
Thread Tools
Palmgren
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 19, 2004, 09:21 AM
 
I use crontab to call a AppleScript (ScriptEditor 1.9, OS 10.2.8) that wakes me up. The script sets the sound volume in Finder, but if it has previously been muted, adjusting the volume does not diable mute. Is there a AppleScript command to toggle muting in Finder on/off?
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Oct 19, 2004, 10:20 AM
 
I remember that 10.2.8 had some beta System Event Applescript capabilities. I don't know if the following script will work in 10.2.8, but it does work as advertised in 10.3 and higher.[php]tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events"
tell process "System Preferences"
set muteValue to get value of checkbox "Mute" of group 1 of window "Sound"
if muteValue = 1 then
click checkbox "Mute" of group 1 of window "Sound"
end if
end tell
end tell

tell application "System Preferences"
quit
end tell[/php]
You need to be sure that 'Enable Assitive Devices' in the Universal Access System Preference is on.

C-
     
Palmgren  (op)
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 19, 2004, 02:58 PM
 
It almost works... The script opens up the Sound panel of System Preferences but the script fails at:
set muteValue to get value of checkbox "Mute" of group 1 of window "Sound"
saying that it expected end of line af 'checkbox'. If I delete that statement the same error message appears at:
click checkbox "Mute" of group 1 of window "Sound"
Any suggestions?
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Oct 20, 2004, 08:55 AM
 
Is Assitive Devices check in the Universal Access pref pane? It has been a year since I worked in Jaguar and do not have a machine with Jag on it Is there the Mute checkbox in the Sound Pref Pane?

It may be that Panther has the GUI scripting capability and Jaguar does not. Launching System Preferences and then activating the Sound pane is not GUI scripting, clicking the checkbox is.

Bill Cheeseman has written a great UI scripting tool, UI Browser. You could d/l that application and use the demo to delve into what GUI scripting is capable of on your machine.

C-
     
TimmyDee51
Mac Elite
Join Date: Mar 2000
Location: Cambridge
Status: Offline
Reply With Quote
Oct 20, 2004, 01:25 PM
 
You actually don't have to open the System Preferences to set the volume if System Events is working. Try this:

Code:
tell application "System Events" set volume 8 end tell
Setting the volume to 8 should be the max, but you can adjust it to any numerical value between 0 (mute) and 8 (max).

edit: cleaned up the code appearance a bit
Per Square Mile | A blog about density
     
Palmgren  (op)
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 20, 2004, 06:03 PM
 
Originally posted by suthercd:
Is Assitive Devices check in the Universal Access pref pane?
Yes, it is checked.
     
Palmgren  (op)
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 20, 2004, 06:05 PM
 
Originally posted by TimmyDee51:
You actually don't have to open the System Preferences to set the volume if System Events is working. Try this:

Code:
tell application "System Events" set volume 8 end tell
Well, thats what I did already, but if I left the computer muted setting the volume does not make it speak up.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:01 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,