Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

OSD Mute Status Display & Toggle Mute On/Off Script!


  • Please log in to reply
11 replies to this topic
DominicTFY
  • Members
  • 10 posts
  • Last active: Mar 24 2005 01:00 PM
  • Joined: 05 Dec 2004
Hey guys, this is the OSD Mute script i came up with. It turns on/off master mute and displays the mute status at the bottom left of the screen through OSD.
Special thanks to Chris & Tekl for their help. :D
Press Control + Windows Key + m to try...hehe...
Feel free to post any errors faced and suggestions. Cheers, mate(s)!

;By Dominic Tay
;Master Mute
^#m::
Gui,Destroy
SoundSet, +1,, mute
SoundGet, Master_mute,, mute
if Master_mute = On
{
Gui, Color, 000080
Gui, font, s20 bold cYellow, Tahoma
Gui, Add, text,x0 y0, Mute On
DetectHiddenWindows on
WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
WinSet, TransColor,000080 %transparent%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w200 h50 x10 y705
setenv, presstime, %A_MDay%%A_hour%%A_Min%%A_Sec%
envadd, presstime, 2
SetTimer, RemoveGui, On
return
RemoveGui:
  setenv, presstime2, %A_MDay%%A_hour%%A_Min%%A_Sec%
  ifgreaterorequal, presstime2, %presstime%
  {
    Gui, Destroy
    SetTimer, RemoveGui, off
  }
return
}
else
{
Gui, Color, 000080
Gui, font, s20 bold cYellow, Tahoma
Gui, Add, text,x0 y0 vMyText, Mute Off
DetectHiddenWindows on
WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
WinSet, TransColor,000080 %transparent%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w200 h50 x10 y705
setenv, presstime, %A_MDay%%A_hour%%A_Min%%A_Sec%
envadd, presstime, 2
SetTimer, RemoveGui, On
return
}
return


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

However, if i turn mute off to on, the OSD display shows "On", but with a trace of the last letter of "F" from "OFF".

That happens because you were adding the text controls one on top of the other (with overlap). Here is a simplified version that seems to work okay:
^#m::

SoundSet, +1,, mute

SoundGet, Master_mute,, mute

Gui, Color, 000080

Gui, font, s20 bold cYellow, Tahoma

Gui, Add, text,x0 y0 vGuiText, Mute %Master_mute%

DetectHiddenWindows on

WinWait, %A_ScriptName%

WinSet, TransColor, 000080 150

WinSet, AlwaysOnTop, On

Gui, -Caption

Gui, Show, w200 h50 x10 y705

Sleep, 600

Gui, Destroy

return


DominicTFY
  • Members
  • 10 posts
  • Last active: Mar 24 2005 01:00 PM
  • Joined: 05 Dec 2004
Thx again, Chris! I tot of that simplified script before. However, if i wan to toggle between on/off with that simplified script, I kind of like had to wait for 600 ms between the toggle.

Gui, Show, w200 h50 x10 y705
Sleep, 600 ;---------------> Wait for 600ms
Gui, Destroy

But i made a change and edited my code above by just adding a "Gui,Destroy" right at the front of the script. So it eradicates the prob. hehe...
and now, u can toggle between mute on/off anytime, even before the 600 ms wait. But hey Chris, u roX! Cheers, mate! And please please, let me noe if u haf a simplified version of the new code above. I will really appreciate that! thx! :D

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

let me noe if u haf a simplified version of the new code above

Here's a revised one that allows the hotkey to work even when the window is already displayed:

^#m::
SoundSet, +1,, mute
SoundGet, Master_mute,, mute
SetTimer, GuiDestroy, off ; This avoids a rare split-second timing issue.
Gui, Destroy ; Make sure it's destroyed when starting out in case timer hasn't fired yet.
Gui, Color, 000080
Gui, font, s20 bold cYellow, Tahoma
Gui, Add, text,x0 y0 vGuiText, Mute %Master_mute%
DetectHiddenWindows on
WinWait, %A_ScriptName%
WinSet, TransColor, 000080 150
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w200 h50 x10 y705
SetTimer, GuiDestroy, 600
return

GuiDestroy:
SetTimer, GuiDestroy, off
Gui, Destroy
return

DominicTFY
  • Members
  • 10 posts
  • Last active: Mar 24 2005 01:00 PM
  • Joined: 05 Dec 2004
OMG~~ :!:
Stunningly shorter den mine...haha...thx again, chris. U never fail 2 amuse me with your computer knowledge.Haha~ :D

BoBo
  • Guests
  • Last active:
  • Joined: --
@ DominicTFY
where are you from ?

DominicTFY
  • Members
  • 10 posts
  • Last active: Mar 24 2005 01:00 PM
  • Joined: 05 Dec 2004
@ BoBo
I'm from Singapore. :D
Wad about you guys, BoBo and Chris?

BoBo
  • Guests
  • Last active:
  • Joined: --
B = D!
C = FL/USA

:idea:

DominicTFY
  • Members
  • 10 posts
  • Last active: Mar 24 2005 01:00 PM
  • Joined: 05 Dec 2004
Haha...icic..Right now i trying 2 make my own volume OSD script using Gui's Text and Progress Bar together..Haha. Will post questions if i m not sure. :lol:

  • Guests
  • Last active:
  • Joined: --
Thanks for the script.I made a little change.I think this would look better for the eye. It looks good on my computer but It may look different on somebodies computer. You can try :)






;By Dominic Tay
;Master Mute
^#m::
Gui,Destroy
SoundSet, +1,, mute
SoundGet, Master_mute,, mute
if Master_mute = On
{
Gui, Color, FF0000
Gui, font, s20 bold cWhite, Tahoma
Gui, Add, text,x0 y0, Mute On
DetectHiddenWindows on
WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
WinSet, TransColor,000080 %transparent%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w130 h35 x375 y375
setenv, presstime, %A_MDay%%A_hour%%A_Min%%A_Sec%
envadd, presstime, 2
SetTimer, RemoveGui, On
return
RemoveGui:
  setenv, presstime2, %A_MDay%%A_hour%%A_Min%%A_Sec%
  ifgreaterorequal, presstime2, %presstime%
  {
    Gui, Destroy
    SetTimer, RemoveGui, off
  }
return
}
else
{
Gui, Color, 00FF00
Gui, font, s20 bold cWhite, Tahoma
Gui, Add, text,x0 y0 vMyText, Mute Off
DetectHiddenWindows on
WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
WinSet, TransColor,000080 %transparent%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w130 h35 x375 y375
setenv, presstime, %A_MDay%%A_hour%%A_Min%%A_Sec%
envadd, presstime, 2
SetTimer, RemoveGui, On
return
}
return


  • Guests
  • Last active:
  • Joined: --
I combined volume up, volume down and mute. I assigned f10, f11, and f12.
Looks nice.

f10::Send {Volume_down}
f12::Send {Volume_Up}

volume_up::
SoundSet, +1, MASTER
Gosub, osd
Return
+volume_up::
SoundSet, +1, WAVE
Gosub, osd
Return
volume_down::
SoundSet, -1, MASTER
Gosub, osd
Return
+volume_down::
SoundSet, -1, WAVE
Gosub, osd
Return

osd:
SoundGet, ?volM, MASTER
SoundGet, ?volW, WAVE
Transform, ?volM, Ceil, %?volM%
Transform, ?volW, Ceil, %?volW%
?full = 

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

IIIIIIII
IfWinNotExist, volumeMASTER
{
   StringLeft, ?barM, ?full, %?volM%
   StringLeft, ?barW, ?full, %?volW%
   Progress,1: B H26 W790 ZH0 C0 ZX0 ZY0 FS22 CTE0932F CWblack, , , volumeMASTER,TPF Display
   WinGetPos, , ?wY, , , volumeMASTER
   ?wY += 26
   Progress,2: B Y%?wY% H26 W790 ZH0 C0 ZX0 ZY0 FS22 CTred CWblack, , , volumeWAVE,TPF 

Display
   Progress, 1:, %?volM%--%?barM%
   Progress, 2:, %?volW%--%?barW%
}
Else
{
   StringLeft, ?barM, ?full, %?volM%
   StringLeft, ?barW, ?full, %?volW%
   Progress, 1:, %?volM%--%?barM%
   Progress, 2:, %?volW%--%?barW%
}

SetTimer, label, 2000 ;bars are visible for 2 seconds
Return
label:
SetTimer, label, Off
Progress, 1:Off
Progress, 2:Off
Return










;By Dominic Tay
;Master Mute
f11::
Gui,Destroy
SoundSet, +1,, mute
SoundGet, Master_mute,, mute
if Master_mute = On
{
Gui, Color, FF0000
Gui, font, s20 bold cWhite, Tahoma
Gui, Add, text,x0 y0, Mute On
DetectHiddenWindows on
WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
WinSet, TransColor,000080 %transparent%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w130 h35 x375 y375
setenv, presstime, %A_MDay%%A_hour%%A_Min%%A_Sec%
envadd, presstime, 2
SetTimer, RemoveGui, On
return
RemoveGui:
  setenv, presstime2, %A_MDay%%A_hour%%A_Min%%A_Sec%
  ifgreaterorequal, presstime2, %presstime%
  {
    Gui, Destroy
    SetTimer, RemoveGui, off
  }
return
}
else
{
Gui, Color, 00FF00
Gui, font, s20 bold cWhite, Tahoma
Gui, Add, text,x0 y0 vMyText, Mute Off
DetectHiddenWindows on
WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
WinSet, TransColor,000080 %transparent%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w130 h35 x375 y375
setenv, presstime, %A_MDay%%A_hour%%A_Min%%A_Sec%
envadd, presstime, 2
SetTimer, RemoveGui, On
return
}
return


Don Guido
  • Guests
  • Last active:
  • Joined: --
hi there,

I noticed that there is a small eror in the script. Namely, in the following line:
Gui, Add, text,x0 y0 vMyText, Mute Off

I believe the vMyText should in fact just be: MyText

This will stop the popup error box you get and allo the Mute off message to be seen.

Kind regards,

DG