# Finder windows appear twice in Applescript

**URL:** <https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070>\
**Category:** TotalFinder\
**Tags:** question\
**Created:** [January 21, 2019, 2:09pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070 "2019-01-21T14:09:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![asewrsakfe](https://discuss.binaryage.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@asewrsakfe](https://discuss.binaryage.com/u/asewrsakfe)\
**Post date:** [January 21, 2019, 2:09pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/1 "2019-01-21T14:09:18Z")

</div>

Hi,  
When collecting a list of Finder windows in Applescript, every window is listed twice. To test, have some Finder window(s) open and run the following in Script Editor:

```
tell application "System Events"
	  set FinderWins to (windows of (processes whose name = "Finder"))
end tell

```

The result is a nested list with every window listed two times.

Is there a way to avoid this behaviour?

Regards

---

<div class="post-metadata">

**Author:** ![asewrsakfe](https://discuss.binaryage.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@asewrsakfe](https://discuss.binaryage.com/u/asewrsakfe)\
**Post date:** [January 21, 2019, 2:11pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/2 "2019-01-21T14:11:18Z")

</div>

Aaargh, that should have looked nicer. Forgot to think of markdown. ☹ Sorry.

---

<div class="post-metadata">

**Author:** ![darwin](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/darwin/32/2275_2.png) [@darwin](https://discuss.binaryage.com/u/darwin)\
**Post date:** [January 21, 2019, 2:34pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/3 "2019-01-21T14:34:44Z")

</div>

Ah, just tried it and I must confirm it here on my Mojave system.

It works as expected in plain Finder.app without TotalFinder.

Looking into it…

---

<div class="post-metadata">

**Author:** ![asewrsakfe](https://discuss.binaryage.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@asewrsakfe](https://discuss.binaryage.com/u/asewrsakfe)\
**Post date:** [January 21, 2019, 2:52pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/4 "2019-01-21T14:52:29Z")

</div>

Thanks for the fast response! In case there may be a difference, I am still on 10.13.6.

---

<div class="post-metadata">

**Author:** ![darwin](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/darwin/32/2275_2.png) [@darwin](https://discuss.binaryage.com/u/darwin)\
**Post date:** [January 21, 2019, 3:02pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/5 "2019-01-21T15:02:21Z")

</div>

Ok, now I understand why it behaves this way…

Actually this functionality does not touch Finder or TotalFinder. You are asking “System Events” app to give you all windows of a given app. And it works by iterating all visible windows and giving them back. In case of TotalFinder the situation is that it has parent “frame window” and possibly up to two child Finder windows attached to it. System Events returns all of them. In other words it does not iterate only (top-level) non-child windows.

If you create TotalFinder window with dual mode and two distinct tabs, you would see result of three windows. One will have “tab1 | tab2” in name (which is the parent window). I’m now looking into how to distinguish this.

---

<div class="post-metadata">

**Author:** ![darwin](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/darwin/32/2275_2.png) [@darwin](https://discuss.binaryage.com/u/darwin)\
**Post date:** [January 21, 2019, 3:08pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/6 "2019-01-21T15:08:46Z")

</div>

To get all Finder’s visible windows, you should talk directly to Finder:

```
tell application "Finder"
	set FinderWins to windows
end tell
```

---

<div class="post-metadata">

**Author:** ![asewrsakfe](https://discuss.binaryage.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@asewrsakfe](https://discuss.binaryage.com/u/asewrsakfe)\
**Post date:** [January 21, 2019, 3:22pm UTC](https://discuss.binaryage.com/t/finder-windows-appear-twice-in-applescript/7070/7 "2019-01-21T15:22:42Z")

</div>

It’s part of a larger window collection where I tried to catch also non-scriptable apps, hence the System Events: “get (windows of (processes whose visible = true) whose value of attribute “AXMinimized” is false)”. Maybe I’ll have to run Finder separately.

Awesome support, btw!
