[shell-coding] Coding Solution to WA3 and Advertising
- From: Paradox <paradox5555@xxxxxxxxxxx>
- To: Litestep Mailing List <litestep@xxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Aug 2002 17:35:24 -0400
My friend at Spinner agreed to share code to help us get a Winamp 3
geekamp going, provided that I do some free advertising on the LS
mailing list, so with that in mind
PLEASE CHECK OUT WINMAPPER!
www.spinner.nl
It's a very nice Windows hotkey manager with full support for
multimedia keys, modifiers, key sequences, ect. It has built in
support for Winamp (including Winamp 3 as of the new build coming out
today). It can call hotkeys from any program without changing focus,
so those of you that like to play mp3's/music while inside of games,
this program is perfect for you. It also supports sending key
sequences, and running programs with modifiers, so you can easily use
bang.exe to call litestep functions from winmapper hotkeys.
There is a 30 day trial available on the site, it's $19.99 to
register (and well worth it IMHO). The people at spinner are really
kewl, kewl enough to SHARE CODE with me for the benefit of the LS
community, so please at least check the program out and register it
if you plan to use it.
Ok with that out of the way, here's the e-mail he sent me that
explains how he controls winamp 3 by sending keystrokes to it,
hopefully someone will be able to use this info to update Geekamp or
write a new module. This same process DOES work with Winamp 2 as
well, so if someone writes a module using this method it should in
theory work on all versions of winamp. If you use this technique,
please cite "Spinner.nl" in special thanks or whatever, they're a
small software company and need all the help they can get ;-)
--- Original Message ---
From: "Nicolai Kjaer" <nic@xxxxxxxxxx>
To: 'Paradox' <paradox5555@xxxxxxxxxxx>
Cc:
Sent: Sat, 10 Aug 2002 23:15:33 +0200
Subject: Coding for Winamp 3
>Anyway, here's a short version of what to do, with notes and
comments
>thrown in:
>-----
>Controlling Winamp 3.x from code
>
>First, you need a function that finds the main Winamp window. With
>version 1/2, this is a window with the class name of 'Winamp v1.x',
>so
>you can get a handle to it through the standard Win32 API function
>FindWindow(classname, windowname) and then post messages to it.
>With Winamp version 3, the overall window has a classname of
>'STUDIO'.
>
>Shot list:
>Target Class name
Window name
>Notes
>Winamp 1/2 Winamp v1.x
>Winamp v3 STUDIO
>Winamp v3 playlist BaseWindow_RootWnd Playlist
>handle.child.lastwindow
>Winamp v3 navigation BaseWindow_RootWnd 'normal'
>handle.parent
>
>The playlist (for Playlist home/end) is special; you need the
correct
>control in order to post the keysequence. Once you have the Playlist
>window handle, get the first child, then the last window on that
>child.
>This is done through standard Win32 API's GetWindow function:
> hPlaylist := FindWindow('BaseWindow_RootWnd',
>'Playlist');
> hPlaylist := GetWindow(hPlaylist, GW_CHILD);
> hPlaylist := GetWindow(hPlaylist, GW_HWNDLAST);
>
>For the navigation window (for Volume Up/Down), get and use the
>parent
>window handle on the window handle you found:
> hNav:=FindWindow('BaseWindow_RootWnd', 'normal');
> if(hNav <> 0) then hNav:=GetParent(hNav);
>
>For the normal keystrokes, just use the main Winamp window handle.
>
>Examples:
> // Winamp handle
> hWinAmp1:=FindWindow('Winamp v1.x', nil);
> hWinAmp3:=FindWindow('STUDIO', nil);
> // Playlist handle
> hPlaylist:=FindWindow('BaseWindow_RootWnd', 'Playlist');
> if(hPlaylist<>0) then begin
> hPlaylist := GetWindow(hPlaylist, GW_CHILD);
> hPlaylist := GetWindow(hPlaylist, GW_HWNDLAST);
> end;
> // Navigation handle
> hNav:=FindWindow('BaseWindow_RootWnd', 'normal');
> if(hNav <> 0) then hNav:=GetParent(hNav);
>
>Once you have all the window handles, you just need to send the
right
>keystrokes to the right window. An example of how to send a single
>character (asciiChar) to Winamp v3 is provided here:
>
> // Get virtual key code and scancode for the character
> key:=(VkKeyScan(asciiChar) AND $FF);
>scancode:=MapVirtualKey(key, 0);
> if scancode = 0 then scancode:=OemKeyScan(Ord(asciiChar));
> // Modify scancode to correct position. repeatCount must be >=
>1.
> scancode:=(scancode SHL 16) + repeatCount;
> // Get handle to winamp
> hWinAmp3:=FindWindow('STUDIO', nil);
> if(hWinAmp3 <> 0) then begin
> // Post key down, char, up messages
> PostMessage(hWinAmp3, WM_KEYDOWN, key, scancode);
> PostMessage(hWinAmp3, WM_CHAR, Ord(asciiChar),
>scancode);
> PostMessage(hWinAmp3, WM_KEYUP, key, ($C0000000) AND
>(scancode));
> end;
>
>Most of the basic functionality is available through hotkeys. For
the
>volume, I post 5 x VK_UP/DOWN messages to the Navigation window
>(this is
>roughly 10% change); for the Play list home/end, I post VK_HOME/END
>followed by a VK_RETURN to the Playlist window. For all the other
>functionality we post the characters to the main window.
>
>If the hotkey is CTRL+D for example: post a key down for the CTRL,
>then
>the key down/char/up for the ascii char ("D"), then the key up for
>CTRL.
>
>A note on auto-starting Winamp 3: I find it very slow compared to
v2,
>and had to build in support for waiting until the Winamp 3 window
was
>actually visible, and then wait another 2 seconds before firing the
>command. You can determine when the window is [supposedly] visible
by
>examining the return value of GetWindowLong(handle, GWL_STYLE):
> if(GetWindowLong(hWinAmp, GWL_STYLE) AND WS_VISIBLE)=0 then //
>Not ready yet, wait
>
>To start Winamp, create a temporary file with an .mp3 extension,
then
>use the standard Windows function (FindExecutable) to get the
>associated
>program for it. Run that program. Winamp v3 also has support for
>command
>line parameters, so you can start it with a specific file or
playlist
>and so forth. There might also be a registry key that points to the
>executable for Winamp3.
>
>-----
>
>And that's it :-). Simple, but effective. I hope it helps - just let
>me
>know if you have any questions :).
>
>Kindly,
>Nicolai Kjaer
>CEO, spinner.nl
>
__________________________________________________
Subscription options and archive:
http://www.freelists.org/list/shell-coding
- Follow-Ups:
- [shell-coding] Re: Coding Solution to WA3 and Advertising
- From: Kevin Schaffer
Other related posts:
- » [shell-coding] Coding Solution to WA3 and Advertising
- » [shell-coding] Re: Coding Solution to WA3 and Advertising
- [shell-coding] Re: Coding Solution to WA3 and Advertising
- From: Kevin Schaffer