StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rob Otter  
#1 Posted : Tuesday, December 22, 2020 4:02:15 AM(UTC)
Rob Otter

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 10/26/2020(UTC)
Posts: 44
Germany
Location: Darmstadt

Thanks: 14 times
Was thanked: 1 time(s) in 1 post(s)
Hi,

on my triple-monitor setup, I was annoyed by the task switcher window (Alt-Tab and Ctrl-Alt-Tab) as it always pops up on the primary screen where I usually need to have it on the screen where my mouse is.
As soon as I found out that this switcher is a common Explorer window with special style and can be moved by S+, the rest was easy. The trick is to identify it - as it has a distinct class name, it can be distinguished from other Explorer windows.

I´d like to share this with you in case you also have a need for it.
The correct place is in Global Actions --> Window Events --> Foreground Window Change as it is called everytime the window focus changes:

Code:
/*
    Move the task switcher window (Alt-Tab / Ctrl-Alt-Tab)
    to the window where the mouse is currently located.
*/
var currApp = sp.ForegroundWindow();

// The task switcher window class name is "MultitaskingViewFrame"
if (currApp.ClassName == "MultitaskingViewFrame") {
    var mouseScreen = Screen.FromPoint(sp.GetCurrentMousePoint());

    currApp.MoveToScreen(GetScreenNumber(mouseScreen));
    // This will re-center (but possibly not resize) in case the target screen has a different resolution:
    currApp.FitToScreen();
}

/*
    Returns the number of a given Screen object
    or -1 if the Screen was not found.
*/
function GetScreenNumber(screen) {
    var allScreens = Screen.AllScreens;
    var screenNumber = allScreens.Length - 1;

    while (screenNumber > -1 && allScreens[screenNumber].DeviceName != screen.DeviceName) {
        screenNumber--;
    }

    return screenNumber;
}


Btw: Rob, it would come in handy if the function MoveToScreen(number) would take a Screen object or even a Screen´s DeviceName instead of a number, as the number is no attribute of the Screen class and need to be found out quite uncomfortably, as you can see above.
Rob  
#2 Posted : Tuesday, December 22, 2020 7:09:58 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 818
United States
Location: Tampa, FL

Thanks: 18 times
Was thanked: 195 time(s) in 170 post(s)
That was from very early on, and I just copied what the original S+ did.

I've updated it in 0.4.0.9 to accept a screen number or object.
Code:
var currApp = sp.ForegroundWindow();

// The task switcher window class name is "MultitaskingViewFrame"
if (currApp.ClassName == "MultitaskingViewFrame") {
    currApp.MoveToScreen(Screen.FromPoint(sp.GetCurrentMousePoint()));
    // This will re-center (but possibly not resize) in case the target screen has a different resolution:
    currApp.FitToScreen();
}

P.S. This is handy!

Edited by user Tuesday, December 22, 2020 8:15:42 AM(UTC)  | Reason: Not specified

thanks 1 user thanked Rob for this useful post.
Rob Otter on 12/22/2020(UTC)
Rob Otter  
#3 Posted : Tuesday, December 22, 2020 2:37:57 PM(UTC)
Rob Otter

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 10/26/2020(UTC)
Posts: 44
Germany
Location: Darmstadt

Thanks: 14 times
Was thanked: 1 time(s) in 1 post(s)
Thanks Rob for your quick solution, works like a charm!
Best thing is, it is a non-script-breaking change. I like that both parameter types can be used now.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.