PrefPane selection syntax

Hi
New to the forum. First entry.
On the Forum was a question about opening a Sound PrefPane and Michel Bujardet showed how to do it.
My question is once the PrefPane is open what is the code that is used to make selections within the PrefPane on the Menus and devices. Also does the PrefPane have to be opened to make selections.
Thanks

Dim s As Shell
  s = New Shell
  s.Execute ("open -b com.apple.systempreferences /System/Library/PreferencePanes/Sound.prefPane")
  s.Close

No Reply! Is Xojo not able to do this or is it because I am listed as not verified.

you open it with a shell, Xojo can not control other apps.

by the way, if you want to change something in the sound settings you must not open the PrefPane window.
You can do it with shell or applescript.

Do not change the user’s settings.
They set them that way for a reason, who are you to tell them otherwise?

Have some respect for your user.

[quote=281449:@Tim Parnell]Do not change the user’s settings.
They set them that way for a reason, who are you to tell them otherwise?

Have some respect for your user.[/quote]

amen!

Sometimes there is simply no way.

What are you trying to achieve exactly ? What is the setting you want to change ?

Thanks for the info. Perhaps I should explain what I am trying to do. I am trying to code a program just for my own use to Open the sound panel in the Preferences. With the Shell code I get the sound panel open , then I want to be able to select “Output” in the upper menu then select a device for sound output. I will want to select between “Line Out” and my Bluetooth Headset.
I could not find any examples on how to make selections in any preferences panels.
Any help is appreciated.

I doubt extremely much you can achieve that by simple means. As far as I know pref panes are not scriptable with AppleScript, and you certainly cannot achieve that with shell.

It is possible that this can be obtained by going deep into the system with a declare, but that goes far beyond simple. Or even documented.

[quote=281499:@Lewis Ponchek]…then I want to be able to select “Output” in the upper menu then select a device for sound output. I will want to select between “Line Out” and my Bluetooth Headset.
I could not find any examples on how to make selections in any preferences panels.
Any help is appreciated.[/quote]

look at this https://forum.xojo.com/conversation/post/183638

It’s for changing Input Device, but you can see how to do it

maybe it works for Output Device if you change (in ListInputDevices)

dim cmd as String = f.ShellPath + " input list"

to

dim cmd as String = f.ShellPath + " output list"

and in popInput - Change

dim cmd as String = f.ShellPath + " input '" + newdevice + "'"

to

dim cmd as String = f.ShellPath + " output '" + newdevice + "'"

I am new to Xojo and not sure I have explained what i want to do very well. The code from Axel was too much for my experience. Maybe I will try to accomplish my code with Applescript.
Thanks for all your help.

Buried in there is a simple way to switch input using a Shell to the command line utility audiodevice (included in the download).

Look in main > popInput > Change for where this happens.

This line gets the file of the utility (which was copied to Resources in a build step)

dim f as FolderItem = app.ExecutableFile.Parent.Parent.Child _ ("Resources").Child("audiodevice")

This line builds the command to execute. ShellPath specifies the utility to invoke followed by parameters.

dim cmd as String = f.ShellPath + " input '" + newdevice + "'"

This line actually executes the command which should change the input.

mshell.Execute cmd

See here Controlling sound output device with term… - Apple Community for the same thing changing output. Just change input to output.

Looking at the audiodevice utility source it’s calling (deprecated) Core Audio functions. You could replace this with direct declare calls but that’s extra hassle :stuck_out_tongue:

Thanks guys very much.
I will try this code again and see if it may work for me.