Show view options

Thanks for the heads-up on that, Qwerty. I’ve never used the Inspector window myself, so I hadn’t realised it was a floater too. Since the View Options window has exactly the same name as the frontmost Finder window, it seems a good idea to pass that name as a parameter to the handler.

I’m not sure now exactly what KIA wants, so here I’ve commented out the lines that shut the windows again:

tell application "Finder"
	open (choose folder)
	set windowName to name of front Finder window
	(* set originalView to current view of Finder window 1
  set current view of Finder window 1 to icon view *)
	my allWindows(windowName)
	(* set current view of Finder window 1 to list view
  my allWindows(windowName)
  set current view of Finder window 1 to originalView *)
	-- close Finder window 1
end tell

on allWindows(windowName)
	tell application "System Events"
		tell application process "Finder"
			set frontmost to true
			if not ((first window whose description is "floating window" and name is windowName) exists) then keystroke "j" using command down
			repeat with rg in radio groups of window 1
				if (radio button "All windows" of rg exists) then
					click radio button "All windows" of rg
					-- keystroke "j" using command down
					exit repeat
				end if
			end repeat
		end tell
	end tell
end allWindows

That should probably be repeat while Finder window 1 exists. Here, a window here is any kind of window that belongs to the Finder. A Finder window is specifically a window that shows the contents of a folder.

I’m using System 10.4.6. There may be some differences due to that. Another way to close the floating window might be to change keystroke “j” using command down to click button 1 of window 1.

Hmm, it works for me, but I’m running 10.4.7 - I have no experience with 10.3.9 so although I suspect that is the problem, I am not certain.

I see a Finder window open, the View Options floating window opens. Then , very quickly, the “All windows” button clicks, the Finder window closes. A new one opens, the “View Options” floating window updates, the “All windows” button clicks. This continues until all open windows have been processed.

When I tested it, I made sure all windows were “This window only” and after the script they were “All windows.”

That’s not a mistake in the script. The window closes so the “View options” can be updated with the next window’s information. Maybe there has been a misunderstanding.

Do you want to leave the windows open after the “All windows” button is clicked?

Hi Nigel.

I haven’t had trouble with that so far, and I ran the script with multiple apps running and documents open, so I thought Finder could distinguish Finder windows - open folders - from other windows that belong to Finder. It’s better to be accurate, so I’ll remember this for the future.

Thanks,

j

This example on switches in position " All Windows ". Switchings do not occur. I need to switch in position " All windows ".

I already wrote, that there is no even a performance of a condition. The modified example does not do Display dialog “Ok” though there are no messages on mistakes:

tell application "Finder"
	open desktop
	set windowName to name of front Finder window
	(* set originalView to current view of Finder window 1

set current view of Finder window 1 to icon view *)
	my allWindows(windowName)
	(* set current view of Finder window 1 to list view

my allWindows(windowName)

set current view of Finder window 1 to originalView *)
	-- close Finder window 1
end tell

on allWindows(windowName)
	tell application "System Events"
		tell application process "Finder"
			set frontmost to true
			delay 3
			if not ((first window whose description is "floating window" and name is windowName) exists) then keystroke "j" using command down
			delay 3
			repeat with rg in radio groups of window 1
				if (radio button "All windows" of rg exists) then
					click radio button "All windows" of rg
					display dialog "Ok"
					-- keystroke "j" using command down
					exit repeat
				end if
			end repeat
		end tell
	end tell
end allWindows

I observe at the first start the open window " Show view options ", upon termination of work of a script. At the second start it is closed. From here a conclusion: the script does not understand, that the window " Show view options " is already opened. The script not correctly identifies this window and works not with it.

Whether there will be windows opened - a question minor.

Hi KIA.

I’m sorry that I’m not much help to you.

I ran the script you posted and the display dialog worked for me.

Did you enable GUI scripting in AppleScript Utility as well as in System Preferences? Maybe the script needs to be rewritten for 10.3.9.

I can’t think of a way to help. The script works on my computer, and I don’t know why it doesn’t work for you. Maybe it would help to see your event log. I’ll post mine for you to compare with yours.

I ran this script:

tell application "Finder"
	open (choose folder)
	set windowName to name of front Finder window
	(* set originalView to current view of Finder window 1
  set current view of Finder window 1 to icon view *)
	my allWindows(windowName)
	(* set current view of Finder window 1 to list view
  my allWindows(windowName)
  set current view of Finder window 1 to originalView *)
	-- close Finder window 1
end tell

on allWindows(windowName)
	tell application "System Events"
		tell application process "Finder"
			set frontmost to true
			if not ((first window whose description is "floating window" and name is windowName) exists) then keystroke "j" using command down
			repeat with rg in radio groups of window 1
				if (radio button "All windows" of rg exists) then
					click radio button "All windows" of rg
					-- keystroke "j" using command down
					exit repeat
				end if
			end repeat
		end tell
	end tell
end allWindows

and this is the Event Log:

And I ran this script:

tell application "Finder"
	activate
	open desktop
	repeat while window 1 exists
		my allWindows()
		close Finder window 1
	end repeat
end tell

on allWindows()
	tell application "System Events"
		tell application process "Finder"
			set frontmost to true
			if not ((first window whose description is "floating window") exists) then keystroke "j" using command down
			repeat with rg in radio groups of window 1
				if (radio button "All windows" of rg exists) then
					click radio button "All windows" of rg
					keystroke "j" using command down
					exit repeat
				end if
			end repeat
		end tell
	end tell
end allWindows

and this is the Event Log:

Yes, I wrote in the first letter (#1), that GUI Scripting enable

My event Log (script in post #25):

tell application “Finder”
open desktop
get name of Finder window 1
“Desktop”
end tell
tell application “System Events”
set frontmost of application process “Finder” to true
exists window 1 of application process “Finder” whose description = “floating window” and name = “Desktop”
false
keystroke “j” using command down
count every radio group of window 1 of application process “Finder”
0
end tell

Hi KIA.

Your log has this line:

I ran the same script (post #25) and that line in my log is

I never used 10.3.9, so I don’t know what your “View options” window looks like, but it seems that it’s different from mine and Nigel’s, which would explain your problems with the script.

We could compare screenshots by e-mail to compare, but if the problem is the different OS, you need somebody with 10.3.9 experience to help you.

j

Hi, KIA.

Would you mind running this test script in Script Editor on your computer, then post everything that appears in Script Editor’s ‘Result’ pane here? It might cast some light on the UI structure of the View Options window in 10.3.9.

tell application "Finder"
	activate
	-- Close all windows belonging to the Finder.
	close windows
	-- Open a 'Finder window' for the Desktop folder.
	open desktop
	-- Set its view temporarily to 'icon view'.
	set currentView to current view of Finder window 1
	set current view of Finder window 1 to icon view
end tell

tell application "System Events"
	tell application process "Finder"
		set frontmost to true
		-- Open the view options window.
		keystroke "j" using command down
		delay 1
		-- Find out what UI elements it has.
		set UIelements to UI elements of (first window whose description is "floating window")
	end tell
end tell

-- Restore the original view of the Desktop 'Finder window'.
tell application "Finder" to set current view of front Finder window to currentView

-- Return what I need to know.
return UIelements

Well, one of these days I shall illustrate with screen pictures all actions. While I shall give a broad gully. The floating window has opened, but apparently it is not reflected histories of performance of a script.


tell application "Finder"
	activate
	close every window
		{}
	open desktop
	get current view of Finder window 1
		icon view
	set current view of Finder window 1 to icon view
		icon view
end tell
tell application "System Events"
	set frontmost of application process "Finder" to true
	keystroke "j" using command down
	get every UI element of window 1 of application process "Finder" whose description = "floating window"
		{}
end tell
tell application "Finder"
	set current view of Finder window 1 to icon view
		icon view
end tell

I think this information too will be interesting:

tell application "Finder"
	activate
	-- Close all windows belonging to the Finder.
	close windows
	-- Open a 'Finder window' for the Desktop folder.
	open desktop
	-- Set its view temporarily to 'icon view'.
	set currentView to current view of Finder window 1
	set current view of Finder window 1 to icon view
end tell

tell application "System Events"
	tell application process "Finder"
		set frontmost to true
		-- Open the view options window.
		keystroke "j" using command down
		delay 1
		-- Find out what UI elements it has.
		--	Or this:	set UIelements to windows
		--	Or this:	set UIelements to UI elements of windows
		set UIelements to properties of windows
	end tell
end tell

-- Restore the original view of the Desktop 'Finder window'.
tell application "Finder" to set current view of front Finder window to currentView

-- Return what I need to know.
return UIelements

Result (set UIelements to windows) - first run:

{window “Desktop” of application process “Finder” of application “System Events”,
window “Desktop” of application process “Finder” of application “System Events”,
window 3 of application process “Finder” of application “System Events”}

Result (set UIelements to UI elements of windows) - second run:
{{static text “Desktop” of window “Desktop” of application process “Finder” of application “System Events”, button 1 of window “Desktop” of application process “Finder” of application “System Events”, UI element 3 of window “Desktop” of application process “Finder” of application “System Events”},

{button 1 of window “Desktop” of application process “Finder” of application “System Events”, static text “Desktop” of window “Desktop” of application process “Finder” of application “System Events”, grow area 1 of window “Desktop” of application process “Finder” of application “System Events”, button 2 of window “Desktop” of application process “Finder” of application “System Events”, button 3 of window “Desktop” of application process “Finder” of application “System Events”, button 4 of window “Desktop” of application process “Finder” of application “System Events”, scroll bar 1 of window “Desktop” of application process “Finder” of application “System Events”, scroll area 1 of window “Desktop” of application process “Finder” of application “System Events”},

{scroll area 1 of window 3 of application process “Finder” of application “System Events”}}

The third start(set UIelements to properties of windows):

{{position:{592, 34}, maximum value:missing value, name:“Desktop”, size:{200, 426}, subrole:missing value, class:window, minimum value:missing value, enabled:missing value, selected:missing value, role:“AXWindow”, help:missing value, title:“Desktop”, value:missing value, orientation:missing value, description:“window”, focused:false},

{position:{242, 92}, maximum value:missing value, name:“Desktop”, size:{656, 407}, subrole:missing value, class:window, minimum value:missing value, enabled:missing value, selected:missing value, role:“AXWindow”, help:missing value, title:“Desktop”, value:missing value, orientation:missing value, description:“window”, focused:true},

{position:{0, 0}, maximum value:missing value, name:missing value, size:{800, 600}, subrole:missing value, class:window, minimum value:missing value, enabled:missing value, selected:missing value, role:“AXWindow”, help:missing value, title:“”, value:missing value, orientation:missing value, description:“window”, focused:false}}

Hi KIA

I’m posting the result of the script on my computer (10.4.7) for you to compare to your second run. There are differences.

The problem is solved. Here a code which is executed truly. However how to define, what of two windows with one name necessary?

tell application "Finder"
	activate
	-- Close all windows belonging to the Finder.
	close windows
	-- Open a 'Finder window' for the Desktop folder.
	open desktop
	-- Set its view temporarily to 'icon view'.
	set currentView to current view of Finder window 1
	set current view of Finder window 1 to icon view
end tell

tell application "System Events"
	tell application process "Finder"
		set frontmost to true
		-- Open the view options window.
		keystroke "j" using command down
		set frontmost to true
		delay 1
		-- Find out what UI elements it has.
		--	Or this:	set UIelements to windows
		set UIelements to properties of windows
		repeat with itm in windows
			if (focused of itm is false) and (size of itm is not {800, 600}) then
				set UIelements to properties of radio buttons of radio group 1 of UI element 1 of UI element 3 of itm & properties of radio buttons of radio group 1 of UI element 2 of UI element 3 of itm
				tell radio button "All windows" of radio group 1 of UI element 2 of UI element 3 of itm to click
			end if
		end repeat
	end tell
end tell

-- Restore the original view of the Desktop 'Finder window'.
tell application "Finder" to set current view of front Finder window to currentView

-- Return what I need to know.
return UIelements

Result (Unknown 1 & Unknown 2):
{{position:{693, 231}, maximum value:2.0, name:“Right”, size:{83, 18}, subrole:missing value, class:radio button, minimum value:0.0, enabled:true, selected:missing value, role:“AXRadioButton”, help:missing value, title:“Right”, value:0.0, orientation:missing value, description:“radio button”, focused:missing value}, {position:{610, 231}, maximum value:2.0, name:“Bottom”, size:{83, 18}, subrole:missing value, class:radio button, minimum value:0.0, enabled:true, selected:missing value, role:“AXRadioButton”, help:missing value, title:“Bottom”, value:1.0, orientation:missing value, description:“radio button”, focused:missing value},

{position:{610, 76}, maximum value:2.0, name:“All windows”, size:{136, 18}, subrole:missing value, class:radio button, minimum value:0.0, enabled:true, selected:missing value, role:“AXRadioButton”, help:missing value, title:“All windows”, value:0.0, orientation:missing value, description:“radio button”, focused:missing value}, {position:{610, 56}, maximum value:2.0, name:“This window only”, size:{136, 18}, subrole:missing value, class:radio button, minimum value:0.0, enabled:true, selected:missing value, role:“AXRadioButton”, help:missing value, title:“This window only”, value:1.0, orientation:missing value, description:“radio button”, focused:missing value}}