Winamp

From Enso Wiki

Jump to: navigation, search
  • NOTE: This command is written for Command Server not as a stand alone command
  • NOTE: This command requires pywin32

[edit] Usage

  • winamp - The base command
    • prev - Move to the previous Track
    • next - Move to the next Track
    • play - Play the track or resume play
    • pause - Pause the Track
    • stop - Stop the Track
    • forward - Fast forward a little bit
    • rewind - Rewind a little bit
    • raisevol - Increase the volume
    • lowervol - Decrease the volume
    • + - Increase the volume
    • - - Decrease the volume

[edit] Code

from base import BaseCommand
import win32api
import win32gui
 
WM_COMMAND = 0x0111
WM_USER    = 0x400
 
 
class Command(BaseCommand):
    def __init__(self, *args):
        BaseCommand.__init__(self, *args)
 
        self.newBoundedCommand("winamp {command}",
                                self._winamp,
                                "Control Winamp",
                                "<p>Lets you control Winamp via enso</p>",
                                ["prev", "next", "play", "pause", "stop", "forward", "rewind", "raisevol", "lowervol", "+", "-"]
        )
 
        self.winampCommands = {"prev"      :40044,
                                "next"      :40048,
                                "play"      :40045,
                                "pause"     :40046,
                                "stop"      :40047,
                                "forward"   :40157,
                                "rewind"    :40148,
                                "raisevol"  :40058,
                                "lowervol"  :40059,
                                "+"         :40058,
                                "-"         :40059}
 
    #Command Methods
    def _winamp(self, command):
        hWinamp = win32gui.FindWindow('Winamp v1.x', None)
 
        if self.winampCommands.has_key(command):
            return win32api.SendMessage(hWinamp, WM_COMMAND, self.winampCommands[command], 0)
        else:
            raise AssertionError("Unknown Winamp Command, try again")