Jump to content
Sign in to follow this  
SAEED

Master Volume & Wave Controller

Recommended Posts

SAEED

This script using a CPU near about 04 to 09

so help me to reduce CPU usage which is using this Script

#include<SoundGetSetQuery.au3>
#NoTrayIcon
_SoundSetWaveVolume(100)
_SoundSetMasterVolume(100)
; Wave HotKeys
HotKeySet("^!{NUMPAD5}", "WAVE_MUTE")
HotKeySet(("!{NUMPAD9}"), "WAVE_UP")
HotKeySet(("!{NUMPAD3}"), "WAVE_DOWN")
; Master Hotkeys
HotKeySet("!{NUMPAD5}", "MASTER_VOLUME_MUTE")
HotKeySet(("!{NUMPAD8}"), "MASTER_VOLUME_UP")
HotKeySet(("!{NUMPAD2}"), "MASTER_VOLUME_DOWN")
; Wave Global Variables
Global $WaveMute, $Wave_Mute_Status, $Wave_Volume_Status, $Wave_Down, $Wave_Up
;Master Global Variables
Global $MasterMute, $Master_Mute_Status, $Master_Volume_Status, $Master_Down, $Master_Up

While 1 
    Sleep(100)
; Master Query
    $Master_Mute_Status = _SoundGetMasterMute()
    $Master_Volume_Status = _SoundGetMasterVolume()
; Wave Query
    $Wave_Mute_Status = _SoundGetWaveMute()
    $Wave_Volume_Status = _SoundGetWaveVolume()
Wend

;*******************************************************************
; Wave Functions Start
Func WAVE_MUTE();Wave Sound Mute by pressing Alt + Shift + Numpad 5
    $WaveMute = Not $WaveMute
    While $WaveMute
        Sleep(100)
        If $Wave_Mute_Status = 0 Then
            _SoundSetWaveMute(1)
            $WaveMute = Not $WaveMute
        ElseIf $Wave_Mute_Status = 1 Then
            _SoundSetWaveMute(0)
            $WaveMute = Not $WaveMute
        Else
            $WaveMute = Not $WaveMute
        EndIf
    WEnd
EndFunc  ;==>WAVE_MUTE

Func WAVE_UP();Wave Sound Up by pressing Alt + Numpad 9
    $Wave_Up = Not $Wave_Up
    While $Wave_Up
        Sleep(100)
        $Wave_Volume_Status += 5
        If $Wave_Volume_Status < 105 Then
            _SoundSetWaveVolume($Wave_Volume_Status)
            $Wave_Up = Not $Wave_Up
        Else
            $Wave_Up = Not $Wave_Up
        EndIf
    WEnd
EndFunc  ;==>WAVE_UP

Func WAVE_DOWN();Wave Sound Down by pressing Alt + Numpad 3
    $Wave_Down = Not $Wave_Down
    While $Wave_Down
        Sleep(100)
        $Wave_Volume_Status -= 5
        If $Wave_Volume_Status > -5 Then
            _SoundSetWaveVolume($Wave_Volume_Status)
            $Wave_Down = Not $Wave_Down
        Else
            $Wave_Down = Not $Wave_Down
        EndIf
    WEnd
EndFunc  ;==>WAVE_DOWN
; Wave Functions End
;*******************************************************************

;*******************************************************************
; Master Functions Start
Func MASTER_VOLUME_MUTE();Master Volume Mute by pressing Alt + Numpad 5
    $MasterMute = Not $MasterMute
    While $MasterMute
        Sleep(100)
        If $Master_Mute_Status = 0 Then
            _SoundSetMasterMute(1)
            $MasterMute = Not $MasterMute
        ElseIf $Master_Mute_Status = 1 Then
            _SoundSetMasterMute(0)
            $MasterMute = Not $MasterMute
        Else
            $MasterMute = Not $MasterMute
        EndIf
    WEnd
EndFunc  ;==>MASTER_VOLUME_MUTE

Func MASTER_VOLUME_UP();Master Volume Up by pressing Alt + Numpad 9
    $Master_Up = Not $Master_Up
    While $Master_Up
        Sleep(100)
        $Master_Volume_Status += 5
        If $Master_Volume_Status < 105 Then
            _SoundSetMasterVolume($Master_Volume_Status)
            $Master_Up = Not $Master_Up
        Else
            $Master_Up = Not $Master_Up
        EndIf
    WEnd
EndFunc  ;==>MASTER_VOLUME_UP

Func MASTER_VOLUME_DOWN();Master Volume Down by pressing Alt + Numpad 3
    $Master_Down = Not $Master_Down
    While $Master_Down
        Sleep(100)
        $Master_Volume_Status -= 5
        If $Master_Volume_Status > -5 Then
            _SoundSetMasterVolume($Master_Volume_Status)
            $Master_Down = Not $Master_Down
        Else
            $Master_Down = Not $Master_Down
        EndIf
    WEnd
EndFunc  ;==>MASTER_VOLUME_DOWN
; Master Functions End
;*******************************************************************

SoundGetSetQuery.au3

Share this post


Link to post
Share on other sites
somdcomputerguy

Depending on your OS, you might can use this (with Send) for Main volume control,

{VOLUME_MUTE} 2000/XP Only: Mute the volume 
{VOLUME_DOWN} 2000/XP Only: Reduce the volume 
{VOLUME_UP} 2000/XP Only: Increase the volume

(the commands above also work for me with Vista)

I use ControlSend directly to a media player to manage it's volume level

Also I have used code like this to control main volume..

Run("sndvol.exe", "", @SW_HIDE)
WinWaitActive("Volume Mixer")
ControlSend("Volume Mixer", "", "msctls_trackbar321", "{END}")

{END} sets vol to 0, {HOME} to 100, {UP} and {DOWN} for increments, "m" to mute

Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.