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

Notification

Icon
Error

Options
Go to last post Go to first unread
Eien  
#1 Posted : Friday, March 31, 2023 5:03:32 PM(UTC)
Eien

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/4/2018(UTC)
Posts: 9
France

Thanks: 3 times
Hello,

I'm using this scipt to open the Windows 11 volume mixer with a gesture: sp.RunProgram("ms-settings:apps-volume", "", "open", "normal", true, false, false);

I have a dual monitor set up (TV+PC). I use a Display fusion app feature that allows me to open any app on the monitor where the mouse cursor is. For example if i do a mouse gesture to open my brower on my PC, it opens on my PC monitor but if i do it on my TV, then the brower opens on my TV monitor.

I would like the Windows 11 volume mixer to behave the same way my browser does but as it stands currently, if the volume mixer is already open on my PC monitor when i try to open it on my TV it doesn't work as it just brings back the focus to the instance already opened on my PC monitor. I have to close the volume mixer instance on my PC monitor in order to open a new one on my TV.

Is there a way for a script to close the current instance if already opened and open a new one in the foreground every time a gesture to open the volume mixer is done?

Edited by user Sunday, April 2, 2023 11:32:56 AM(UTC)  | Reason: Not specified

Rob  
#2 Posted : Friday, March 31, 2023 5:32:11 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Here's something to get you started.

This one always closes the Settings window, opens the mixer, then moves it to the target screen:
Code:
var settingsWindow = sp.WindowFromClassOrTitle("ApplicationFrameWindow", "Settings");
if(settingsWindow != null && settingsWindow.Visible) {
    settingsWindow.SendClose();
    sp.Sleep(250); //Adjust as needed
}
sp.RunProgram("ms-settings:apps-volume", "", "open", "normal", true, false, false);
sp.Sleep(250); //Adjust as needed
settingsWindow = sp.WindowFromClassOrTitle("ApplicationFrameWindow", "Settings");
settingsWindow.MoveToScreen(Screen.FromPoint(sp.GetCurrentMousePoint()));

This one moves the Settings window to the screen where the mouse cursor is located if it's already open, otherwise opens and moves:
Code:
var settingsWindow = sp.WindowFromClassOrTitle("ApplicationFrameWindow", "Settings");
if(settingsWindow != null && settingsWindow.Visible) {
    settingsWindow.MoveToScreen(Screen.FromPoint(sp.GetCurrentMousePoint()));
} else {
    sp.RunProgram("ms-settings:apps-volume", "", "open", "normal", true, false, false);
    sp.Sleep(250); //Adjust as needed
    settingsWindow = sp.WindowFromClassOrTitle("ApplicationFrameWindow", "Settings");
    settingsWindow.MoveToScreen(Screen.FromPoint(sp.GetCurrentMousePoint()));
}
thanks 1 user thanked Rob for this useful post.
Eien on 3/31/2023(UTC)
Eien  
#3 Posted : Friday, March 31, 2023 8:30:09 PM(UTC)
Eien

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/4/2018(UTC)
Posts: 9
France

Thanks: 3 times
Thank you for your help and quick response.

I tried both scripts but unfortunately i get an error message. When i draw the gesture the mixer's window open with the error message. (Same when the mixer is already open.)

I just pasted the script you provided in the script tab and clicked apply. (In case i'm missing a step in the settings).
Rob  
#4 Posted : Friday, March 31, 2023 8:47:29 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
What error message are you seeing?
thanks 1 user thanked Rob for this useful post.
Eien on 3/31/2023(UTC)
Eien  
#5 Posted : Friday, March 31, 2023 9:07:16 PM(UTC)
Eien

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/4/2018(UTC)
Posts: 9
France

Thanks: 3 times
I tried to link a screen capture of the error message in my previous reply.

It says TypeError:Cannot read properties of null (reading'moveToScreen') at Script [263]:9:16->settingsWindow.MoveToScreen(Screen.FromPoint(sp.GetCurrentMousePoint()));
Rob  
#6 Posted : Saturday, April 1, 2023 10:35:20 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I see your interface is not English - what is the title of the Settings window?
thanks 1 user thanked Rob for this useful post.
Eien on 4/2/2023(UTC)
Eien  
#7 Posted : Sunday, April 2, 2023 11:32:29 AM(UTC)
Eien

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/4/2018(UTC)
Posts: 9
France

Thanks: 3 times
I just changed "settings" to "Paramètres" in the first script you provided and it works perfectly now:No more error messages and works exactly as expected.

Thank you so much!
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.