Thread View: news.software.readers
9 messages
9 total messages
Started by matija
Sat, 21 Jun 2003 13:11
[dialog] X-Now-Playing script :)
Author: matija
Date: Sat, 21 Jun 2003 13:11
Date: Sat, 21 Jun 2003 13:11
136 lines
5294 bytes
5294 bytes
i've written a nice little script that will add an "X-Now-Playing: song"
header to your posts or at the end of them.
it works on my win2k machine with winamp 2.91, so if it doesn't work
on your computer, let me know. it should also work for e-mails, but
i haven't tried it since i use dialog for usenet only.
feedback much appreciated.
program OnBeforeSendingMessage;
// ----------------------------------------------------------------------
const
winampWindowTitle = 'Winamp v1.x';
WM_USER = 1024;
WM_WA_IPC = WM_USER;
IPC_GETVERSION = 0;
MB_YESNO = 4;
IDYES = 6;
IDNO = 7;
// ----------------------------------------------------------------------
function findWindow(c1, c2: PChar): Cardinal; external 'FindWindowA@user32.dll stdcall';
function getWindowTextLength(hWnd: Cardinal): Integer; external 'GetWindowTextLengthA@user32.dll stdcall';
function getWindowText(hWnd: cardinal; lpString: PChar; nMaxCount: Integer): Integer; external 'GetWindowTextA@user32.dll stdcall';
function messageBox(hWnd: Cardinal; lpText, lpCaption: PChar; uType: longword): Integer; external 'MessageBoxA@user32.dll stdcall';
// ----------------------------------------------------------------------
function findWinampHWND : cardinal;
begin
result := findWindow (winampWindowTitle, null);
end;
// ----------------------------------------------------------------------
function winampSong (winampHWND:cardinal) : string;
var titleLen : integer;
tempInt : integer;
tempStr : string;
plNum : integer;
tempmp3 : string;
begin
// used in case winamp is not running or the window is not found
tempStr := 'nothing';
// if winamp's window is found...
if winampHWND <> 0 then
begin
// find the caption text of winamp's window
titleLen := getWindowTextLength (winampHWND) + 2;
setLength (tempStr, titleLen);
getWindowText (winampHWND, pchar(tempStr), titleLen);
setLength (tempStr, length(tempStr));
// the window title is "x. song artist - song name - Winamp", where the x
// is the playlist position, but we don't want that, so we'll remove both
tempInt := pos (' - Winamp', tempStr);
plNum := pos (' ', tempStr) + 1;
tempStr := copy (tempStr, plNum, tempInt - plNum);
// check if the string ends with '.mp3' and remove it
tempmp3 := lowerCase (copy (tempStr, length(tempStr) - 3, 4));
if tempmp3 = '.mp3' then
begin
tempStr := copy (tempStr, 1, length(tempStr) - 4);
end;
end; // if winampHWND <> 0
result := TempStr;
end;
// ----------------------------------------------------------------------
function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
var tempSong : string;
begin
// don't do anything for e-mails, nobody looks at e-mail headers anyway :)
if isEmail = false then
begin
// get the song name
tempSong := winampSong (findWinampHWND);
// uncomment the line below to get a messagebox asking you if you wish
// to include the X-Now-Playing header in your post
// if (MessageBox(null, 'Insert X-Now-Playing: "' + tempSong + '"?', 'Insert X-Header?', MB_YESNO) = IDYES) then
// insert the x-header at the beginning of the message, dialog (or perhaps
// the news server) will sort it out as necessary.
message.insert (1, 'X-Now-Playing: "' + tempSong + '"');
// use this if you also wish to add the song name to the bottom of your post:
// message.add ('');
// message.add ('Now playing: ' + tempSong);
end;
result := true;
end;
// ----------------------------------------------------------------------
begin
end.
--
there is a cheer. the gnomes have learned a new way to say hooray. [-shpongle]
address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script :)
Author: matija
Date: Sat, 21 Jun 2003 13:58
Date: Sat, 21 Jun 2003 13:58
33 lines
2478 bytes
2478 bytes
matija, completely geschtonkenflapped, wrote:
> i've written a nice little script that will add an "X-Now-Playing: song"
> header to your posts or at the end of them.
and i've found a "bug". if winamp is not running, you get
X-Now-Playing: "nothing", which looks weird. here's a portion
of the script to fix it. of course, there's still the issue
when the song's name is actually "nothing" ;))
-----
// get the song name
tempSong := winampSong (findWinampHWND);
if tempSong <> 'nothing' then tempSong := '"' + tempSong + '"';
// uncomment the line below to get a messagebox asking you if you wish
// to include the X-Now-Playing header in your post
// if (MessageBox(null, 'Insert X-Now-Playing: ' + tempSong + '?', 'Insert X-Header?', MB_YESNO) = IDYES) then
// insert the x-header at the beginning of the message, dialog (or perhaps
// the news server) will sort it out as necessary.
message.insert (1, 'X-Now-Playing: ' + tempSong);
-----
--
there is a cheer. the gnomes have learned a new way to say hooray. [-shpongle]
address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script :)
Author: Jarrod Cifer
Date: Sat, 21 Jun 2003 14:00
Date: Sat, 21 Jun 2003 14:00
9 lines
1820 bytes
1820 bytes
matija, upon reaching Nirvana, postulated: > i've written a nice little script that will add an "X-Now-Playing: song" > header to your posts or at the end of them. Damn cool! Thanks for sharing. -- J. Cifer
Re: [dialog] X-Now-Playing script :)
Author: matija
Date: Sat, 21 Jun 2003 17:22
Date: Sat, 21 Jun 2003 17:22
18 lines
2039 bytes
2039 bytes
Jarrod Cifer, completely geschtonkenflapped, wrote:
>> i've written a nice little script that will add an "X-Now-Playing: song"
>> header to your posts or at the end of them.
>
> Damn cool! Thanks for sharing.
my pleasure. i fixed some quirks since posting, but i'll send
a new version as soon as i get it to work with winamp 3.x.
i'll also try making it as configurable as possible - with or
without quotation marks / winamp version / adding the song name
to the bottom of the post, etc.
--
there is a cheer. the gnomes have learned a new way to say hooray. [-shpongle]
address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script :)
Author: Gandalf il Grigio
Date: Sun, 22 Jun 2003 02:21
Date: Sun, 22 Jun 2003 02:21
15 lines
1989 bytes
1989 bytes
news.software.readers ~ 21/6/2003 ~ matija: > my pleasure. i fixed some quirks since posting, but i'll send > a new version [cut] i'll also try making it as configurable as possible Please do, I'd love to use your script when it's �finished� :) Great idea, and good scripting skills (I guess, mine are equal to 0 ;)) G -- _____ Farewell! _ _ ___ ~ ICQ# 16553733 mailto:gandalf*ithn.net | __|___ ___ _| |___| | _| ~ 40tude Dialog http://snurl.com/dialog | | | .'| | . | .'| | _| ~ Google Groups http://snurl.com/ggroup |_____|__,|_|_|___|__,|_|_| ~ ITHNetiquette http://snurl.com/ithnet
Re: [dialog] X-Now-Playing script :)
Author: Jarrod Cifer
Date: Sun, 22 Jun 2003 06:50
Date: Sun, 22 Jun 2003 06:50
19 lines
2288 bytes
2288 bytes
matija, upon reaching Nirvana, postulated: > my pleasure. i fixed some quirks since posting, but i'll send > a new version as soon as i get it to work with winamp 3.x. > i'll also try making it as configurable as possible - with or > without quotation marks / winamp version / adding the song name > to the bottom of the post, etc. Two questions: Have you added it to the script repository on the Dialog wiki pages? You've already shown me how to add a header, can you give me a tip how to delete a header on sending a message as well? Thanks! -- J. Cifer
Re: [dialog] X-Now-Playing script :)
Author: Dirk Steins
Date: Sun, 22 Jun 2003 07:35
Date: Sun, 22 Jun 2003 07:35
26 lines
2120 bytes
2120 bytes
On Sat, 21 Jun 2003 15:11:17 +0200, matija wrote: > > i've written a nice little script that will add an "X-Now-Playing: song" > header to your posts or at the end of them. > > it works on my win2k machine with winamp 2.91, so if it doesn't work > on your computer, let me know. it should also work for e-mails, but > i haven't tried it since i use dialog for usenet only. > > feedback much appreciated. Nice script. Unfortunately i can't try it out since i already have a OnBeforeSending script running here which creates my expires... email address. So i first have to integrate them both, but that shouldn't be to hard. :-) Maybe i'll do that later today thanx anyway! Cheers, Dirk -- "You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, The Swiss hold the America's Cup, France is accusing the US of arrogance, and Germany doesn't want to go to war."
Re: [dialog] X-Now-Playing script :)
Author: matija
Date: Sun, 22 Jun 2003 11:54
Date: Sun, 22 Jun 2003 11:54
35 lines
2624 bytes
2624 bytes
Jarrod Cifer, completely geschtonkenflapped, wrote:
> Two questions:
> Have you added it to the script repository on the Dialog wiki pages?
not yet. i'll do so as soon as people on this and the croatian
news software groups say it's working as expected :)
> You've already shown me how to add a header, can you give me a tip how to
> delete a header on sending a message as well?
index := message.indexOf ('what you are searching for');
message.delete (index);
if you don't know the search string exactly, traversal
will be necessary:
for n := 0 to message.count do
if pos ('something', message[n]) <> 0 then message.delete (n);
so, if you're searching for 'X-Foo: bar' which is constant,
you go with the first method. if the X-Foo header changes
(e.g. 'X-Foo: bar' or 'X-Foo: baz' or 'X-Foo: quux' or...),
the second method should be used, and this time you're
searching only for 'X-Foo'.
--
there is a cheer. the gnomes have learned a new way to say hooray. [-shpongle]
address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script :)
Author: ChaKy
Date: Sun, 22 Jun 2003 15:37
Date: Sun, 22 Jun 2003 15:37
16 lines
1986 bytes
1986 bytes
Dana Sun, 22 Jun 2003 13:54:57 +0200, matija je napisao/la u <1lm0vftr9xw0z$.dlg@shpongle.604>: > not yet. i'll do so as soon as people on this and the croatian > news software groups say it's working as expected :) [...] For me, it's working just fine ;-) -- =| ChaKy <chaky@softhome.net> | ICQ:96731865 |= "Going back into time, blind through the night" Now playing: "Robert Miles - Piano In Trance" (Winamp 2.91)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads