I have an application with a batch mode functionality. It does a set of conversions and displays a progress window connected to the main window.
The progress window displays something like “converting x of y”.
The progress window is opened and closed every time to make it possible to cancel after one (or more) of the conversions.
Every time the progress window is closed/opened my application comes to the foreground. I don’t want that to happen. Once the conversions start I want my main window to “deactivate”. I don’t want to hide it as I (and other users) might want to switch to it to see how far it is.
I’m looking for something like:
tell application “blahblah” to inactivate
perform conversions
tell application “blahblah” to activate.
Also: When minimized, it “maximizes” again on progress window activity.
I know the frontmost function but is there also something like “set backmost”.
Does anyone know how to accomplish this?
I’ve used Call Method to set windows to an upper level of window drawing to bring them to the front. You could use that to set it to the background/desktop picture level. But it would always be obscured and perhaps unreachable until the progress of your process is done and the app sets itself back to “normal app level”.
call method “setLevel:” of window “main” with parameter 3
this sets the app higher than all other apps (like iTunes floating on top of everything). Check the cocoa documentation for the explanation of levels
Thanks for your reply. I do not exactly understand what you mean but I will investigate it.
In the mean time I found a work-around. I left the topic open as I hoped that someone would have an answer and I “came back” today.
The work around is:
Find the current most foreground application
initialize/modify/quit progress panel (my application automatically jumps to the foreground: default applescript behavior)
Set previous forground application back to foreground
And in Applescript:
tell application "Finder"
set Name_App to item 1 of (get name of processes whose frontmost is true)
end tell
"initialize/modify/quit progress panel with text and a progress bar or a barber pole"
if "<My application name>" is not in Name_App then
tell application "System Events" to set frontmost of process Name_App to true
end if
Where is your application name without the .app extension.
This has the effect that upon calling one of the progress panel functions my application automatically swaps to the foreground (applescript default behavior) and is immediately swapped back within a split second and the previous application has focus again. I still don’t like it but some of my users really do like it as they can “count the steps” without having to look at the application.