Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Perl Mp3 Player

by grummerX (Pilgrim)
on Sep 19, 2002 at 10:44 UTC ( [id://199129]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl Mp3 Player
in thread Perl Mp3 Player

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://199129]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found