Can't terminate can't close can't performClose Help please!!

Hi Guys

I gotta be honest i’m really struggling with this ASOC stuff.

Anyhow my problem is how do i get my application to quit, I think i need the terminate command but its not working for me.

So then i picked up something from a post on here where i can use “applicationShouldTerminateAfterLastWindowClosed”
but it only works when i close the window manually i can’t implement a “close” or a “performClose” before the
“applicationShouldTerminateAfterLastWindowClosed” kicks in.

What i’m trying to do is the simplest of things:

  1. Drop a folder on the app— Sorted that Part
  2. A window opens with a process bar (just the barber pole effect)— Sorted that Part
  3. I have a collate script which removes duplicates and a few other bits and bats etc. Sorted That Part
  4. When it finishes the app quits window with progress bar is gone— Just can’t get it to work and have run out of ideas

Any help would be appreciated.

Thanks

One way is to type “quit”

Sorry Craig that isn’t working either.

i’ve had to use system events to quit it, just seems a bit untidy really though.

I’m not sure I understand the problem, but you can try:

tell current application’s NSApp to terminate_(me)

This is quite the messy way to quit an app
but you can run this below. It will find the pid of that appname and kill it

I used repeat 2 times because it sometimes grabs the PID of the grep that greps your app name


repeat 2 times
do shell script "ps aux |grep myappname(spaces\\ must\\ be\\ double\\ escaped).app | grep psn | awk '{print $2}'|while read line; do kill $line; done"

end repeat

Hi Guys

Thanks for all your help and input!

Shane your solution worked in the end, although i have to say my script as a first attempt isn’t very good.

But you gotta start somewhere.

Thanks again everyone.