Can't get current pane #-1728 from current pane

Running Sierra

tell application “System Preferences”
set myIds to the id of every pane
set myAnchors to anchors of current pane
end tell

Obviously new to applescript.

I’m getting the following error:

error “System Preferences got an error: Can’t get current pane.” number -1728 from current pane.

Apologies for being able give a compiled script.
I’m in a secured environment.

Thank you in advance.

Model: mac mini
AppleScript: 2.5
Browser: Safari 537.36
Operating System: macOS 10.12

Hi. Welcome to MacScripter.

The current pane in System Preferences is the pane (eg. General, Mouse, Network) that’s currently showing. It sounds as if you may not have a pane showing when you get the error. Is that the case?

MacScripter has its own [applescript] and [/applescript] tags for AppleScript code. If you put your code between these, or select it in the posting window and click the “Applescript” button just above, it comes out looking like this:

tell application "System Preferences"
	set myIds to the id of every pane
	set myAnchors to anchors of current pane
end tell

Ah I see. Yes, that works but my expectation was different.
I was expecting an output to the command line.
I’m trying to ascertain version information without going into the machine using Remote Desktop.
i.e., I’m using ssh trying to get Java versioning specifically.

Looking into the preferences Info.plist for Java, I see versioning information but it’s not the same when the actual preference is opened. I was hoping this would somehow resolve the disparity of the information.

Do you happen to know if this would be possible to do?

Thank you for resolving the other issue, esp. so quickly.

You lost me for a while. I couldn’t work out what scripting System Preferences had to do with command lines, Remote Desktop, or Java.

I take it you want to quiz a remote machine which has a non-standard Java installation for which there’s a pane in its System Preferences application ( menu → System Preferences…).

System Preferences doesn’t return any useful information via AppleScript beyond the names and identifiers of the panes and anchors. I don’t know the answer to your query, but it may be worth checking out system_profiler if you haven’t already done so. For instance, to get the Flash Player version on my machine:

set paneName to "Flash Player" -- Try changing this to the name of your Java preference pane.
do shell script "system_profiler SPPrefPaneDataType | sed -En '/" & paneName & ":/,/Version:/{/" & paneName & ":|Version:/p;}'"

However, I suspect that this returns the pane version, which just happens to coincide with that of the Flash Player. I get 1.7 for the Dock pane, but the Dock on this machine is version 1.8.

system_profiler can also return information about frameworks and other kinds of data.

I hope this has given you something useful to go on. Sorry I couldn’t be more help. :frowning: