Noviceatthis Posted April 2, 2013 Posted April 2, 2013 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:http://www.nirsoft.net/utils/nircmd.htmlOnce this has been inserted, you should be able to use the UDF:SetVol#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") ExitLoop EndIf If Not FileExists("C:\Windows\nircmd.exe") Then MsgBox(0, "Error", "Nircmd.exe is not present in the Windows Directory") ExitLoop EndIf Global $sDecimal = ($sPercent * 0.01) Global $newVol = ($sDecimal * 65535) If StringIsDigit($newVol) Then Global $sCommand = "nircmd setsysvolume " & $newVol Global $run = _RunDos($sCommand) ExitLoop ElseIf StringInStr($newVol, ".") <> 0 Then $newVol1 = StringSplit($newVol, ".") Global $sCommand1 = "nircmd setsysvolume " & $newVol1[1] Global $run1 = _RunDos($sCommand1) ExitLoop Else MsgBox(0, "", "Percentage is not Valid") ExitLoop EndIf WEnd EndFunc ;==>_setSysVolExample#include <SetVol.au3> _setSysVol(40)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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now