Replicate Windows + E on macOS

Dear community,

I could use your help once again.

Unfortunately, I have to use Windows for work. On Windows, the keyboard shortcut Windows + E opens File Explorer. I'd like to recreate this behavior on my MacBook using BetterTouchTool.

My goal is that, regardless of which application I'm currently using (e.g., Safari, Notes, or any other app), pressing ⌘ Command + E should always open a new Finder window displaying my Home folder—the same folder that can be opened from the Desktop by pressing ⌘ Command + ⇧ Shift + H ("Open Home Folder").

The difference from ⌘ Command + ⇧ Shift + H, however, is that ⌘ Command + E should always open a new Finder window showing my Home folder, rather than simply navigating the currently active Finder window to the Home folder.

For example, if I'm currently viewing the Downloads folder and press ⌘ Command + ⇧ Shift + H, Finder doesn't open a new window—it simply changes the existing window to display my Home folder. With the new ⌘ Command + Eshortcut, I want the Downloads window to remain open while a new Finder window opens showing my Home folder.

Likewise, if I'm already in my Home folder and press ⌘ Command + E, it should still open another new Finder window displaying my Home folder. Every time I press ⌘ Command + E, a new Finder window showing my Home folder should be created.

So, I'm looking for a solution where ⌘ Command + E always opens a new Finder window with my Home folder, regardless of whether I'm currently in another application, another Finder folder, or already in my Home folder.

Is there a way to achieve this behavior using BetterTouchTool?

Thank you very much for your help!

You can use BTT's "Run Apple Script" action with this apple script:

tell application "Finder"
	activate
	set newWindow to make new Finder window
	set target of newWindow to home
end tell

Thank you very much for your quick response.

I noticed that I made a mistake in my original request: I did not mean the Home folder, but rather the Computer view, which can be opened with ⌘ Command + ⇧ Shift + C.

I also noticed two things:

First: The script works perfectly when I am using another application, such as Safari or Notes. However, when I execute the same command while I am already in the Finder, nothing happens. Is there a reason for this behavior, and is there a way to make it work reliably even when Finder is the active application?

Second: I am working with three monitors, and the new Finder window always opens on my main display. This is inconvenient when I am currently working on my third monitor, for example.

Is there a way to configure it so that the new Finder window opens on the display where the mouse cursor is currently located?

Thank you very much for your help!

You can try this (much more complex) script that should center on your mouse's monitor:

use AppleScript version "2.4"
use framework "AppKit"
use scripting additions

property cocoa : a reference to current application
property preferredWidth : 900
property preferredHeight : 650
property edgeMargin : 30

-- Get the current mouse position.
set mousePoint to cocoa's NSEvent's mouseLocation()
set mouseRecord to mousePoint as record
set mouseX to x of mouseRecord
set mouseY to y of mouseRecord

-- Find the display containing the mouse pointer.
set screenList to cocoa's NSScreen's screens()
set targetScreen to item 1 of screenList

repeat with oneScreen in screenList
	set screenFrame to oneScreen's frame()
	
	set screenMinX to (cocoa's NSMinX(screenFrame)) as real
	set screenMaxX to (cocoa's NSMaxX(screenFrame)) as real
	set screenMinY to (cocoa's NSMinY(screenFrame)) as real
	set screenMaxY to (cocoa's NSMaxY(screenFrame)) as real
	
	if mouseX ≥ screenMinX and mouseX < screenMaxX and ¬
		mouseY ≥ screenMinY and mouseY < screenMaxY then
		
		set targetScreen to oneScreen
		exit repeat
	end if
end repeat

-- Get the usable display area, excluding the menu bar and Dock.
set visibleFrame to targetScreen's visibleFrame()

set usableLeft to (cocoa's NSMinX(visibleFrame)) as integer
set usableWidth to (cocoa's NSWidth(visibleFrame)) as integer
set usableHeight to (cocoa's NSHeight(visibleFrame)) as integer

-- Convert AppKit's bottom-left coordinate system
-- to Finder's top-left coordinate system.
set primaryScreen to item 1 of screenList
set primaryFrame to primaryScreen's frame()

set primaryTop to (cocoa's NSMaxY(primaryFrame)) as integer
set targetTop to (cocoa's NSMaxY(visibleFrame)) as integer
set usableTop to primaryTop - targetTop

-- Keep the window within the target display.
set windowWidth to preferredWidth
set windowHeight to preferredHeight

set maximumWidth to usableWidth - (2 * edgeMargin)
set maximumHeight to usableHeight - (2 * edgeMargin)

if windowWidth > maximumWidth then set windowWidth to maximumWidth
if windowHeight > maximumHeight then set windowHeight to maximumHeight

-- Centre the window on the display containing the mouse.
set leftPosition to (usableLeft + ((usableWidth - windowWidth) / 2)) as integer
set topPosition to (usableTop + ((usableHeight - windowHeight) / 2)) as integer

set rightPosition to leftPosition + windowWidth
set bottomPosition to topPosition + windowHeight

-- Open a new Finder window in the Computer view.
tell application "Finder"
	set newWindow to make new Finder window
	set target of newWindow to computer container
	set bounds of newWindow to ¬
		{leftPosition, topPosition, rightPosition, bottomPosition}
	
	try
		set index of newWindow to 1
	end try
	
	activate
end tell

有一些报错,并且不能正确在鼠标所在屏幕打开

use AppleScript version "2.4"
use framework "AppKit"
use scripting additions

property cocoa : a reference to current application
property preferredWidth : 900
property preferredHeight : 650
property edgeMargin : 30

-- 1. 使用 Cocoa 框架获取当前鼠标位置
set mousePoint to cocoa's NSEvent's mouseLocation()
set mouseX to mousePoint's x as real
set mouseY to mousePoint's y as real

-- 2. 查找包含鼠标指针的显示器
set screenList to cocoa's NSScreen's screens()
set targetScreen to item 1 of screenList

repeat with oneScreen in screenList
set screenFrame to oneScreen's frame()

set screenMinX to (cocoa's NSMinX(screenFrame)) as real
set screenMaxX to (cocoa's NSMaxX(screenFrame)) as real
set screenMinY to (cocoa's NSMinY(screenFrame)) as real
set screenMaxY to (cocoa's NSMaxY(screenFrame)) as real

if mouseX ≥ screenMinX and mouseX < screenMaxX and ¬
	mouseY ≥ screenMinY and mouseY < screenMaxY then
	
	set targetScreen to oneScreen
	exit repeat
end if

end repeat

-- 3. 获取可用显示区域(排除菜单栏和程序坞)
set visibleFrame to targetScreen's visibleFrame()

set usableLeft to (cocoa's NSMinX(visibleFrame)) as integer
set usableWidth to (cocoa's NSWidth(visibleFrame)) as integer
set usableHeight to (cocoa's NSHeight(visibleFrame)) as integer

-- 4. 将 AppKit 的左下角坐标系转换为 Finder 的左上角坐标系
set primaryScreen to item 1 of screenList
set primaryFrame to primaryScreen's frame()

set primaryTop to (cocoa's NSMaxY(primaryFrame)) as integer
set targetTop to (cocoa's NSMaxY(visibleFrame)) as integer
set usableTop to primaryTop - targetTop

-- 5. 确保窗口大小不超过可用区域
set windowWidth to preferredWidth
set windowHeight to preferredHeight

set maximumWidth to usableWidth - (2 * edgeMargin)
set maximumHeight to usableHeight - (2 * edgeMargin)

if windowWidth > maximumWidth then set windowWidth to maximumWidth
if windowHeight > maximumHeight then set windowHeight to maximumHeight

-- 6. 在包含鼠标的显示器上居中窗口
set leftPosition to (usableLeft + ((usableWidth - windowWidth) / 2)) as integer
set topPosition to (usableTop + ((usableHeight - windowHeight) / 2)) as integer

set rightPosition to leftPosition + windowWidth
set bottomPosition to topPosition + windowHeight

-- 7. 打开新的 Finder 窗口并设置位置(最终稳定版)
tell application "Finder"
activate
make new Finder window

-- 延迟以确保窗口完全初始化
delay 0.1

-- 直接对最前面的窗口设置边界(新窗口默认即为电脑视图)
tell front window
	set bounds to {leftPosition, topPosition, rightPosition, bottomPosition}
end tell

end tell