Rank: Newbie
Groups: Approved
Joined: 9/4/2018(UTC) Posts: 9 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
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 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()));
}
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 9/4/2018(UTC) Posts: 9 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).
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
What error message are you seeing?
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 9/4/2018(UTC) Posts: 9 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()));
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 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?
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 9/4/2018(UTC) Posts: 9 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!
|
|
|
|
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