Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not work with this automator workflow #1

Open
websitefingerprinting opened this issue Jul 4, 2020 · 5 comments
Open

Can not work with this automator workflow #1

websitefingerprinting opened this issue Jul 4, 2020 · 5 comments

Comments

@websitefingerprinting
Copy link

Hi! I tried to use this workflow but it did not work. The log was:
can't obtain “window "Sidecar" of application process "System Preferences"

I am not familiar with Applescript and I have no idea how to fix it. Do you have any idea where the problem is?
Thank you so much!

@rauls4
Copy link
Owner

rauls4 commented Jul 4, 2020

Do you see the sidecar icon in the System Preferences window?

@websitefingerprinting
Copy link
Author

@rauls4 Yes! Actually, after I ran this workflow, the sidecar panel was opened, then I got that error message. My OS is Catalina 10.15.5

@rauls4
Copy link
Owner

rauls4 commented Jul 5, 2020

Hmm. I am not sure what the deal is (I assume you are running the OS in English). AppleScript is basically complaining that there is not "Sidecar" window open, if you see a window very much like this one then it should work. If AppleScript still complains that it cannot see it I am not sure there is much I can do about it.

side

@GJRobert
Copy link

@websitefingerprinting can you indicate that which language are you using?

@rauls4 I also encounter this problem and my OS language is Chinese of Taiwan (zh-tw), therefore my Sidecar window has got a localized title in Chinese ("並行") in my case.

Is there a workaround?

@GJRobert
Copy link

GJRobert commented Jul 28, 2021

I have found a way to list all UI item in my "Sidecar" window
ref. user interface - Use AppleScript to list the names of all UI elements in a window (GUI scripting) - Stack Overflow

Should I change all UI strings in this workflow to localized terms?

[Update] Yes! After localizing all the UI strings, this workflow works like a charm. And also I have solved #3 by making this workflow an application, not only a Service, so that no any other app needs permission granted. I love this workflow of yours @rauls4 and bravo and kudos to Apple automation!

Here is my script for zh-tw users, for macOS 11.4 or versions with the same Sidecar UI:

tell application "System Preferences"
	activate
	set the current pane to pane id "com.apple.preference.sidecar"
	get the name of every anchor of pane id "com.apple.preference.sidecar"
	delay 1
	tell application "System Events"
		set target_button to a reference to (first button whose name is "中斷連線") of (window "並行" of application process "System Preferences")
		if target_button exists then
			click target_button
		else
			click menu button "選擇裝置" of window "並行" of application process "System Preferences"
			count menu items of menu of menu button "選擇裝置" of window "並行" of application process "System Preferences"
			select item 1 of menu button "選擇裝置" of window "並行" of application process "System Preferences"
			key code 125
			key code 76
		end if
	end tell
	quit
end tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants