SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Sun May 14, 2006 11:28 am Post subject: Crazy Scripting : Muter v1.0 ( MPPS type Button ) |
|
|
Muter v1.0
- Muter v1.0 is a Tiny GUI app for SndVol32.exe.
- The main job of Muter is to Toggle Master Volume Mute between ON/OFF.
- Additionally, it will open/activate "Volume Control" window
- A Normal Click will Toggle Master Volume Mute Status
- A Long click ( Keeping the Left Mouse Button pressed for 1 second ) on the Icon will open/activate "Volume Control"
- Muter is an Always-On-Top window and the GUI remembers it last position.
- Muter is based on MPPS type button simulation. (See. TipsNTricks: How to Simulate a Graphical Button in a GUI?)
Snapshots:

| Code: | ;#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.  _________________

Last edited by SKAN on Mon May 15, 2006 5:35 am; edited 1 time in total |
|