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

applescript fails when interacting with GUI app #3

Open
acdha opened this issue May 20, 2015 · 3 comments
Open

applescript fails when interacting with GUI app #3

acdha opened this issue May 20, 2015 · 3 comments

Comments

@acdha
Copy link
Member

acdha commented May 20, 2015

From @GoogleCodeExporter on May 20, 2015 16:39

What steps will reproduce the problem?
1. Call applescript that does "tell application xyz" (where xyz is a GUI
application) from a handler.  crankd must be running via launchd.

What is the expected output? What do you see instead?
Expected Output: result from applescript
Actual Output: applescript fails because it doesn't have a connection to
WindowServer


What version of the product are you using? On what operating system?
Version: current posted version
OS: 10.5.8


Please provide any additional information below.
As a work-around, I've wrapped crankd in a Platypus app that runs on login
after 30 seconds.  Is it possible for crankd to obtain the proper
WindowServer handle from launchd/somewhere and execute in that context?  I
don't even know where to start (patch-wise) if it is possible so I can't
really help with this (except testing).

Original issue reported on code.google.com by [email protected] on 10 Dec 2009 at 9:37

Copied from original issue: #3

@acdha
Copy link
Member Author

acdha commented May 20, 2015

From @GoogleCodeExporter on May 20, 2015 16:39

I'll have to check but I'm fairly certain that this would require running in a 
WindowServer 
context - how are you running crankd? I think if it's set up as a launch agent 
and the 
session type is "aqua" you should be able to do this. Otherwise we might need 
something tricky.

Original comment by [email protected] on 10 Dec 2009 at 9:55

@acdha
Copy link
Member Author

acdha commented May 20, 2015

From @GoogleCodeExporter on May 20, 2015 16:39

I had been running it as an agent but I don't think I had the session type set 
at
all.  I set the session type to Aqua and reloaded the plist, everything worked 
great.
 You can close this issue.  It would probably be a good idea to make a note of this
in the README or add -S Aqua to the install script's launchctl load.

Original comment by [email protected] on 10 Dec 2009 at 10:23

@acdha
Copy link
Member Author

acdha commented May 20, 2015

From @GoogleCodeExporter on May 20, 2015 16:39

One more comment about this: I had been running the applescript as an 
application,
saved as an app bundle with LSUIElement=true, so that it would pick up on the 
right
context because the open command figures that out.  It caused a nasty old-style
pinwheel every so often so I switched back over to osascript.  Immediately, I 
hit the
same context problem that was supposed to be fixed by -S Aqua.  I fixed it by 
calling
my script like this: "sudo /bin/launchctl bsexec $PIDOFITUNES /usr/bin/osascript
/path/to/script.scpt".  I really don't like running it with sudo but that's the 
only
way launchctl's bsexec will work.  Maybe something tricky might have to be 
done?  It
might be that context switches of this nature are strictly limited to root, I've
never developed anything that low level so I don't really know.

Original comment by [email protected] on 11 Dec 2009 at 12:37

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

No branches or pull requests

1 participant