I recently lost my favorite script which was a simple command to switch between default sound device using a small utility called nircmd.
https www.nirsoft.net /utils/nircmd.html Broken Link for safety
The sent commands were toggled by pressing WIN+A:
nircmd setdefaultsounddevice "BEDROOM" 1
nircmd setdefaultsounddevice "LIVING ROOM" 1
There was also another part of the script that would output a small notification in the bottom right corner that would show which option was toggled (it was just simple text).
Any help getting me this going again would be sooooo awesome.
Thanks
lost my favorite script - need help with simple script Topic is solved
-
- Posts: 112
- Joined: 20 Mar 2017, 03:02
Re: lost my favorite script - need help with simple script
https://www.autohotkey.com/boards/viewtopic.php?t=57478
https://www.autohotkey.com/boards/viewtopic.php?t=11086 (with a ToolTip!)
https://www.autohotkey.com/boards/viewtopic.php?t=11086 (with a ToolTip!)
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
-
- Posts: 112
- Joined: 20 Mar 2017, 03:02
Re: lost my favorite script - need help with simple script
OMG THIS IS IT! I cant believe you found this. I am having an error though when trying to compile for my own needs. There was a thrid option in this example you posted but I only want to switch between 2 sources: BEDROOM & LIVING ROOM. Here is my attempt to do this:
Code: Select all
#a::
toggle += 1 ; This increments toggle state (so values after execution of this line will be one of 0,1,2)
if (toggle = 1)
{
Run nircmd setdefaultsounddevice "BEDROOM"
soundToggleBox("BEDROOM")
}
else if (toggle = 2)
{
Run nircmd setdefaultsounddevice "LIVING_ROOM"
soundToggleBox("LIVING_ROOM")
toggle := -1 ; set to -1 so on next run it will end up being 0
}
Return
Call to non existent funtion.
Specifically: soundToggleBox("BEDROOM")
------>006: soundToggleBox("BEDROOM")
-
- Posts: 112
- Joined: 20 Mar 2017, 03:02
Re: lost my favorite script - need help with simple script
never mind I forgot about thesecond part of the script !Here it is in its entirety:
This works like a charm THANK YOU!!!!!!
Code: Select all
#a::
toggle += 1 ; This increments toggle state (so values after execution of this line will be one of 0,1,2)
if (toggle = 1)
{
Run nircmd setdefaultsounddevice "BEDROOM"
soundToggleBox("BEDROOM")
}
else if (toggle = 2)
{
Run nircmd setdefaultsounddevice "LIVING_ROOM"
soundToggleBox("LIVING_ROOM")
toggle := -1 ; set to -1 so on next run it will end up being 0
}
Return
; Display sound toggle GUI
soundToggleBox(Device)
{
IfWinExist, soundToggleWin
{
Gui, destroy
}
Gui, +ToolWindow -Caption +0x400000 +alwaysontop
Gui, Add, text, x35 y8, Default sound: %Device%
SysGet, screenx, 0
SysGet, screeny, 1
xpos:=screenx-275
ypos:=screeny-100
Gui, Show, NoActivate x%xpos% y%ypos% h30 w200, soundToggleWin
SetTimer,soundToggleClose, 2000
}
soundToggleClose:
SetTimer,soundToggleClose, off
Gui, destroy
Return
-
- Posts: 112
- Joined: 20 Mar 2017, 03:02
Re: lost my favorite script - need help with simple script
Oh one thing id like to fix.. Could you hlep me make it so it cycles through only 2 options instead of 3. I have to press +A 2 times to get off of the LIVING ROOM setting.BNOLI wrote: ↑30 Apr 2020, 07:15https://www.autohotkey.com/boards/viewtopic.php?t=57478
https://www.autohotkey.com/boards/viewtopic.php?t=11086 (with a ToolTip!)
Re: lost my favorite script - need help with simple script Topic is solved
Bluerose555 wrote: ↑01 May 2020, 19:36
Oh one thing id like to fix.. Could you hlep me make it so it cycles through only 2 options instead of 3. I have to press +A 2 times to get off of the LIVING ROOM setting.
Code: Select all
#a::
toggle := !toggle ; 0,1
if (toggle = 1)
{
Run nircmd setdefaultsounddevice "BEDROOM"
soundToggleBox("BEDROOM")
}
else
{
Run nircmd setdefaultsounddevice "LIVING_ROOM"
soundToggleBox("LIVING_ROOM")
;toggle := -1 ; set to -1 so on next run it will end up being 0
}
Return
; Display sound toggle GUI
soundToggleBox(Device)
{
IfWinExist, soundToggleWin
{
Gui, destroy
}
Gui, +ToolWindow -Caption +0x400000 +alwaysontop
Gui, Add, text, x35 y8, Default sound: %Device%
SysGet, screenx, 0
SysGet, screeny, 1
xpos:=screenx-275
ypos:=screeny-100
Gui, Show, NoActivate x%xpos% y%ypos% h30 w200, soundToggleWin
SetTimer,soundToggleClose, 2000
}
soundToggleClose:
SetTimer,soundToggleClose, off
Gui, destroy
Return
Test it
-
- Posts: 112
- Joined: 20 Mar 2017, 03:02
Re: lost my favorite script - need help with simple script
thank you I figured it out on my own.. I really appreciate the help !
Re: lost my favorite script - need help with simple script
... so you could use the 'topic solved' option for the posting that helped to solve your problem - so the topic gets finally closed. ThxBluerose555 wrote: ↑08 May 2020, 02:24thank you I figured it out on my own.. I really appreciate the help !
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !