For the record, here is the final code wrapped into a subroutine.
sub getSoundVolume { #usage: $tpcnt=getSoundVolume($hwnd) or ($tpcnt,$lpcnt,$rpcnt)=get +SoundVolume($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; }
In reply to Re^2: Output syntax for waveOutGetVolume API
by slloyd
in thread Output syntax for waveOutGetVolume API
by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |