PDA

View Full Version : Get the path to winamp's current title



father of monstermagnet
October 8th, 2004, 08:56 AM
Hello,

i want to get the path (folder) of the current playing title in winamp.

The API doc says this function can only be used from a plugin.

But i'm able to retrieve all info that contains numbers only these two
are not working.

211 Retrieves (and returns a pointer in 'ret') a string that contains the
filename of a playlist entry (indexed by 'data'). Returns NULL if error,
or if 'data' is out of range.
212 Retrieves (and returns a pointer in 'ret') a string that contains the
title of a playlist entry (indexed by 'data'). Returns NULL if error,
or if 'data' is out of range.

When i set the data out of range it returns NULL else it returns only a
number...

Maybe you know a solution.

You need LuaWindowsFunctions Plugin with

LWF.WM_USER = ConvertHextoDecimal ("0400") in LWinFunc Constants.lua (Girder dir)

if you wanna test it.

Or maybe you know an other solution that doesn't
need a winamp plugin like gen_scripting_1004.

Thanks


--int ret=SendMessage(hwndWinamp,WM_USER, data, id);

h = FindWindow("Winamp v1.x",nil)

--125 Returns the position in the current playlist, in tracks

PlPos = SendMessage(h,LWF.WM_USER,0,125)
print (PlPos)


--211 Retrieves (and returns a pointer in 'ret') a string that contains
--the filename of a playlist entry (indexed by 'data').
--Returns NULL if error, or if 'data' is out of range.

--212 Retrieves (and returns a pointer in 'ret') a string that contains
--the title of a playlist entry (indexed by 'data').
--Returns NULL if error, or if 'data' is out of range.

print (SendMessage(h,LWF.WM_USER,PlPos,211))

avid
October 8th, 2004, 09:07 AM
I haven't looked at the WinAmp API, but what you are seeing makes perfect sense.

SendMessage can only send two numbers and get one number back - that's all it can communicate. If you use SendMessage to send to a window *in the same process* (as would happen with a plug-in) then the number *could* be interpreted as an address (e.g. of a string). But sending to or from different processes, such addresses are meaningless. So you can't use SendMessage to receive a string value. [OK - there *is* a way to do it - "global atoms" - but I bet that WinAmp is not using them].

So that's why numbers work and strings don't. Does that make sense?

Brian

Promixis
October 8th, 2004, 09:11 AM
Undocumented in the lua system function plugin.


print (GetWAF("test"))


don't worry about the "test". its a coding error. not this function is not well tested and will crash girder if used inappropriately.

father of monstermagnet
October 8th, 2004, 09:42 AM
Thanks Brian for your explanation, that make sense.

Mike the System plugin command works...very cool i will play and see... :lol:

Have a nice weekend !

father of monstermagnet
October 9th, 2004, 02:06 AM
I can't make girder crash ! :lol:

Mike it's working very stabil, it's possible to run it every second.
I use it to show the album cover of the current winamp song.

As I said before your plugins makes Girder more powerful than ever.

BTW.: Running the IE app with all winamp info has lower CPU rate than
using Winamp plugins.

Promixis
October 9th, 2004, 04:39 AM
Thanks for beta testing it then!

If you a gml with winamp and ieosd, please upload it.

Grin Reaper
October 10th, 2004, 08:57 AM
I can't make girder crash ! :lol:

Mike it's working very stabil, it's possible to run it every second.
I use it to show the album cover of the current winamp song.

As I said before your plugins makes Girder more powerful than ever.

BTW.: Running the IE app with all winamp info has lower CPU rate than
using Winamp plugins.

exactly what i want to do (was having to look to diff applications to try and show album cover for the song i'm playing).

i'd love to see that gml, and what plugins you're using.

father of monstermagnet
October 14th, 2004, 08:16 AM
Maybe one of the worst scripts you have ever seen.

Used to have an animated album cover slideshow.
Put some pics (bmp) into a mp3 folder and play it with winamp,
then run this script with arlarmtimer (500ms).

WinLuaEx, LuaWindowsFunctions 1.4, LuaSystemFunctions 1.4


--Winamp Album Cover Slideshow (Pics in bmp format)

OSDexists = FindWindow(nil,"Titleosd - Microsoft Internet Explorer")
OSDexists1 = FindWindow(nil,"http:// - Titleosd - Microsoft Internet Explorer")
if (OSDexists == 0) and (OSDexists1 == 0)
then
UnloadLuaCom ()
LoadLuaCom ()
r = RegSetStringValue ("HKEY_LOCAL_MACHINE", "Software\\Girder3","slideshow", "slideshow");
if &#40; r < 0 &#41; then
print &#40;"Error setting string value"&#41;
end
TOSD = luacom.CreateObject&#40;"InternetExplorer.Application"&#41;
if not TOSD then
return
end

TOSD&#58;Navigate &#40;"about&#58;blank - Microsoft Internet Explorer"&#41;
TOSD.Document&#58;WriteLn &#40;"<title>Titleosd</title>"&#41;
TOSD.Document&#58;WriteLn &#40;"<body scroll='no' bgcolor='#FFB9DC'>"&#41;
--Change path...
TOSD.Document&#58;WriteLn &#40;"<table border='0' cellpadding='0' cellspacing='0'><tr><td id='VU' height=150 width=150> file&#58;///C&#58;/Test/folder.jpg</td></tr></table></body>"&#41;
TOSD.Fullscreen = 1
tr = TOSD.document.body&#58;createTextRange &#40;&#41;
TOSD.Height = &#40; tr&#58;boundingHeight&#40;&#41;+tr&#58;offsetTop&#40;&#41;*2&#41;
TOSD.Width = &#40;tr&#58;boundingWidth&#40;&#41;+tr&#58;offsetLeft&#40;&#41;*2&#41;
TOSD.Left = 0 --TOSD.Document.ParentWindow.Screen.AvailWidth - TOSD.Width
TOSD.Top = 0

TIME_Sleep &#40;50&#41; --WinLuaEx plugin

local h,x

h = TOSD.HWND
x = &#40;GetWindowLong&#40;h, -20&#41;&#41; --LuaWindowsfunctions 1.4 plugin
x = band &#40;x,4294705151&#41;
x = bor &#40;x,128&#41;
x= bor &#40;x,768&#41;
SetWindowLong&#40;h, -20, x &#41;

SetWindowOpaque &#40;h,255,185,220&#41;
t,l,b,r = GetWindowRect &#40;h&#41;
f = 4
SetWindowClip &#40;h,f,f,b-t-f,r-l-f&#41;

TOSD.Visible = 1

SetWindowPos &#40;h,LWF.HWND_TOPMOST,0,0,0,0,bor &#40;LWF.SWP_NOSIZE,LWF.SWP_NOMOVE&#41;&#41;

TOSD&#58;Refresh&#40;&#41;

else

--------------------------------------------------------------------------------

Ft = GetWAF&#40;"test"&#41; --LuaSystemFunctions 1.4 plugin

function fileparse&#40;fname&#41;
local _, _, drive, path, basename, extension = strfind&#40;fname, "^&#40;%a&#58;&#41;&#40;.-\\+&#41;&#40;&#91;^\\&#93;*&#41;&#40;%..*&#41;$"&#41;
return drive, path, basename, extension
end

drive, path, basename, extension = fileparse&#40;Ft&#41;
--print &#40;drive&#41;
--print&#40;path&#41;
--print&#40;basename&#41;
--print&#40;extension&#41;

-- print file list
--for i=1, FL&#91;"n"&#93; do
-- print&#40;FL&#91;i&#93;&#41;
--end

--------------------------------------------------------------------------------

path = gsub &#40;path ,"\\","/"&#41;

WshShell = luacom.CreateObject &#40;"WScript.Shell"&#41;
x = WshShell&#58;RegRead &#40;"HKEY_LOCAL_MACHINE\\Software\\Girder3\\slideshow"&#41;
print &#40;x&#41;
if &#40;path == x&#41; then
return
end

r = RegSetStringValue &#40;"HKEY_LOCAL_MACHINE", "Software\\Girder3","slideshow", path&#41;;
if &#40; r < 0 &#41; then
print &#40;"Error setting string value"&#41;
end

TOSD.document.body&#58;createTextRange &#40;&#41;&#58;execCommand&#40;"Delete"&#41;

TOSD.Document&#58;WriteLn &#40;"<title>Titleosd</title>"&#41;
TOSD.Document&#58;WriteLn &#40;"<SCRIPT LANGUAGE='JavaScript'><!--"&#41;
TOSD.Document&#58;WriteLn &#40;"var slideShowSpeed = 5000;"&#41;
TOSD.Document&#58;WriteLn &#40;"var crossFadeDuration = 5;"&#41;
TOSD.Document&#58;WriteLn &#40;"var Pic = new Array&#40;&#41;;"&#41;
function readdir&#40;name&#41;
ret, handle, fd = FindFirstFile&#40;name.."/*.bmp"&#41;;

local FileList=&#123;&#125;
FileList&#91;"n"&#93; = 0
if &#40;ret<0&#41; then

print&#40;"Nothing found"&#41;
return
end

local i=1
repeat
-- only save things that are NOT directories
-- if &#40;band&#40;fd.FileAttributes,16&#41; ~= 16&#41; then
FileList&#91;i&#93; = fd.Filename
FileList&#91;"n"&#93; = i
i = i+1
-- end
ret, fd = FindNextFile&#40;handle&#41;
until &#40;ret == 0&#41;

FindClose&#40;handle&#41;;
return FileList

end;

-- build file list

FL = readdir&#40;drive..path&#41;

if &#40;ret<0&#41; then
TOSD.Document&#58;WriteLn &#40;"//--></script><body scroll='no' bgcolor='#FFB9DC'>"&#41;
--Change path...
TOSD.Document&#58;WriteLn &#40;"<table border='0' cellpadding='0' cellspacing='0'><tr><td id='VU' height=150 width=150> file&#58;///C&#58;/Test/folder.jpg</td></tr></table></body>"&#41;
tr = TOSD.document.body&#58;createTextRange &#40;&#41;

TOSD&#58;Refresh&#40;&#41;

return
end

for i=1, FL&#91;"n"&#93; do
TOSD.Document&#58;WriteLn &#40;"Pic &#91;"..i.."&#93; = 'file&#58;///"..drive..path..FL&#91;i&#93;.."'"&#41;
end

TOSD.Document&#58;WriteLn &#40;"var t;"&#41;
TOSD.Document&#58;WriteLn &#40;"var j = 1;"&#41;
TOSD.Document&#58;WriteLn &#40;"var p = Pic.length;"&#41;
TOSD.Document&#58;WriteLn &#40;"var preLoad = new Array&#40;&#41;;"&#41;
TOSD.Document&#58;WriteLn &#40;"for &#40;i = 1; i < p; i++&#41; &#123;"&#41;
TOSD.Document&#58;WriteLn &#40;"preLoad&#91;i&#93; = new Image&#40;&#41;;"&#41;
TOSD.Document&#58;WriteLn &#40;"preLoad&#91;i&#93;.src = Pic&#91;i&#93;;&#125;"&#41;
TOSD.Document&#58;WriteLn &#40;"function runSlideShow&#40;&#41; &#123;"&#41;
TOSD.Document&#58;WriteLn &#40;"if &#40;document.all&#41; &#123;"&#41;
TOSD.Document&#58;WriteLn &#40;"document.images.SlideShow.style.filter='revealTran s&#40;duration=2,Transition=23&#41;';"&#41;
TOSD.Document&#58;WriteLn &#40;"document.images.SlideShow.style.filter='revealTran s&#40;duration=crossFadeDuration,Transition=23&#41;';"&#41;
TOSD.Document&#58;WriteLn &#40;"document.images.SlideShow.filters.revealTrans.Appl y&#40;&#41;;&#125;"&#41;
TOSD.Document&#58;WriteLn &#40;"document.images.SlideShow.src = preLoad&#91;j&#93;.src;"&#41;
TOSD.Document&#58;WriteLn &#40;"if &#40;document.all&#41; &#123;"&#41;
TOSD.Document&#58;WriteLn &#40;"document.images.SlideShow.filters.revealTrans.Play &#40;&#41;;&#125;"&#41;
TOSD.Document&#58;WriteLn &#40;"j = j + 1;"&#41;
TOSD.Document&#58;WriteLn &#40;"if &#40;j > &#40;p - 1&#41;&#41; j = 1;"&#41;
TOSD.Document&#58;WriteLn &#40;"t = setTimeout&#40;'runSlideShow&#40;&#41;', slideShowSpeed&#41;;&#125;"&#41;
TOSD.Document&#58;WriteLn &#40;"//--></script>"&#41;
TOSD.Document&#58;WriteLn &#40;"<body scroll='no' onload='runSlideShow&#40;&#41;' bgcolor='#FFB9DC'>"&#41;
TOSD.Document&#58;WriteLn &#40;"<table border='0' cellpadding='0' cellspacing='0'><tr><td id='VU' height=150 width=150> file&#58;///"..drive..path..FL&#91;1&#93;.."</td></tr></table></body>"&#41;

tr = TOSD.document.body&#58;createTextRange &#40;&#41;

TOSD&#58;Refresh&#40;&#41;

end

father of monstermagnet
October 15th, 2004, 08:27 AM
Display animated slideshow of jpg's inside albumfolder

1.Run once to create the String


r = RegSetStringValue &#40;"HKEY_LOCAL_MACHINE", "Software\\Girder3","slideshow", "path"&#41;;

2. Start with winamp


LoadLuaCom &#40;&#41;
ie = luacom.CreateObject&#40; "InternetExplorer.Application" &#41;
ie&#58;navigate&#40; location or "about&#58;blank" &#41;
ie.document&#58;WriteLn &#40;"<body bgcolor='black' scroll='no'>"&#41;

ie.fullScreen = 1
ie.Height = 280
ie.Width = 280
ie.Left = 15
ie.Top = 107
while ie.busy == 1 do end

TIME_Sleep &#40;50&#41; --WinLuaEx plugin

local h,x

h = ie.HWND
x = &#40;GetWindowLong&#40;h, -20&#41;&#41; --LuaWindowsfunctions 1.4 plugin
x = band &#40;x,4294705151&#41;
x = bor &#40;x,128&#41;
x= bor &#40;x,768&#41;
SetWindowLong&#40;h, -20, x &#41;

SetWindowOpaque &#40;h,0,0,0&#41;
t,l,b,r = GetWindowRect &#40;h&#41;
f = 4
SetWindowClip &#40;h,f,f,b-t-f,r-l-f&#41;

ie.Visible = 1

SetWindowPos &#40;h,LWF.HWND_TOPMOST,0,0,0,0,bor &#40;LWF.SWP_NOSIZE,LWF.SWP_NOMOVE&#41;&#41;

3.Run every second with arlarmtimer


Ft = GetWAF&#40;"test"&#41; --LuaSystemFunctions 1.4 plugin
r,x = RegGetStringValue&#40;"HKEY_LOCAL_MACHINE", "Software\\Girder3","slideshow"&#41;;

--Manipulate GetWAF String
function fileparse&#40;fname&#41;
local _, _, drive, path, basename, extension = strfind&#40;fname, "^&#40;%a&#58;&#41;&#40;.-\\+&#41;&#40;&#91;^\\&#93;*&#41;&#40;%..*&#41;$"&#41;
return drive, path, basename, extension
end

drive, path, basename, extension = fileparse&#40;Ft&#41;

if &#40;path == x&#41; then
return
end

r = RegSetStringValue &#40;"HKEY_LOCAL_MACHINE", "Software\\Girder3","slideshow", path&#41;;


path = gsub &#40;path ,"\\","/"&#41;

ie.document&#58;Write &#91;&#91;

<head><title>Titleosd</title>
<SCRIPT LANGUAGE='JavaScript'><!--
var slideShowSpeed = 5000;
var crossFadeDuration = 5;
var Pic = new Array&#40;&#41;;
&#93;&#93;

--Find all jpg's
function readdir&#40;name&#41;
ret, handle, fd = FindFirstFile&#40;name.."/*.jpg"&#41;;

local FileList=&#123;&#125;
FileList&#91;"n"&#93; = 0
if &#40;ret<0&#41; then

print&#40;"Nothing found"&#41;
return
end

local i=1
repeat

FileList&#91;i&#93; = fd.Filename
FileList&#91;"n"&#93; = i
i = i+1

ret, fd = FindNextFile&#40;handle&#41;
until &#40;ret == 0&#41;

FindClose&#40;handle&#41;;
return FileList

end;

FL = readdir&#40;drive..path&#41;

if &#40;ret<0&#41; then
ie.document&#58;WriteLn &#40;"//--></script><body scroll='no' bgcolor='black'>"&#41;
--Change path...
ie.document&#58;WriteLn &#40;"<table border='0' cellpadding='0' cellspacing='0'><tr><td id='VU' height=150 width=150> file&#58;///C&#58;/Test/1.jpg</td></tr></table></body>"&#41;
ie&#58;refresh&#40;&#41;
return
end

for i=1, FL&#91;"n"&#93; do
ie.document&#58;WriteLn &#40;"Pic &#91;"..i.."&#93; = 'file&#58;///"..drive..path..FL&#91;i&#93;.."'"&#41;
end

ie.document&#58;Write &#91;&#91;
var t;
var j = 1;
var p = Pic.length;
var preLoad = new Array&#40;&#41;;
for &#40;i = 1; i < p; i++&#41; &#123;
preLoad&#91;i&#93; = new Image&#40;&#41;;
preLoad&#91;i&#93;.src = Pic&#91;i&#93;;&#125;
function runSlideShow&#40;&#41; &#123;
if &#40;document.all&#41; &#123;
document.images.SlideShow.style.filter='revealTran s&#40;duration=2,Transition=23&#41;';
document.images.SlideShow.style.filter='revealTran s&#40;duration=crossFadeDuration,Transition=23&#41;';
document.images.SlideShow.filters.revealTrans.Appl y&#40;&#41;;&#125;
document.images.SlideShow.src = preLoad&#91;j&#93;.src;
if &#40;document.all&#41; &#123;
document.images.SlideShow.filters.revealTrans.Play &#40;&#41;;&#125;
j = j + 1;
if &#40;j > &#40;p - 1&#41;&#41; j = 1;
t = setTimeout&#40;'runSlideShow&#40;&#41;', slideShowSpeed&#41;;&#125;
//--></script></head>
<body bgcolor='black' scroll='no' onload="runSlideShow&#40;&#41;">
&#93;&#93;
ie.document&#58;WriteLn &#40;"<table border='0' cellpadding='0' cellspacing='0'><tr><td id='VU' height=150 width=150> file&#58;///"..drive..path..FL&#91;1&#93;.."</td></tr></table></body>"&#41;

ie&#58;refresh &#40;&#41;

Grin Reaper
October 16th, 2004, 10:09 PM
thanks, i'll take a look into that when i get some time on my hands.

father of monstermagnet
October 18th, 2004, 06:14 AM
And another unfinished one


Ft = GetWAF&#40;"test"&#41; --LuaSystemFunctions 1.4 plugin

function fileparse&#40;fname&#41;
local _, _, drive, path, basename, extension = strfind&#40;fname, "^&#40;%a&#58;&#41;&#40;.-\\+&#41;&#40;&#91;^\\&#93;*&#41;&#40;%..*&#41;$"&#41;
return drive, path, basename, extension
end

drive, path, basename, extension = fileparse&#40;Ft&#41;

--path = gsub &#40;path ,"\\","/"&#41;

basename = gsub &#40;basename," ",""&#41;

local infolder = &#40;drive..path.."*.mp3"&#41;
local outfile = "c&#58;\\playlist.html"

local playlist = &#123;&#125;
local ret, handle, fd = FindFirstFile&#40;infolder&#41;
if &#40;ret >= 0&#41; then
repeat
if &#40;&#40;fd.Filename ~= "."&#41; and &#40;fd.Filename ~= ".."&#41;&#41; then
tinsert&#40;playlist, fd.Filename&#41;
end
ret, fd = FindNextFile&#40;handle&#41;
until &#40;ret == 0&#41;
end
FindClose&#40;handle&#41;

sort&#40;playlist&#41;

-- write playlist table to file
fd = openfile&#40;outfile, "w+"&#41;
write &#40;fd, "<HTML><HEAD><TITLE>Listing of&#58;"..drive..path.."</TITLE><STYLE>A&#123;text-decoration&#58;none&#125;a&#58;link&#123;color&#58;white;font-size&#58;18pt;padding&#58;2px;font-family&#58; arial&#125;a&#58;visited&#123;color&#58;blue;font-size&#58;18pt;padding&#58;2px;font-family&#58; arial&#125;body &#123;background-attachment&#58;fixed; font-family&#58; arial;color&#58;white&#125;</STYLE></HEAD><BODY background=file&#58;///C&#58;/HTPC/Background/background1.bmp bgproperties='fixed' ><center><hr><h1>"..path.."</h1>file&#58;///"..drive..path.."folder.jpg</center><hr>
"&#41;
for i = 1, getn&#40;playlist&#41; do
write&#40;fd, '<a href="file&#58;///'..drive..path..playlist&#91;i&#93;..'">'..playlist&#91;i&#93;..'
'&#41;
end
closefile&#40;fd&#41;

Open with htmlosd (mozilla with enabled mime audio)

Or useless with


if not luacom then
UnloadLuaCom &#40;&#41;
end
LoadLuaCom &#40;&#41;

oIE = luacom_CreateObject&#40;"InternetExplorer.Application"&#41;

oIE&#58;Navigate&#40;"C&#58;\\playlist.html"&#41;
oIE.Fullscreen = 1

oIE.Visible = 1

I have fun playing around with the Ft = GetWAF("test") :D