AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Sun May 14, 2006 11:28 am    Post subject: Crazy Scripting : Muter v1.0 ( MPPS type Button ) Reply with quote

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. Smile
_________________


Last edited by SKAN on Mon May 15, 2006 5:35 am; edited 1 time in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sun May 14, 2006 11:44 pm    Post subject: Reply with quote

Nicely presented, as always!
Back to top
View user's profile Send private message Send e-mail
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon May 15, 2006 5:35 am    Post subject: Reply with quote

Very Happy Thanks Mr.Chris Very Happy
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group