Possible to Suppress Dialog Boxes?

Good Morning,

I was wondering if it’s possible to have a script suppress any dialog boxes that may arise.

I have the following script that organizes all of my Finder windows and minimizes everything on my screen…


tell application "Finder"
	set window_list to windows
	set base_bounds to {3, 50, 300, 300}
	set v_increment to 30
	set h_increment to 0
	set window_list to reverse of window_list
	repeat with a_window in window_list
		set the current view of a_window to list view
		set bounds of a_window to base_bounds
		set item 1 of base_bounds to (item 1 of base_bounds) + h_increment
		set item 3 of base_bounds to (item 3 of base_bounds) + h_increment
		set item 2 of base_bounds to (item 2 of base_bounds) + v_increment
		set item 4 of base_bounds to (item 4 of base_bounds) + v_increment
	end repeat
end tell
tell application "System Events"
	keystroke "h" using {command down, option down}
end tell
tell application "System Events" to tell process "Finder" to set visible to true

As you can imagine, something like this gets hung up when a dialog box appears. Is it possible to suppress these dialogs without knowing which application they belong to? I’m trying to make this process as automated as possible.

Thanks!!
Zach

Hi Zach,

I’m not sure what issues you are coming across. Try this version.

tell application "Finder"
	set window_list to windows
	set base_bounds to {3, 50, 300, 300}
	set v_increment to 30
	set h_increment to 0
	set window_list to reverse of window_list
	repeat with a_window in window_list
		set the current view of a_window to list view
		set bounds of a_window to base_bounds
		set item 1 of base_bounds to (item 1 of base_bounds) + h_increment
		set item 3 of base_bounds to (item 3 of base_bounds) + h_increment
		set item 2 of base_bounds to (item 2 of base_bounds) + v_increment
		set item 4 of base_bounds to (item 4 of base_bounds) + v_increment
	end repeat
	tell application "System Events"
		set visible of every process whose name is not "Finder" to false
	end tell
end tell

The alternative would be to add a ‘delay’ after the Cmd-Opt-H

Best wishes

John Maisey
www.nhoj.co.uk