Jump to content

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

Crazy Scripting : Muter v1.0 ( MPPS type Button )


  • Please log in to reply
2 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Posted Image Muter v1.0

[*:2ylwzqc1]Muter v1.0 is a Tiny GUI app for SndVol32.exe.
[*:2ylwzqc1]The main job of Muter is to Toggle Master Volume Mute between ON/OFF.
[*:2ylwzqc1]Additionally, it will open/activate "Volume Control" window

[*:2ylwzqc1]A Normal Click will Toggle Master Volume Mute Status
[*:2ylwzqc1]A Long click ( Keeping the Left Mouse Button pressed for 1 second ) on the Icon will open/activate "Volume Control"[*:2ylwzqc1]Muter is an Always-On-Top window and the GUI remembers it last position.
[*:2ylwzqc1]Muter is based on MPPS type button simulation. (See. TipsNTricks: How to Simulate a Graphical Button in a GUI?)[/list]
;#InstallMouseHook 
OnExit, GuiEscape
IfNotExist, Muter.ini
    IniWrite, 10`,10,Muter.ini,Settings,GuiPos

IniRead,GuiPos,Muter.ini,Settings,GuiPos 
StringSplit,Pos,GuiPos,`,

Menu,Tray,Icon, SndVol32.exe,1
Menu,Tray,Tip , Muter v1.0

Gui, +Sysmenu +ToolWindow +AlwaysOnTop
Gui,Margin, 2,2
Gui, Add, Picture,  x2  y5 w32 h32 E0x200 vState1 icon5 gMPP_Switch, SndVol32.exe
Gui, Add, Picture,  x2  y5 w34 h34 Border vState0 icon5 gMPP_Switch, SndVol32.exe
Gui,Show, x%Pos1% y%pos2% AutoSize, % A_Space "Muter"
WinID:=WinExist("A")
SetTimer, SetIcon, 10
Return

MPP_Switch:

  GuiControl Hide, State0
  TC := A_TickCount
  Loop, {
    MouseDown:=GetKeyState("LButton","P")
    If (!MouseDown) {
       LongClick=0
       Break
    }
    If (A_TickCount-TC) > 1000 {
       LongClick=1
       Break
        }
  }
  IfEqual,LongClick,1,GoSub,SubRoutine1
  else GoSub, SubRoutine0

  GuiControl Show, State0

Return

SubRoutine1:
 IfWinNotExist, Volume Control
 Run, SndVol32.exe
 else
 WinActivate, Volume Control
Return

SubRoutine0:
  Sleep, 100
  SoundSet, +1, , MUTE 
Return

SetIcon:

SoundGet,Mute, MASTER, MUTE

If Mute=%LastMute%
   Exit

SetTimer, SetIcon, Off

If Mute=Off 
   {
   GuiControl, ,State1, *icon5 SndVol32.exe
   GuiControl, ,State0, *icon5 SndVol32.exe
   }
else {
   GuiControl, ,State1, *icon4 SndVol32.exe
   GuiControl, ,State0, *icon4 SndVol32.exe
}

LastMute:=Mute
SetTimer, SetIcon, 100
Return

GuiEscape:
GuiClose:
  WinGetPos, xPos, yPos, , ,ahk_id %WinID%
  IniWrite,%xPos%`,%yPos%,Muter.ini,Settings,GuiPos
  ExitApp
Return

I hope this concept is interesting!

Regards. :)
kWo4Lk1.png

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Nicely presented, as always!

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
:D Thanks Mr.Chris :D