🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
11 messages
11 total messages Started by Antonio 'Gandalf' Favata Fri, 17 Oct 2003 20:56
[Dialog] [Dialog] foobar X-Now-Playing script
#135652
Author: Antonio 'Gandalf' Favata
Date: Fri, 17 Oct 2003 20:56
9 lines
1889 bytes
I know that someone is using Dialog with foobar, and that he/she has a
script similar to matija's X-Now-Playing one (which is for Winamp):
<http://40tude.com/dialog/wiki/index.php/ScriptXNowPlaying>
So, please, share it [here or on Wiki] :)
-- 
Fare Well! | 40tude Dialog (adesso in Italiano): http://snurl.com/dialog
G          | Advice:         xp-Antispy 3.72 ~ http://www.xp-antispy.org
                                                     17/10/2003 22.39.26
«Seven for the Dwarf-lords in their halls of stone...»
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135657
Author: Antonio 'Gandalf' Favata
Date: Sat, 18 Oct 2003 01:04
11 lines
1941 bytes
news.software.readers ~ 17/10/2003 22.56 ~ Antonio 'Gandalf' Favata:

> Subject: [Dialog] [Dialog] foobar X-Now-Playing script

(Whops, sorry... I guess I'd better tell my Hamster not to add the tag if
it's already there ^__^)
-- 
Fare Well! | 40tude Dialog (adesso in Italiano): http://snurl.com/dialog
G          | Advice:         xp-Antispy 3.72 ~ http://www.xp-antispy.org
                                                     18/10/2003 3.04.53
«Ash nazg durbatulûk, ash nazg gimbatul...»
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135672
Author: daRkSidE
Date: Sat, 18 Oct 2003 10:26
18 lines
2069 bytes
On  Fri,  17 Oct 2003 22:56:36 +0200, *Antonio 'Gandalf' Favata* wrote:

> Subject: [Dialog] [Dialog] foobar X-Now-Playing script

How many Dialog?

> I know that someone is using Dialog with foobar, and that he/she has a
> script similar to matija's X-Now-Playing one (which is for Winamp):

[Italian, sorry]
Message-ID: <10dxjcn7p7ka8.dlg@darkside.df>

I think the original message wasn't in this newsgroup.

-- 
                                          18/10/2003 0:33:24, daRkSidE
Un nuovo newsreader in Italiano: 40tude Dialog: http://snurl.com/dialog
Tradotto da Antonio 'Gandalf' Favata con l'aiuto di Enrico C e daRkSidE
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135674
Author: Antonio 'Gandalf' Favata
Date: Sat, 18 Oct 2003 12:12
18 lines
2233 bytes
news.software.readers ~ 18/10/2003 12.26 ~ daRkSidE:

>> Subject: [Dialog] [Dialog] foobar X-Now-Playing script
> How many Dialog?

The original message had just one tag, but when I superseded it Hamster
inserted the second one... now it does a second check :)

> Message-ID: <10dxjcn7p7ka8.dlg@darkside.df>
> I think the original message wasn't in this newsgroup.

Thanks! So the «someone» I was talking about is Jernej Simončič...
Please, Jernej, would you share the script? :)
-- 
Fare Well! | 40tude Dialog (adesso in Italiano): http://snurl.com/dialog
G          | Advice:            eMule 0.3 ~ http://www.emule-project.net
                                                     18/10/2003 14.08.40
I'm not as dumb as you look.
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135676
Author: Jernej Simončič
Date: Sat, 18 Oct 2003 12:33
148 lines
7880 bytes
On Sat, 18 Oct 2003 14:12:23 +0200, Antonio 'Gandalf' Favata wrote:

> Thanks! So the «someone» I was talking about is Jernej Simončič...
> Please, Jernej, would you share the script? :)

Sure, here it is:

//program foobar2000;

(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
(* Script: Add X-Now-Playing based on infromation from foobar2000 <http://foobar2000.hydrogenaudio.org/>         *)
(* Version: 0.11                                                                                                 *)
(* Author: Jernej Simoncic <jernej simoncic at guest arnes si>                                                   *)
(*                                                                                                               *)
(* Usage: The script directly inserts the text from your foobar2000 titlebar; use it's excellent formatting      *)
(* formatting functions to fit the text to your needs; the script won't add anything if the titlebar starts with *)
(* foobar2000 - as this normally means that the player is stopped                                                *)
(* You can set exactly what is added to the message below                                                        *)
(*                                                                                                               *)
(* Tested with foobar2000 0.667 on Win2k.                                                                        *)
(*                                                                                                               *)
(* Changelog:                                                                                                    *)
(*  0.10 - first release                                                                                         *)
(*  0.11 - can be used with $include                                                                             *)
(*                                                                                                               *)
(* ToDo:                                                                                                         *)
(*  - 8-bit/unicode character processing                                                                         *)
(*                                                                                                               *)
(* Use this script at your own risk.                                                                             *)
(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)

const
  EMail = 1; News = 2; XHeader = 1; EndOfMessage = 2;

  (* * * * * * * * * * * * * * * * * * * * * * * * * * SETTINGS * * * * * * * * * * * * * * * * * * * * * * * * * *)
  UseWith = EMail + News;  //EMail: e-mail messages; News: newsgroup posts
  AddTo = XHeader {+ EndOfMessage}; //XHeader, EndOfMessage 
  XHeaderText = 'X-Now-Playing: %song%'; //the x-header text to add
  EndMessageText = '%n%Now playing: %song%'; //text to add to end of message
  //In both XHeaderText and EndMessageText, %song% will be replaced by the song title; if %song% doesn't appear
  //in the text, song title is added at the end
  //You can also use %n% in the EndMessageText to represent a line break
  (* * * * * * * * * * * * * * * * * * * * * * * * * END OF SETTINGS  * * * * * * * * * * * * * * * * * * * * * * *)
  
  fb2kWindowClass = 'FOOBAR2000_CLASS'; //don't change unless you know what you're doing

function FindWindow(lpClassName, lpWindowName: PChar): Cardinal; external 'FindWindowA@user32.dll stdcall';
function GetWindowTextLengthA(hWnd: Cardinal): Integer; external 'GetWindowTextLengthA@user32.dll stdcall';
function GetWindowTextA(hWnd: cardinal; lpString: PChar; nMaxCount: Integer): Integer; external 'GetWindowTextA@user32.dll stdcall';

function MessageBox(hWnd: Cardinal; lpText: WideString; lpCaption: WideString; uType: longword): Integer; external 'MessageBoxW@user32.dll stdcall';

procedure MsgBox(text: WideString);
begin
  MessageBox(null,text,'aaa',0);
end;

function GetFB2kTitle: WideString;
var handle: Cardinal;
    tlen,i: Integer;
    titlea: String;
begin

  titlea := ''
  handle := FindWindow(fb2kWindowClass, null);;

  if (handle <> 0) then
  begin
    tlen := GetWindowTextLengthA(handle)+1;
    
    SetLength(titlea, tlen);
    
    i := GetWindowTextA(handle, PChar(titlea), tlen);

    SetLength(titlea, Length(titlea)-1);
  end;
    
  Result := titlea;
end;

function foobar2000(var Message: TStringlist; IsEmail: boolean): boolean;
var song, text: WideString;
    i: Integer;
begin

  if (((not isEmail) and ((UseWith and News) = News)) or (isEmail and ((UseWith and EMail) = EMail))) then
  begin
    song := GetFB2kTitle();
    
    if (song = '') then
      exit;
    if (Copy(song,1,10) = 'foobar2000') then
      exit;

    if ((AddTo and XHeader) = XHeader) then
    begin
      if (Pos('%song%',XHeaderText) > 0) then
        text := StringReplace(XHeaderText,'%song%',song,[rfReplaceAll])
      else
        text := XHeaderText + song;
        
      //clean 8-bit characters from header
      for i := 127 to 255 do
      	if (Pos(Chr(i),text) > 0) then
      	  text := StringReplace(text,Chr(i),'_',[rfReplaceAll]);  
      
      //sanity checks
      if (Copy(text,1,2) <> 'X-') then
      	text := 'X-' + text;
      if (Pos(': ', text) > 2) and (Pos(': ',text) < (Length(text)-3)) then
        for i := 0 to Message.Count - 1 do
          if (Message.Strings[i] = '') then //insert as the last x-header
          begin
            Message.Insert(i, text);
            break;
          end;
    end;
  
    if ((AddTo and EndOfMessage) = EndOfMessage) then
    begin
      if (Pos('%song%', EndMessageText) > 0) then
        text := StringReplace(EndMessageText,'%song%',song,[rfReplaceAll])
      else
      	text := EndMessageText + song;
      
      text := StringReplace(text,'%n%',#13#10,[rfReplaceAll]);
      	
      Message.Add(text);
    end;
    
  end;

  Result := True;
end;

(*var s: WideString;

begin
  s := GetFB2kTitle;
  MsgBox(s);
end.*)

Note that it currently gets the text from FB2k's titlebar; I'll work on
this later. 

-- 
Jernej Simončič, <jernej simoncic at guest arnes si>
http://www2.arnes.si/~sopjsimo/
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135677
Author: Antonio 'Gandalf' Favata
Date: Sat, 18 Oct 2003 13:24
17 lines
2082 bytes
news.software.readers ~ 18/10/2003 14.33 ~ Jernej Simončič:

>> Please, Jernej, would you share the script? :)
> Sure, here it is:

Thanks!

>   titlea := ''
>   handle := FindWindow(fb2kWindowClass, null);;

This is a typo, I guess: the double semicolon on the second line, while
the first has none...
-- 
Fare Well! | 40tude Dialog 2.0.6.1 (in Italiano) http://snurl.com/dialog
G          | Advice:      ChangeExt 1.9 ~ http://www.justaskcomputer.com
                                                     18/10/2003 15.21.25
"Hey, dad, remember our car?" -- Calvin
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135678
Author: Antonio 'Gandalf' Favata
Date: Sat, 18 Oct 2003 13:34
10 lines
2010 bytes
news.software.readers ~ 18/10/2003 14.33 ~ Jernej Simončič:

> (* Tested with foobar2000 0.667 on Win2k.

I think you can add also foobar2000 0.7.1 on Windows XP Pro SP1 :)
-- 
Fare Well! | 40tude Dialog 2.0.6.1 (in Italiano) http://snurl.com/dialog
G          | Advice:                SciTE 1.5.5 ~ http://snurl.com/scite
                                                     18/10/2003 15.33.54
«Then Gandalf revealed the strength that lay hid in him»
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135679
Author: Jernej Simončič
Date: Sat, 18 Oct 2003 14:04
11 lines
1929 bytes
On Sat, 18 Oct 2003 15:34:25 +0200, Antonio 'Gandalf' Favata wrote:

> I think you can add also foobar2000 0.7.1 on Windows XP Pro SP1 :)

I know, but I didn't bother updating the script. I'm also still waiting for
better unicode support in scripting, as currently I can only get the text
in current windows codepage - which isn't enough for me :)

-- 
Jernej Simončič, <jernej simoncic at guest arnes si>
http://www2.arnes.si/~sopjsimo/
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135731
Author: Krzysztof Kudłacik
Date: Sun, 19 Oct 2003 05:55
15 lines
2175 bytes
On Fri, 17 Oct 2003 22:56:36 +0200, Antonio 'Gandalf' Favata wrote:

> I know that someone is using Dialog with foobar, and that he/she has a
> script similar to matija's X-Now-Playing one (which is for Winamp):
> <http://40tude.com/dialog/wiki/index.php/ScriptXNowPlaying>
> So, please, share it [here or on Wiki] :)

You don't have to use "script" technique. Just use proper software (with
Winamp, foobar2000 etc.):
http://amip.tools-for.net/

-- 
.:. miniFAQ dla 40tude Dialog http://dialog.born66.net
GH/GP/GSS  d-  s:+  a36  C++ L+ W+++ N++ K- w O-- M-- PS--- PE+ Y+ PGP+
t--- 5-- X++++ R- b++ DI- D-- G e+++ h---- r+++ z+++
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#135740
Author: Antonio 'Gandalf' Favata
Date: Sun, 19 Oct 2003 13:25
11 lines
2056 bytes
news.software.readers ~ 19/10/2003 7.55 ~ Krzysztof Kudłacik:

> You don't have to use "script" technique. Just use proper software (with
> Winamp, foobar2000 etc.): http://amip.tools-for.net/

Looks great, thanks! But I think I'll stick with the script, it works ;)
-- 
Fare Well! | 40tude Dialog 2.0.7.1 (in Italiano) http://snurl.com/dialog
G          | Advice:  Looking for freeware? ~ http://snurl.com/webattack
                                                     19/10/2003 15.25.20
Five days is not too long to wait for a gun (Bart's chalkboard #1F20)
Re: [Dialog] [Dialog] foobar X-Now-Playing script
#136046
Author: Marcus Mönnig
Date: Thu, 23 Oct 2003 20:22
13 lines
2020 bytes
On Sat, 18 Oct 2003 16:04:04 +0200, Jernej Simončič wrote:

> I know, but I didn't bother updating the script. I'm also still waiting for
> better unicode support in scripting, ...

I'm waiting, too. :-) Though, I don't think Carlo will put in the PWideChar
type. Go over to his newsgroup and beg! ;-)

Marcus
-- 
No replies in private e-mail, please, unless explicitly requested!
Please log bug reports into Mantis: http://www.40tude.com/dialog/mantis/
Please share your scripts and tips: http://www.40tude.com/dialog/wiki/
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