I've been using a short AutoHotKey script to simulate Alt Tab on Windows 10 using the middle mouse button, so that I can quickly open my most recently opened app, or toggle between two apps, with the click of a button. This is what I'm using
Mbutton::SendEvent {Alt Down}{Tab}{Alt Up}
But I've been using two monitors recently, and what I really want to do is switch to the most recently opened app ON THE ACTIVE MONITOR (or the monitor that the mouse is currently on). Alt Tab alone doesn't work obviously, because often the most recently opened app is on the other monitor and I only want to bring the window of the most recently used app forward if it is in the monitor I'm currently working in. Does anyone know if this is possible and how I might go about doing it?
I am pasting here my script. It is very ugly, but it works on my two-monitor setup as you described: switches to the previous (for the monitor where you click middle button) active window.
One of the functions (
GetMonitorIndexFromWindow(windowHandle)) is not mine, taken from here.Note that I haven’t got time to work on generic case for my
GetMonitorIndexFromMouse()function, so it’s just good for my specific case (2 monitors, with the left one as primary).I have
isDebug := truehere, so that you could see the tooltip with variables − feel free to change it toisDebug := falseof course, if the script works for you.