Problems with a volume slider

The code:

on action theObject
	set lVolumeSlider to (integer value of slider theObject)
	set lButtonState to (integer value of button "btn_Prefs_AudibleAlert" of tab view item "tab_Prefs_Other" of tab view "tab_View_Pref" of window "win_Preferences")
	set lVolume to round lVolumeSlider rounding as taught in school -- To nearest whole number
	
	if lButtonState = 1 then
		set output volume to lVolume
		beep
		
	else
		tell user defaults to set contents of default entry "mkp_vol_VolumeControl" to 0
	end if
	
end action

The error:

The question:
Thinking that a slider would be a slick addition to the user interface I set about trying to script one, with frustrating results. In the above script “btn_Prefs_AudibleAlert” is a checkbox button indicating whether an audible alert is true or false and “mkp_vol_VolumeControl” is the user default value for the slider. What I am trying to do is set the application volume to the integer value of the slider but hopefully leave the system volume level where it is (ie: setting the volume in iTunes does not affect the overall volume of other applications). I have read several previous postings and tried several variations all to no avail.

Is there a simple answer to what I am doing wrong?

Thanks in advance.

Hi,

in this line

set lVolumeSlider to (integer value of slider theObject)

thisObject is a reference to an object, so just omit slider

set lVolumeSlider to integer value of theObject

Even though I would have felt like such a TOOL if that was all it was, I was really hoping… Unfortunately it just provides a new error:

ouvl = output volume? So is it telling me that it can’t set the output volume to the variable? should it be set ‘as integer’?

folks, read the dictionary

set volume number ¬
output volume integer ¬
input volume integer ¬
alert volume integer ¬
output muted boolean


set volume output volume lVolume

Thanks for that Stefan, but I DID read the dictionary. Apparently my comprehension wasn’t up to your standards, sorry.

On re-reading this it sounded snarky, which granted, it may have been a little but after the HOURS of googling, reading previous posts on this and other sites, and yes, checking the dictionary I came hat in hand for help feeling like an idiot. I really DO appreciate the help Stefan, just not the assumption that I’m a lazy douchebag. :smiley:

Check that yourself.

«class ouvl» -- output volume

What is “it”?

:lol::lol::lol: . :confused:

I was just kidding :wink: