Rank: Advanced Member
Groups: Approved
Joined: 10/26/2020(UTC) Posts: 50 Location: Darmstadt Thanks: 15 times Was thanked: 2 time(s) in 2 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.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 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 3:15:42 PM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 10/26/2020(UTC) Posts: 50 Location: Darmstadt Thanks: 15 times Was thanked: 2 time(s) in 2 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.
|
|
|
|
Rank: Member
Groups: Approved
Joined: 11/10/2021(UTC) Posts: 10
|
Win+tab also has the same problem.
|
|
|
|
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close