Make a window in AS studio inactive for a time while a script runs

I have an need to make a window in appleScript studio inactive for a time while a script runs.

What’s happening is that while the progress bar is running in another window - a user can click on something else in another window (of the same app) and it will cancel/generate an error. IS there any way to make a window inactive? I’m aware that you can make the window hide or invisible - but that is a cheesy way to do it in my opinion.

Thanks in advance.

First, you’ll have to make the window (the one you want to limit activity to) a panel, instead of a window object. Then you can launch the panel, either as a separate window or as a sheet attached to your main window. Panels by nature require that they are released to allow other windows to gain focus, which allows you to launch it and wait until the panel is closed (automatically or manually), before the user can successfully click anything else.

…Make sure you use some sort of code to actively close the panel after you are done with it. I included a bit of code below that closes the panel when a button is clicked in the panel. You could use any other event to close the window, you just have to make sure to do it implicitly with the ‘close panel’ command. I also disabled the panel’s close button (in IB) so the user can’t close it that way. If you close the panel without issuing the ‘close panel’ command, the window disappears, but the app will not return focus to any other window object and you will be stuck unable to do anything but force quit the app.

on clicked theObject
	if (name of theObject is equal to "ShowThePanel") then

		set theSensitiveWindow to window "Window2"
		display theSensitiveWindow
	else if (name of theObject is equal to "CloseThePanel") then
		close panel (window of theObject)
	end if
end clicked

Here’s apple’s info about displaying panel’s: … display

Hope this help…

I keep my main window a regular window and then when something needs to process, I open a panel window attached to the main window with a progress bar. In this way the main window is still visible but inactive. You could also use a call method I think:

call method "disableFlushWindow" of window "main"
--do something
call method "enableFlushWindow" of window "main"


Thanks guys - I didn’t realize that panels could do this…or that they were meant to - my script works great now.