Winamp & Shoutcast Forums gen_action

24th August 2004, 07:53   #1
shaneh
Major Dude

Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
gen_action

A quick pluggy to do what Ive been meaning to do for ages. It was whipped up in about 10 mins so its got all my usual lack of class.. :P

It uses ShellExecute(..) to do up to five different actions on a right clicked item in the playlist, with the help of ATF. Edit actions.ini to define them.

I'll add hotkeys later on. Hitting a hot key will perform a given action on the currently playing item instead of having to right click it. I should make the limit as many as you like too.

With the help of rundll32 you can do quite a few things with this... left as an exercise.
Attached Files
 gen_action.zip (4.7 KB, 4339 views)

 24th August 2004, 13:45 #2 inthegray Major Dude     Join Date: Sep 2003 Posts: 704 nice. i played around a bit (added a "Google for Song Lyrics"), and i'd like to see what else you can do with this. glad to see you working on stuff again.
 25th August 2004, 22:06 #3 CaAl Junior Member   Join Date: Apr 2004 Location: NL Posts: 23 Great! I've been looking for this for quite some time, thanks!!! I'll appreciate a hotkey-update as well :-p
 26th August 2004, 00:01 #4 billyvnilly Forum King, M.D.     Join Date: Mar 2004 Location: Detroit burbs Posts: 3,379 great plugin idea....me likes submenus lots and lots. but a few options are not working for me i just downloaded it into a fully pluginloaded wa5 though. i also use firefox as default. "Audioscrobbler for Artist" opens in firefox, "Musicmobs artist" opens in IE, and "find in explorer" does work, the others dont. btw, Just mentioning that find file on disk by Dro has hotkey Ctrl+f, pehaps when u get to it, use that if possible. Win XP PRO 5.04 many plugins Firefox 0.9.3 as default browser
 26th August 2004, 01:08 #5 inthegray Major Dude     Join Date: Sep 2003 Posts: 704 billy, you can configure it all in the .ini file, by opening it in notepad. a quick glance is all it'll take to figure out what to do.
 26th August 2004, 01:35 #6 billyvnilly Forum King, M.D.     Join Date: Mar 2004 Location: Detroit burbs Posts: 3,379 omg i love this plugin! thanks for the tip about the .ini inthegrayoops i apologize i didnt read shaneh's entire thread i shoulda caught that[/edit] disregard previous post...thx shaneh
 26th August 2004, 10:27 #7 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 Just installed gen_action. Nice little pluggy heh... The only thing I hate about it, is that it's not my creation.
 26th August 2004, 11:01 #8 CaAl Junior Member   Join Date: Apr 2004 Location: NL Posts: 23 I've been playing with gen_action for a while, and it's great. I've got a huge database (in textfile) with hits and the year of release on my pc; and via FINDSTR %title% I can easily look up the year of a song and edit it's ID3 tag. Two requests: - can the Action!functionality also be added to songs in my library? - can it be used on multiple files? If I select k files and do Action!, it only does it for the song my cursor is on; instead of opening k windows, which I'd prefer
 26th August 2004, 11:34 #9 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Ok, thanks guys. Ive been meaning to do this simple plugin for ages, have finally got around to doing something at least. Its similar to the kind of thing I had planned for 'mouse actions' in Toaster. However the newer Toaster, HTML edition may make this redundant - though I am still thinking about exactly what I am going to do there. Id like to add scripting without the HTML part as well.. For example, you could make an action which executes a 'winamp script' which can interact with winamp. You could for example write a very simple 1 line action script such as wa.Randomize(wa.getSelected()) Which would randomize the selected items. Or something like. wa.EnqueFromML(wa.getSelectedATF(%artist%)) Which would enqueue all songs from the ML given the selected items artist tag. You could write scripts which do pretty much anything really. As a complex example, you could write a script which connects to Audioscrobbler and looks up a particular artist, finds the top song for that artist, finds it in your ML and enqueues it. All with a few lines of script and accessible from right clicking an item in winamp. I realised it was quite a waste to release heaps of little plugins which basically are just all the same code, with one small difference (rate a song, change its playcount, find it in explorer, locate it on a web site, generate a sig file etc). And figured one plugin which could be scripted to do all these things and more would be better. Id suspect it would be quite powerful, basically let you extend winamp in the same way you can extend office apps with VBA - will be done in exactly the same way actuaally. I have the know-how, just not the time Quite a few design considerations however. Anywho... A couple things Ive been considering.. +Hot keys for the actions +Flags to indicate the action should be done to the song on song change. (makes making sig file generation easy for eg.) +Multiple items, by using the 'send to' functionality - would also make it available in the ML with no extra effort. A couple problems when using multiple items however. Some programs take multiple items as multiple command line arguments, whereas others should be execute n times.ie. a] musicbrainz songa.mp3 songb.mp3 songc.mp3 b] http://www.google.com/q=artist1 http://www.google.com/q=artist2 Theres a few complications in handling these various scenarios. Last edited by shaneh; 26th August 2004 at 12:03.
 26th August 2004, 13:19 #10 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 Maybe you could take the source-code for the NSIS installer and use a similar script language except compiled/executed on-the-fly. I mean borrow the code from it. You could also use ActiveX scripting so people can code such script in both VBScript and JScript. Implement a object called WA with methods similar to all the IPC_ messages and events (OnStop, OnPlay, OnNext). This could grow into a very huge module. Maybe people would never again need to develop/download a separat plug-in, just write the lines of script neccessary to do the wanted action. I would gladly work together with you on such a project. E-Mail me Shane Hird!!!
 26th August 2004, 13:36 #11 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Yeah, I would use the IActiveScript stuff, Ive looked into it a bit, its not too difficult. That Winamp HTML project uses similar sort of tech, just its accessed through window.external instead. Take a look at it in this forum if you havent already. The problem with that is its HTML orientated, requires it be rendered using a browser object etc and be running. Plus I am having difficulty securing window.external from remote sites hosted in a frame of a trusted site. I think making it an actualy object would be better. Basically just raw script would be nicer, but having HTML does have the advantage of having a way to output stuff, render images, have input (buttons), frames etc. What would be good is a generic ActiveX object which you can use in a script, or in a HTML page. This kind of already exists (theres a winamp COM object somewhere, but I dont think it supports events). So its kind of already been done in some respects, but it really needs to be done in process, invoked from winamp (and kept running) and have events. Plus the ability to manually invoke scripts with arguments (ie 'action' commands). Oh.. and I dont want to duplicate the efforts of all what is possible using wasabi/maki etc stuff either. I dont use modern skins, so this is something I have to be careful of, as I am not that familiar with it. I am trying to think of a neat way to be able to do all of the above. Although this 'VBA' type of arch would make many very simple plugins possible without having to develop native plugins, there would still be a need for native plugins for many things. Its too late now, but a nice COM architecture would have been much nicer for plugin development, like wmp I guess. But its a fair bit harder and there probably wouldnt be so many plugins. Last edited by shaneh; 26th August 2004 at 14:01.
 26th August 2004, 15:24 #13 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Yeah it will be available for the ML eventually. It will have to be on the Send To menu, as there is no practical way to get the selected item in the ML. This may cause some complications, and I still havent decided how to deal with multiple items yet. Imagine clicking send to 'google search' for the root of your mp3 collection and having 10,000 browser windows open up :P. Obviously it needs to be handled somewhat intelligently. Ideally this scripting stuff would take care of that, but that could be a while off.
 26th August 2004, 15:52 #14 DAVOR Junior Member   Join Date: Aug 2003 Location: Croatia Posts: 32 Sorry about my english. It is better then nothing (Send To. Multiple items: It will happen only once, next time the user will not select 10,000 items. Please (ML)
 27th August 2004, 10:29 #15 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 Re: ActiveX scripting I did not think of ActiveX scripting inside a browser (Internet Explorer) process, but Windows Script Host. Here is a VBScript that can be executed by WSH: Dim wsh Set wsh = CreateObject("WScript.Shell") ' And theretically using a Winamp COM object: Dim wa Set wa = CreateObject("Shaneh.Winamp") wa.PlayFile "c:\music\song.mp3" wa.Volume = 128 Dim vol vol = wa.Volume And so on.... It will only be the task of creating a object for executing this script inside Winamp without the help of wscript.exe/cscript.exe. You can check out www.microsoft.com/msdn if you don't know a lot of Windows Script Host and ActiveX scripting. Internet Explorer uses ActiveX scripting to execute VBScript and JScript (JavaScript) embedded between
 27th August 2004, 10:41 #16 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Yep, thats what I was talking about, using IActiveScriptSite etc. Except it wouldnt be necessary to call 'createobject' like that, you can call 'AddNamedItems' or something to automatically add objects to the namespace. This way it doesnt require registering the object, and allows you to add existing objects - which would be the case when it is already running in process of winamp. The reason I mentioned ActiveX etc is because I would also like to be able have HTML GUI stuff as well (so I can use it to create a new Toaster version for example). There isnt much difference between ActiveX objects and any other COM objects. But scripts hosted in a browser object can have an interface with buttons, forms, frames, HTML rendering with images etc. Making an object that could be hosted in either HTML or within WSH would be good, but Im not sure how to do that without registering the object in the registry, or how to make it so its hosted in process with winamp. (Although I think its not too difficult to just add the object to the web browsers script namespace, in the same way you add it to a hosted script namespace). But it does mean having two different ways of invoking and handling scripts (web browser hosted scripts, and just regular scripts) which is a bit messy. Anyway, it doesnt matter too much, because I realise its not too difficult for a script to create a InternetExplorer.Application object, and script that, as well as recieve events from it etc. Although it would be a fair bit more work to allow the scripting of a browser object hosted in the media library for example. (Although it would allow for HTML rendering without the IE chrome, required to create a 'Toaster' window for example). That Winamp HTML stuff I created is actually very similar to what you describe and what I plan to do. The only difference is the object is available through window.external instead of some other name, and it requires the web browser object to host the scripting instead of hosting it myself. I have shown how to have events, properties, methods etc. Last edited by shaneh; 27th August 2004 at 11:13.
 27th August 2004, 13:11 #17 DAVOR Junior Member   Join Date: Aug 2003 Location: Croatia Posts: 32 Shaneh, can You make plugin that will write in some "fileML.txt" filename selected in ml, and filename selected in PlayList "filePL.txt", because we in vb can't read this from winamp. I think that this is not a big problem for You, but it is for us that only know to work in VB.
 27th August 2004, 13:31 #18 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Im not quite sure what you are talking about. If you are referring to getting the selected file in the playlist when using a plugin, it involves a bit of a trick. Take a look at ipc_pe.h, and the IPC 'IPC_PE_GETIDXFROMPOINT'. I am not really getting the selected file at all, simply getting the index of the playlist entry (using IPC_PE_GETIDXFROMPOINT) located at the mouse location when the right mouse button is pressed. There is no IPC for getting the selected items, unless you create a media library plugin which adds items to the 'send to' menu. There is also a method of using window hooks and faking a 'playlist entry' command and intercepting the created dialog etc. I dont like this method, but I think DrO has some info on it somewhere.
 27th August 2004, 13:52 #19 DAVOR Junior Member   Join Date: Aug 2003 Location: Croatia Posts: 32 'IPC_PE_GETIDXFROMPOINT' this is very hard to do from VB, i have read the most of Treads out there, but none did solve problem with 'IPC_PE_GETIDXFROMPOINT' and VB. So it will be easier if someone could do the trick from C. When selection, or right mouse click happens simply write selected filename (ML), or index of selected (PL) to text file. In this case all other programers could whith this plugin get the selected files. Simply whith timer control see if contex of text files has changed, if is, the selection or right mouse click has ocured (changed).
 27th August 2004, 14:19 #20 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 It should be possible, if you are doing it from an external app, you will need to use 'ReadProcessMemory', or tricks with "WM_COPYDATA" in order to read the filename out of process. You also need to make sure you are subclassing the playlist rather than the main window to obtain the mouse click messages. As for the ML, as I said, there is no method to get the selection other than using the send to menu. Anyway, the plugin I am working on will allow this (to the extent of what is possible in winamp) and much more to be done in a couple lines of script. I have no idea of the when this will be done however.
 30th August 2004, 13:25 #21 siebe83 Forum King     Join Date: Feb 2004 Posts: 9,229 Great plugin! Just a question: is the number of menu entries limited to 5? I cannot get the sixth to work... If you're bored go here or, if the boredom is more serious, here.
 30th August 2004, 13:32 #22 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Yep, its limited to 5. I'll work on this plugin later, it will allow dynamic number of items, hot keys, acting on currently playing song etc.
 30th August 2004, 13:40 #23 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 You can create a ActiveX COM Object that will run on itself. And then this can be accessible from .vbs files and the like. This object can call into Winamp using a stub "gen_scriptstub.dll, for example.... What's the objects and the methods of "gen_script1.dll" whic you are working on??
 30th August 2004, 13:52 #24 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Yeah, you could do that. But I think hosting the engine native would be better, the way Im doing it. You only want to run stuff while winamp is open anyway. Plus it saves on marshalling stuff across process boundries. It makes it easier to have the object do events too, without the need for signalling through a stub. There is a COM control out there which does the basic play stop etc. What I am working on will do a fair bit more than that, it will allow all the ATF stuff, events, media library querying, skin changing etc. Plus it will allow adding items to the send to menu etc which then fire callbacks. Or at least will allow adding items which then invoke scripts which carry out the action and then quit. I briefly outlined the objects in the scripting thread, but there isnt much atm. I am working on the internal object and memory management, COM wth automation in C++ isnt the easiest of things.
 30th August 2004, 13:57 #25 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 Yeah, okay! Anal retendent! No offense, really! Do you know how we can communicate a little bit faster, than though these fourms. My schools firewall block all Messenger services (MSN, AOL, e.t.c) and IRC i also blocked. Is there a site with a Java chat you and me can use??
 30th August 2004, 14:08 #26 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Im not sure I understand what you mean by that? Either way, it wouldnt be too difficult to modify it to make it act as an activex control. You would just need to register it, and have the class factory start winamp to get the object. But I like the fact it doesnt touch the registry, and is self contained to be accessible only by the environment which should be using it. Though being able to automate from other applications/html pages could be cool. You could always email me at shanehird with the mx yahoo.com. But I like forums, gives me a chance to formulate my replies, and edit them :P And gives me some time in between to do some coding
 30th August 2004, 14:23 #27 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 The stuff between and was just a bad joke! "Automation object" that's the name of it! You see, I have created automation objects before. BASS is a DLL file which contains functions for outputting sound and decoding MP3/OGG and Music Modules (MOD,S3M,XM,e.t.c). So I made an ActiveX Automation object called "bassax.bass" which could be called from VBScript to play MP3 files. It can be called from scripts inside HTML documents or from a VBS file called by Windows Script Host. * END of BASS talk! * Try this: 1. Save the following code as "sc.vbs" on the desktop. code: Dim WshShell, fs, oShellLink, path If WScript.Arguments.Count < 1 Then WScript.Echo "Usage: sc.vbs " WScript.Quit End If set WshShell = WScript.CreateObject("WScript.Shell") set fs = WScript.CreateObject("Scripting.FileSystemObject") set oShellLink = WshShell.CreateShortcut(WScript.Arguments(0)) path = oShellLink.TargetPath If fs.FolderExists(path) Then WshShell.Run "explorer.exe " & path Else WshShell.Run "explorer.exe /select," & path End If  2. Now drag a shortcut file to it. 3. The shortcut's target will be highlighted in a new Explorer window. Nice, don't you think. And I'm the author of it. I tried to use code: set WshShell = WScript.CreateObject("WScript.Shell") set fs = WScript.CreateObject("Scripting.FileSystemObject")  with gen_script1.dll and it worked fine!
 31st August 2004, 06:31 #28 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Yeah, it will work fine. Although I thought WScript was an object only available at startup to .vbs etc files, and would need to be created under gen_script. But whatever. You don't need the wscript. in fron of createobject however. Look in the winamp scripting thread for an example of navigating iexplorer and manipulating ms word. You could do anything with any object, for example copy files somewhere when they are played, or modify a .pls file to include the currently playing item or whatever you like. You could write a script which e-mails the current playcount of the current playing item with the attached album cover and a link to it on amazon to your grandmother if you really wanted.
 31st August 2004, 10:51 #29 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 OFFTOPIC Did you try the sc.vbs file?? You must associate it with .lnk files in the registry like: HKLM\lnkfile\shell HKLM\lnkfile\shell\opentarget = "Open link target" HKLM\lnkfile\shell\opentarget\command = "c:\path\to\sc.vbs "%1"" ONTOPIC I have downloaded the activeXExample from microsoft.com, but how do I put it into the classview so it is easier to edit. I'm also trying to write a script plug-in for Winamp. I'm going to put it into the preferences as a new page instead of popping up a nasty dialog, like you did. But it probably only was for testing it right. Foundation first then the first coat of paint, right??
 31st August 2004, 11:12 #30 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 I didnt try the sc.vbs file, but I can see what it does. It doesnt seem related to anything here. (there is aslo a 'find target..' button on the properties of shortcut files anyway). I am not sure what you are asking about the activexexample, or even what that example is. A good example for this is in msdn, under SAMPLE: AXSH.EXE Demonstrates Implementing ActiveX Script Hosts Be warned that creating a COM component in C++/ATL is no easy task. Creating COM components in VB is a walk in the park, even in C++ its not too bad as long as you are just writing a stock component, the wizards do most of the work for you. But once you start deviating a bit to do something more complicated, and start involving multiple objects and threads, interfacing to something which doesnt have a good API in the first place (Winamp), and want to avoid registering everything, it gets quite difficult. There already is a COM plugin for winamp. However it is just that, a COM object, not a script host. It registers itself and is accessible from any script/vb/vba environment. (WinampCOM). What I am implementing is a COM object, *plus* an environment to script it and invoke the individual scripts. It hosts the scripts, eventually in multiple threads, and will let scripts be invoked from actions. This lets you create a bunch of different files which will get hosted and run under different circumstances, by the plugin. What I am trying to do is basically already possible by combining WinampCOM and this gen_action plugin. Just have gen_action invoke some .vbs files which create the WinampCOM object. And for the 'resident' style scripts, just have them hosted by WSH instead of a custom script host. But stuff with 'send to' and media library stuff would be more complicated to manage.
 31st August 2004, 11:22 #31 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 AXSH.EXE that's what I ment!! I downloaded this, but none of the methods and events are displayed in the ClassView in Visual C++ 6.0. How do you get it into the ClassView in an easy way. I tried importing the .tlb file, but that only messed up the project so bad, that I had to re-extract from AXSH.EXE again. Or do I have to manually edit everything. How did you do it?
 31st August 2004, 11:28 #32 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 I more or less wrote it from scratch. The .sln file is the main project file, but that requires vs.net 2003. The .vcproj file might work in vs6, I dont know. Otherwise you can look for something which converts a vs2003 project to a vs6 project. Or just add the files manually, but you will need to get all the right settings. You can just take a look in the files for those settings, they are xml based. But I didnt really use that example, I mostly wrote it from scratch, but eventually I found this guide which basically explains what I did. I had to make a fair few modifications to it to avoid using the registry, add other objects, support enumeration etc. http://support.microsoft.com/default...NoWebContent=1
 31st August 2004, 12:37 #33 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 That site was a treasure. Now I know how you did it. Thanks Shane Hird. So I need to build it from scratch. Creating a new ATL COM DLL project and so on. I will just move the General Purpose Plug-in stuff in. I'll post an attachment when my plug-in is ready. (Offtopic: Why not call yourself "shane.h", like you were a header file or something, he-he...).
 31st August 2004, 13:30 #34 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 Well I did it about 6 times 6 different ways It wasnt all a waste of time though, as now I have a better understanding of what I am doing. I did have to make quite a few changes to what they described as well, as I dont use registration in the registry for the class or type library. And.. I do use shane.h on some boards, but I guess it was either taken or I couldnt be bothered pressing the '.' when I signed up.
 3rd September 2004, 09:53 #35 saivert Banned     Join Date: Jan 2001 Location: Norway Posts: 927 I have posted my plug-in on the Winamp Scripting thread. It's called NxS Script Control. About the type library thing: I simply included the .tlb file as a resource (of type "TYPELIB") and extract this to the Windows\temp directory. Then I use LoadTypeLib() on this file. I will not use the registry either. I know there is a API for loading Type Libraries directly from resource (Microsoft does this all the time in Windows), but couldn't find it in the Win32 Reference (win32.hlp) Maybe it's old (rather try the Platform SDK docs). What's your comment?
 3rd September 2004, 13:20 #36 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 LoadTypeLib can take a .dll, it will load the typelib from the first typelib resource it finds in the .dll. Just call it with the name of your .dll.
 3rd March 2005, 21:47 #37 Dick65 Senior Member     Join Date: Nov 2004 Location: Bremen, Germany Posts: 157 Shane, am I right that you never got around to do hotkeys for gen_action? Will you?
 4th March 2005, 01:16 #38 shaneh Major Dude   Join Date: Jan 2004 Location: Brisbane, Australia Posts: 1,193 No, I didnt bother. There is already automatic hotkey support in ActiveWinamp, which can do everything gen_action can do and a lot more.
 Winamp & Shoutcast Forums gen_action