Here's a (slightly trimmed) script I use to control Winamp:
#!c:/perl/bin/perl -w use strict; use Win32::API; use constant WM_USER => 1024; use constant WM_COMMAND => 273; my %commands = ( PREV => 40044, NEXT => 40048, PLAY => 40045, PAUSE => 40046, STOP => 40047, # Lots of other commands trimmed for space... ); my $cmd = uc shift; if (exists $commands{$cmd}){ my $FindWindow = new Win32::API( 'user32', 'FindWindow', ['P', 'N'], 'I' ); my $SendMessage = new Win32::API( 'user32', 'SendMessage', ['I', 'I', 'I', 'I'], 'I' ); my $hwndWinamp = $FindWindow->Call('Winamp v1.x', 0); $SendMessage->Call( $hwndWinamp, WM_COMMAND, $commands{$cmd}, 0 ) if $hwndWinamp; } else { print "Invalid command.\n"; }
The most useful Winamp related script I have is the one that locks my computer and pauses Winamp. This snippet checks to see if Winamp is currently playing, and if so sends a "pause" command:
if ($hwndWinamp){ if ($SendMessage->Call($hwndWinamp,WM_USER,0,104) == 1) { $SendMessage->Call($hwndWinamp,WM_COMMAND,40046,0); } }

--grummerX


In reply to Re: Re: Perl Mp3 Player by grummerX
in thread Perl Mp3 Player by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.