NON-Think Windows & AppleScript (e.g., Preferences, Log, Activity, Download Manager)

By chance, does anyone know how to use DEVONthink’s AppleScript dictionary to determine if the front window isn’t a think window? In other words, how would you determine if the frontmost window is one of the following: Preferences, Log, Activity, or Download Manager?

The reason I ask is that I have script that I use to close windows which operates a little differently from the standard one. However, it doesn’t work properly when the frontmost window isn’t a think window (e.g., document or viewer window).

As a temporary work around, I added something to the script that relies on System Events. But it’s incredibly hacky. For simplicity, I’ve included a test version of it below (which is not how it’s actually being used). As you can see, it relies on the names of the windows and then uses a GUI-based approach to close the window—both, of which, are likely to cause problems. In addition, from what I can tell, System Events has issues getting the Activity window’s name.

In any case, if anyone has any better suggestions for tackling the problem—preferably with DEVONthink’s AppleScript dictionary or one doesn’t rely on window names or clicking a menu command—I’d be extremely grateful to hear your thoughts. Thanks in advance for any help you can lend!

tell application "System Events"
	set theWindowsSpecial to {"General", "Editing", "WikiLinks", "Sorter", "Files", "Colors", "Web", "RSS", "Data", "OCR", "Imprinter", "Sync", "Download Manager", "Log"}
	set theWindowFrontName to (name of front window of process "DEVONthink 3")
	if theWindowFrontName is in theWindowsSpecial then
		tell application id "DNtp" to activate
		tell process "DEVONthink 3"
			perform action "AXRaise" of window 1
			click menu item "Close" of menu "Window" of menu bar item "Window" of menu bar 1
		end tell
	end if
end tell