I have an application that I'm running on OSX, and I have this AppleScript that was working on 10.9, but it seems that it does not work on 10.10
try
tell application \"System Events\" to set processPath to application file of application process "My Application"
return POSIX path of processPath
on error errMsg
return ""
end try
When I run this in the AppleScript editor, it gives me the error that "System events got an error: Can't get application process "My Application".
I checked the Activity Monitor, and indeed, there is no process called "My Application" in there. The associated process with my application is now registered by the name "SWT". I confirmed this by killing the "SWT" process, and it killed my app.
My question is, what has changed from 10.9 to 10.10, and why is my application registered as SWT process, instead of "My Application", as it was in 10.9? Additionally, what changes do I need to make in order to register the process by the name of "My Application" (something which I presume will work)?
Update: I tried setting the Application name to "My Application", which worked, and now I am able to see a process called "My Application" in the Activity Monitor, but the AppleScript is still not working. The error that I'm getting now is:
Can’t make alias \"Macintosh HD:Library:Java:JavaVirtualMachines:jdk1.7.0_71.jdk:Contents:Home:bin:java\" of application \"System Events\" into the expected type
Any thoughts on this?
I might have misunderstood your question but if you just want to change your app name from SWT to your application name try this
Display.setAppName("My app name");
This should be set before any display class is initialized.
Related
I have used a simple AppleScript that toggles between active and inactive macOS Mail accounts that has worked peachy up until macOS 10.15 Catalina. I generally trigger this through the Script Menu to hide one account and enable another, but have also tried by simply opening and running it. Either way, it's now failing with the error:
Blockquote error "Mail got an error: AppleEvent handler failed." number -10000
Here's the script: what am I missing here to having this work in Catalina?
tell application "Mail"
set enabled of account "Mac" to false
set enabled of account "Windows" to true
end tell
Previously to the Yosemite update, I used this Applescript to control my Spotify.
Everything worked as a charm when I ran /usr/bin/osascript /Users/jdrummond/SpotifyControl.scpt play/pause.
Now that I have updated my OSX to Yosemite, I keep getting this when I run the same command:
/Users/jdrummond/SpotifyControl2.scpt:1217:1222: script error: Expected end of line, etc. but found identifier. (-2741)
So I tried to create a simple Applescript to interact with Spotify:
using terms from application "Spotify"
tell application "Spotify" to play
end using terms from
But I'm also getting an error:
What am I doing wrong and how to interact with Spotify on Yosemite? Anything changed?
This issue was reported to Spotify and will be fixed in the next update to the desktop client (I'm a developer there and can verify that it has been fixed).
Currently, the following simple script is working for me on OS X 10.9.5, Spotify 1.0.3.101.gbfa97dfe
tell application "Spotify"
playpause
end tell
I saved it as an app in other to use with my Microsoft Keyboard, so that the play/pause button launches the simple app that plays/pauses.
Spotify destroyed the ability to use AppleScript very recently with their latest idiotic update. It's not Yosemite, it's Spotify.
On earlier versions of OS X an applescript like :
tell application "System Events" to tell process "Google Chrome"
get position of window 1
click at {598, 260}
end tell
worked.
But it doesn't work anymore on Mavericks. Is it some kind of broken ?
PS: AppleScript Editor has access to the Accessibility.
Yes, it is. There's some discussion on Apple's site.
Yes. When I try to run
tell application "System Events" to click at {500, 500}
it works in a 10.8 VM but results in an error like System Events got an error: Can’t make {500, 500} into type list in 10.9.
You can use MouseTools instead:
do shell script "MouseTools -x 500 -y 500;MouseTools -leftClick"
This issue has been fixed on Yosemite (tested on Beta 5 and GM).
I wrote reboot scripts for both Snow Leopard and Lion to quickly boot between them.
SL script works fine, but it seems Lion has some additional security feature that requires a password when script is run.
I get a dialog requesting my password that says:
"WorkflowServiceRunner.xpc wants to make changes. Type your password to allow this"
Is there a way in code to send pw info so this runs automatically?
You mean you had to type your password because of tell application "Finder" to restart?
In that case, you can use
do shell script "killall Finder"
tell application "Finder" to open
I have a Mono application that should not show on the dock, but will occasionally show a window. I want neither menu bar nor dock icon to show for this application. I have my application wrapped in an app bundle, and my info.plist file has the LSUIElement set to "1". This does not seem to be hiding my application from the Dock.
I have tried also calling osascript with the following info in a Process.Start:
osascript -e 'tell application "System Events" to set visible of process "myapp" to false'
This returns a System Event error code: -10006. Thus far, I've had no luck finding out what that means.
I've also tried all the standard Hide() and Visibility = false stuff inside Mono.
Anyone found a workaround for this, or have an idea a direction I can look in? For the most part, working in Mono has been straightforward .Net coding, but this has me stumped.
Well, after a fair amount of work, I figured out a better way to do this. I am generating a Silverlight + mono application targeting OSX. I needed to get both launching from the same button press.
Solved it with a bash script command from within the bundle that the Silverlight OOB installation process creates, and simply distributed the created bundle, with some rsync commands.
The line that launches the server bit (created using Mono's macpack tool):
open MyApp.app &
The line that then launches the Silverlight OOB app normally:
./Silverlight $# &> /dev/null
The '$#' bit passes all the initial arguments into the Silverlight executable in the OOB app. Means you have to play with the Info.plist to make it launch your own launcher, so your 'Silverlight' executable doesn't get overwritten on a Silverlight update, but seems to work quite well.
This is what you are looking for: http://uselessthingies.wordpress.com/2008/05/18/an-app-without-dock-icon-and-menu-bar/
tl;dr: Package your .app, and in your app's Info.plist add <key>LSUIElement</key><string>1</string>.