Hi all
I am taking my first steps into scripting an application and it works as i had hoped except it will not quit when told to, either with apple+q or file, quit.
Here is the code, can anyone see why that would be, my thought was that is is due to the loop, but i can’t see another way to acheive what i am doing.
global qlab_status
set qlab_status to "open"
tell application "Finder"
set the visible of process "QLab Focus" to false
end tell
repeat
delay 5
tell application "Finder"
if exists process "QLab" then
tell application "QLab"
activate
end tell
else
set qlab_status to "closed"
end if
end tell
end repeat
Cheers
Gareth
Model: Macbook Pro
Browser: Firefox 2.0.0.3
Operating System: Mac OS X (10.5)
I think you want to be using a stay-open application and an “on idle” handler instead of a repeat loop. Here’s some links to tutorials about this handler…
http://applescriptsourcebook.com/viewtopic.php?pid=60340
http://macscripter.net/articles/482_0_10_0_C/
Hi
Sorry it’s taken so long for me to reply, but i will give this a go today and see if i can work it out with the on-idle handler.
Cheers
Gareth
Here’s the basic form for an on idle loop. Make sure you save it as a “Stay Open” application.
global qlab_status
on run
set qlab_status to "open"
end run
on idle
tell application "Finder"
set the visible of process "QLab Focus" to false
end tell
tell application "Finder"
if exists process "QLab" then
tell application "QLab"
activate
end tell
else
set qlab_status to "closed"
end if
end tell
return 5
end idle
Cheers matt,
I had actually managed to work it out. Now i just have to work out how to save user preferences in Xcode/Interface Builder.
Any help greatly appreciated!!
Cheers
Gareth
That’s so weird. I just spent the first half of the day yesterday doing that to my AS Studio app. I basically used this post:
http://bbs.applescript.net/viewtopic.php?id=13212
Scroll down to HHAS’s post at the bottom. That should get you started.