Sign in to follow this  
Followers 0

Set System Volume

1 post in this topic

So this is my first attempt at a UDF so apologies if it is terrible or if this has been posted before.

I've seen this question asked a few times and as of yet, I dont think there's a way to do this in Autoit3, so i've had to implement the use of an externally made program.

This requires the presence of the nircmd.exe tool in the C:\windows folder, this may be obtained here:

Once this has been inserted, you should be able to use the UDF:


#include <Process.au3>

;Syntax: _SetSysVol(*Percentage of Total Volume to set*)

Func _SetSysVol($sPercent)
While 1
If $sPercent > 100 Then
MsgBox(0, "Error", "Percentage Value Exceeded")
If Not FileExists("C:\Windows\nircmd.exe") Then
MsgBox(0, "Error", "Nircmd.exe is not present in the Windows Directory")
Global $sDecimal = ($sPercent * 0.01)
Global $newVol = ($sDecimal * 65535)
If StringIsDigit($newVol) Then
Global $sCommand = "nircmd setsysvolume " & $newVol
Global $run = _RunDos($sCommand)
ElseIf StringInStr($newVol, ".") <> 0 Then
$newVol1 = StringSplit($newVol, ".")
Global $sCommand1 = "nircmd setsysvolume " & $newVol1[1]
Global $run1 = _RunDos($sCommand1)
MsgBox(0, "", "Percentage is not Valid")
EndFunc   ;==>_setSysVol


#include <SetVol.au3>

Again, I am but a mere novice in Autoit (Hence the name) and there are probably neater ways of doing this, but it works for me :)

note: I do not own nircmd, all credit goes to the Nirsoft team for this utility.

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  
Followers 0