Move focus and mouse to another screen

I’ve been using two screens and using hammerspoon to switch keyboard focus and mouse location between the two. Now I am trying to replicate this in BTT but did not find the corresponding action to achieve so. Wondering if I missed anything, or it should be a feature suggestion?

btw hammerspoon plugin lua code for reference

local function activate_other_screen()
	local screen = hs.mouse.getCurrentScreen()
	local nextScreen = screen:next()
	local center = hs.geometry.rectMidPoint(nextScreen:fullFrame())
	local win = hs.fnutils.find(hs.window.orderedWindows(), function(w) return nextScreen:id() == w:screen():id() end)
	if (win) then
		win:focus()
	else
		print('no win')
	end
	hs.mouse.absolutePosition(center)
end 

hs.hotkey.bind({"option"}, "tab", activate_other_screen)

Here's a quick solution with a lot of edge cases and considerations:

instead of left click better use "Activate Window Under Cursor".

I can post some JS that basically does the same as the above lua this evening (currently without my Mac)

2 Likes

Thanks. I think the main blocker for me is to move mouse to the other screen, which of coz will be sometime left, sometimes right to the main one. and none of these options is a good fit.

thanks, and yes some example to find dynamically the next screen will be very helpful!