Hansio

Set Windows volume

6 posts in this topic

I use MPC-HC to play my movies. Is it possible to create a script that sets Windows volume to 100% and back again when MPC-HC close?

Something like setting the volume to 100%

Start mpc-hc.exe

Set the volume back

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Sadly there is no way (at the moment) to detect what volume windows is at through AutoIt.

As for setting the volume to 100%, you can do that by doing something like:

For $i To 100 Step +1
Send("{VOLUME_UP}")
Next
; Run("...Directory/Mpc.hc.exe")
Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

I use code like this to increase the windows volume to 100%

Switch @OSVersion
        Case "WIN_VISTA", "WIN_7"
            Run("sndvol.exe", "", @SW_HIDE)
        Case "WIN_XP"
            Run("sndvol32.exe", "", @SW_HIDE)
EndSwitch
WinWaitActive("Volume Mixer")
ControlSend("Volume Mixer", "", "msctls_trackbar321", "{HOME}") ; Max system volume
WinClose("Volume Mixer")
1 person likes this

- 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

@somdcomputerguy I tried your code, because I should learn to use ControlSend. The window on my XP is "Volume Control", but anyway...

Thinking about how to read volume level, Window Info for msctls_trackbar32 has ControlClick Coords: 24, 53, and these change with the volume. I don't know how to get these in code. Alternatively, use PixelGetColor and crawl up the control until you find the slider.

Richard

Share this post


Link to post
Share on other sites

Hi,

This might be useful to someone, this a full implementation; if you find it useful use it:

#include <MsgBoxConstants.au3>

MsgBox(64, "Easter", "You have entered the program", 30)


; Set volume to 100% (Windows actually does 2 steps increments for the volume)
Local $i = 0
While $i <= 50
    Send("{VOLUME_UP}", 0)
    $i = $i + 1
WEnd

; Sets the system wave volume to 100%. This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.
SoundSetWaveVolume(100)

; Play one of the default sytem sounds
SoundPlay(@WindowsDir & "\media\tada.wav",1)

MsgBox(64, "Easter", "The previous sound was played at 100%, the next one will be at 50%", 30)

; Set volume from 100% to 50%
Local $i = 0
While $i <= 25
    Send("{VOLUME_Down}", 0)
    $i = $i + 1
WEnd

; Sets the system wave volume to 100%. This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.
SoundSetWaveVolume(100)

; Play one of the default sytem sounds
SoundPlay(@WindowsDir & "\media\tada.wav",1)


MsgBox(64, "Egg", "You are leaving the program", 30)

 

1 person likes this

---
vicsar
https://about.me/vicsar
 

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

On 2016. 6. 2. at 3:21 AM, vicsar said:

Hi,

This might be useful to someone, this a full implementation; if you find it useful use it:

#include <MsgBoxConstants.au3>

MsgBox(64, "Easter", "You have entered the program", 30)


; Set volume to 100% (Windows actually does 2 steps increments for the volume)
Local $i = 0
While $i <= 50
    Send("{VOLUME_UP}", 0)
    $i = $i + 1
WEnd

; Sets the system wave volume to 100%. This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.
SoundSetWaveVolume(100)

; Play one of the default sytem sounds
SoundPlay(@WindowsDir & "\media\tada.wav",1)

MsgBox(64, "Easter", "The previous sound was played at 100%, the next one will be at 50%", 30)

; Set volume from 100% to 50%
Local $i = 0
While $i <= 25
    Send("{VOLUME_Down}", 0)
    $i = $i + 1
WEnd

; Sets the system wave volume to 100%. This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.
SoundSetWaveVolume(100)

; Play one of the default sytem sounds
SoundPlay(@WindowsDir & "\media\tada.wav",1)


MsgBox(64, "Egg", "You are leaving the program", 30)

 

Thank you

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