sub getSoundVolume { #usage: $tpcnt=getSoundVolume($hwnd) or ($tpcnt,$lpcnt,$rpcnt)=getSoundVolume($hwnd); #info: gets sound volume - $tpcnt is a number from 0 to 100. my $hwnd = shift || 0; my $vol=" "x10; $waveOutGetVolume ||= new Win32::API("Winmm", "waveOutGetVolume", ['N','P'], 'N') || return; my $ck = $waveOutGetVolume->Call($hwnd, $vol); my ($leftVol,$rightVol) = unpack 'vv', $vol; my $leftPercent = int($leftVol * 100 / 0xffff); my $rightPercent = int($rightVol * 100 / 0xffff); my $totalVolPercent = int(($leftPercent+$rightPercent)/2); if(wantarray){return ($totalVolPercent,$leftPercent,$rightPercent);} return $totalVolPercent; }