Jump to content

Recommended Posts

Posted (edited)

When there are more than four programs that use the sound mixer, the Volume Mixer window does not resize automatically, so I decided to script a simple solution.  So the way I use this is to use the blue speaker icon and then pin that to my taskbar.  Also, clicking the icon while the script is running will also close the window without having to reach for the x.

Edit: Forgot to mention that I've only ever used this on Windows 7 Pro x64.

Update: 6/22/2014 -- Updated with AdmiralAlkex's suggestion.  Plus a minor code improvement.

Enjoy!

#include <StringConstants.au3>

#include <Misc.au3>

Global Const $title = "Volume Mixer"

Switch _Singleton(@ScriptName, 1)
  Case 0
    WinClose($title)
    Exit
EndSwitch

Opt("WinDetectHiddenText", True)

_main()

Func _main()
  Local Const $volume_mixer_pid = Run("SndVol.exe")

  Switch $volume_mixer_pid <> -1
    Case True
      WinWaitActive($title)
      
      Local Const $default_width = WinGetPos($title)[2]
      
      Local Const $control_threshold = 3      

      Local $control_count = 0

      While ProcessExists($volume_mixer_pid)        
        Switch _get_text($control_count)
          Case True
            $control_count += 1
            
          Case False
            Switch $control_count >= $control_threshold
              Case True   
                _resize_window($default_width, $control_count, $control_threshold)                                
                
                If @error Then Return SetError(1, 0, False)
                
                $control_count = 0
            EndSwitch
        EndSwitch

        Sleep(100)
      WEnd
  EndSwitch
EndFunc

Func _resize_window(Const $default_width, Const $control_count, Const $control_threshold)                        
  Local Const $x = WinGetPos($title)
 
  If @error Then Return SetError(1, 0, False)
                  
  Local Const $new_width = $default_width + (($control_count - $control_threshold) * 110)    
                
  Switch $new_width <= (@DesktopWidth - $x[0])
    Case True
      WinMove($title, '', Default, Default, $new_width)
  EndSwitch
EndFunc

Func _get_text(Const $control_count)
  Local Const $text = StringStripWS(WinGetText($title), ($STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES))
 
  Return StringInStr($text, "Volume for", 0, ($control_count + 1)) > 0
EndFunc
Edited by jaberwacky
Posted

No, not randomly. Open a dozen+ media players and see what I mean. If you stop growing at @DesktopWidth then the user can scroll to the many that doesn't fit the screen, which would be more comfortable than moving the window around to see the rest.

Posted

There's some application I have (VMware Workstation?) that spazzes out and does this to me. For some reason it doesn't clean up after itself (until it's completely shut off) so there's tons of VMware volumes in the mixer but only 1 work... It's not fun finding the one that works when you only see 3 of them :P. I will keep this script around for those occasions ;)

  • 3 weeks later...
Posted

I think there might still be a bug, or is this how you intended it to work?

Good:

Start the script and spam music players: properly expands until the screen if filled.

Bug?

Spam music players then start the script afterwards. No resize at all.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...