I’m trying to talk to an application, with it still being not too visible (unless it was already open, I’ll worry about that check myself). Right now, simply talking to it will open it if its closed, and it gets a weird layer position, that its always second-most upfront (leads to quirky errors with Expose). Anyway, what I’d like it to do is hide as soon as I talk to it. I can’t tell it to keystroke command-H, because it has to be upfront to do that. I can’t tell it to click menu item ‘Hide’ cause thats dependent on the application name (contains a version number, so I can’t hardwire the application name). I’ve tried telling System Events to "tell application “System Events” to set visible of (get processes whose name begins with ““) to false”, but this is the error I get: Can’t set visible of {«class pcap» "” of application “System Events”} to false. (the ___ I’m putting in is correctly finding the app, I think). Any ideas? Is there any opposite of the “activate” command?
You are getting here a list, that’s why you see the error. Try this instead:
tell application "System Events" to set visible of (first process whose name begins with "___") to false
There are times when getting a value won’t work, Xonk. This is one of them.
What you want to do here is to set the visible of an application process to false. However, as jj rightly points out, the statement “get processes whose name…” returns a list, which System Events can’t act upon directly. Instead, try:
tell application "System Events" to set visible of processes whose name begins with "___" to false
Better still, you could be even more specific:
tell application "System Events" to set visible of first process whose name is "___" to false
Thanks a bunch, works great.
Is there a way to do this on a remote machine? I’ve tried it like this but get an error.
tell application "System Events" of machine remMachine
set this_app to some item of (get processes whose name = "Safari")
set visible of this_app to false
end tell
I get “The variable processes is not defined.” re: processes.