🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
6 messages
6 total messages Started by Alain Guérin Mon, 09 Jun 2003 06:49
[Dialog] Postkey in scripts
#126127
Author: Alain Guérin
Date: Mon, 09 Jun 2003 06:49
79 lines
3765 bytes
Hello,

I send this post a second time as I got no answer and I saw that I put
[dialog] in place of [Dialog] in the subject of my first post. Il the
filters are case sensitive, that could be one reason why nobody saw it ;-)

Here after is my first script : it is intented to open a post creation
window with a sentence at the begining of the post.
(May be there is a way without script, but I did not find it ;-)

I found how to send letter keys to the windows (even a space and digits ;-)
but no punctuation signs are sent.

When I send 'Bonjour,', I get 'Bonjour' with no comma.

My script:

Program CreerMessage;
              
  
procedure PutLine(ALine : String);

var
   Letter : Byte;

BEGIN    
   FOR Letter := 1 to Length(ALine) DO
   BEGIN 
   	IF ((ALine[Letter] >= 'A') AND (ALine[Letter] <= 'Z')) THEN
	   PostKey( Ord(ALine[Letter]), true, false,false,
false,false,false,false,false)
        ELSE  IF (ALine[Letter] >= 'a') AND (ALine[Letter] <= 'z') then
           PostKey( Ord(ALine[Letter])-(Ord('a')-ord('A')), false,
false,false, false,false,false,false,false)
        ELSE                         
           PostKey( Ord(ALine[Letter]), false, false,false,
false,false,false,false,false)
   END;                                           
{send cariage return}             
   PostKey( 13, true, false,false,false,false,false,false,false);                       
END;

Procedure OpenNewPost;

begin
   ADo('NewPostToNewsgroup');
{   PostKey( key: Word; Shift, Alt, Ctrl, Left, Right, Middle,
Double,specialkey: Boolean); }
   {shift-tab x 2 -> edit window}
 PostKey( 9, true, false,false,false,false,false,false,false);                       
 PostKey( 9, true, false,false,false,false,false,false,false);    
 PutLine ('Bonjour,'); 
end;

Begin                
   OpenNewPost
End.

It also seems that following coding is not allowed:

CASE ALine[Letter] OF
   	'A'..'Z':        
	   PostKey( Ord(ALine[Letter]), true, false,false,
false,false,false,false,false);
	'a'..'z':
           PostKey( Ord(ALine[Letter])-(Ord('a')-ord('A')), false,
false,false, false,false,false,false,false);
 	ELSE
           PostKey( Ord(ALine[Letter]), false, false,false,
false,false,false,false,false);
	END;

nor this one :
   IF (ALine[Letter] IN ['A'..'Z']) THEN ...

Thanks for your comments
-- 
A.G.
Re: [Dialog] Postkey in scripts
#126136
Author: Juergen Haible
Date: Mon, 09 Jun 2003 16:10
102 lines
4864 bytes
Alain Gu�rin:

> I send this post a second time as I got no answer and I saw that I put
> [dialog] in place of [Dialog] in the subject of my first post. Il the
> filters are case sensitive, that could be one reason why nobody saw it ;-)

Filters aren't case sensitive by default, your message was just left
"unread/watched" in the hope, that someone else knows an answer. ;-)

> Here after is my first script : it is intented to open a post creation
> window with a sentence at the begining of the post.
> (May be there is a way without script, but I did not find it ;-)

I don't think so as there are no customizable "attribution lines" for
new messages. You can add it as a feature request on Dialog's homepage.

> I found how to send letter keys to the windows (even a space and digits ;-)
> but no punctuation signs are sent.
> 
> When I send 'Bonjour,', I get 'Bonjour' with no comma.

PostKey actually doesn't send ASCII characters but emulates keystrokes,
so the PostKey parameter is actually the number of the key to press on
the keyboard. Control codes, letters and numbers mostly have the same
value as their associated ASCII value, but other keys may have different
values depending on the keyboard layout.

For example, ASCII code for "," is 44, but key code 44 is "VK_SNAPSHOT"
(the gray hardcopy key?), so perhaps you made a hardcopy of your message
instead of inserting a comma. ;-) The right value for a "," on *my*
keyboard (german layout) is 188, your (french?) layout might have a
different value for the ",".

A little bit confusing, how about a little PostKey Wizzard? ;->

The following script builds a PostKey line for a given character. It
should work with all keyboard layouts, but I have not tested it, the
results just looked correct:


Program PostKeyWizzard;

// function VkKeyScanA( ch: AnsiChar ): SHORT;
function VkKeyScan( ch: Char ): SmallInt; 
         external 'VkKeyScanA@user32.dll stdcall';

function StateBool( vkState, bit: Integer ): String;
begin
   if (vkState and bit) <> 0 then Result := 'True'
                             else Result := 'False';
end;

function Build_PostKey( ch: Char ): String;
var  vkInfo, vkKey, vkState: SmallInt;
begin
   // translate character to virtual key info
   vkInfo := VkKeyScan( ch );
   
   if vkInfo = -1 then begin
      
      Result := '// ERROR: Could not translate character ';
         
   end else begin
   
      vkKey   := vkInfo and $FF;             // v-key code
      vkState := ( vkInfo and $FF00 ) shr 8; // shift state
      // writeln( inttohex( vkInfo, 4 ) );
                                  
      // Procedure PostKey( key: Word; Shift, Alt, Ctrl, 
      //    Left, Right, Middle, Double, specialkey: Boolean); 
                             
      Result := 'PostKey( ' + inttostr( vkKey )
              + ', ' + StateBool( vkState, $01 ) // Shift
              + ', ' + StateBool( vkState, $04 ) // Alt
              + ', ' + StateBool( vkState, $02 ) // Ctrl
              + ', False, False, False, False, False );'
              + '  // key ';
   end;
           
   if ch < ' ' then Result := Result + '^' + chr(ord(ch)+64)
               else Result := Result + '''' + ch + '''';
end;

Begin         
   writeln( Build_PostKey( 'a' ) );
   writeln( Build_PostKey( 'A' ) );
   writeln( Build_PostKey( ',' ) );
End.

>         ELSE                         
>            PostKey( Ord(ALine[Letter]), false, false,false,

This is the problem, it's not always the ASCII value.

> It also seems that following coding is not allowed:
> [ case, in etc. ]

I just can confirm this, but it's easy to rewrite it with statements,
that the scripting engine understands.

-jh-
Re: [Dialog] Postkey in scripts
#126150
Author: Alain Guérin
Date: Mon, 09 Jun 2003 22:27
21 lines
2122 bytes
Bonjour
Le 09/06/2003 � 18:10:21,  Juergen Haible �crivait :

> Alain Gu�rin:

>> I send this post a second time as I got no answer and I saw that I put
>> [dialog] in place of [Dialog] in the subject of my first post. Il the
>> filters are case sensitive, that could be one reason why nobody saw it ;-)

> Filters aren't case sensitive by default, your message was just left
> "unread/watched" in the hope, that someone else knows an answer. ;-)

Thanks for your answer and particularly for the Wizard.
In fact, I believed that the value was a virtual key value ( that is more
international than key code ;-)



-- 
A.G.
Re: [Dialog] Postkey in scripts
#126163
Author: Alain GUERIN
Date: Tue, 10 Jun 2003 00:12
69 lines
3963 bytes
On Tue, 10 Jun 2003 00:27:54 +0200, Alain Gu�rin wrote:

> Thanks for your answer and particularly for the Wizard.
> In fact, I believed that the value was a virtual key value ( that is more
> international than key code ;-)

And here after is the fixed code, adapted from Juergen script:

Program NewPost;

function VkKeyScan( ch: Char ): SmallInt; 
         external 'VkKeyScanA@user32.dll stdcall';  
procedure PutLine(ALine : String);

VAR
   Letter : Byte;
   KeyCode : Word;
   VKINFO : SmallInt;                                                
   VKState : SmallInt;
   BEGIN
      FOR Letter := 1 TO Length(Aline) DO
   	IF ((ALine[Letter] >= 'A') AND (ALine[Letter] <= 'Z')) THEN
	   PostKey( Ord(ALine[Letter]), true, false,false,
false,false,false,false,false)
        ELSE  IF (ALine[Letter] >= 'a') AND (ALine[Letter] <= 'z') THEN
           PostKey( Ord(ALine[Letter])-(Ord('a')-ord('A')), false,
false,false, false,false,false,false,false)
        ELSE                                                       
        BEGIN     
           VKInfo := VkKeyScan(ALine[Letter]);
           IF VKInfo > -1 THEN
           BEGIN          
           	KeyCode := VKInfo and $FF;
           	vkState := ( VKInfo and $FF00 ) shr 8; // shift state
{   PostKey( key: Word; Shift, Alt, Ctrl, Left, Right, Middle,
Double,specialkey: Boolean); }
                PostKey(KeyCode, VKState and $01 = $01, VKState and $04 =
$04,VKState and $02 = $02, 
           	                    false,false,false,false,false)
        END
   END;                                                        
   PostKey( 13, true, false,false,false,false,false,false,false);                       
END;

Procedure OpenNewPost;

BEGIN
   ADo('NewPostToNewsgroup');
{shift-tab x 2 -> edit window}
 PostKey( 9, true, false,false,false,false,false,false,false);                       
 PostKey( 9, true, false,false,false,false,false,false,false);    
 PutLine ('Hello,'); 
END;

BEGIN                
   OpenNewPost
END.


The next thing I would like, is a way to "read" the news group name in the
message creation window so I can adapt my prompt to each particular group
(at least have 'Bonjour,' or 'Hello,' following the common group language ).

I also saw that the textfile functions are bugged so I will not build a text
file with a particular prompt for each group ;-(

-- 
A.G.
Re: [Dialog] Postkey in scripts
#126195
Author: Juergen Haible
Date: Tue, 10 Jun 2003 12:55
30 lines
2221 bytes
Alain GUERIN:

>            IF VKInfo > -1 THEN

             IF VKInfo <> -1 THEN

> The next thing I would like, is a way to "read" the news group name in the
> message creation window so I can adapt my prompt to each particular group
> (at least have 'Bonjour,' or 'Hello,' following the common group language ).

I see no easy way for doing so, but I'm rather sure most people will
understand "Bonjour" as well ... ;-)

> I also saw that the textfile functions are bugged so I will not build a text
> file with a particular prompt for each group ;-(

I rarely use textfile functions ... TStringList is much easier to use:

var list: TStringList;
...
list := TStringList.Create();
list.LoadFromFile( 'filename' );
writeln( list.Text );
for i := 0 to list.Count - 1 do writeln( list.Strings[i] );
list.Add( 'append line' );
list.SaveToFile( 'filename.new' );
list.Free;

-jh-
Re: [Dialog] Postkey in scripts
#126212
Author: Alain GUERIN
Date: Tue, 10 Jun 2003 18:06
30 lines
2430 bytes
On Tue, 10 Jun 2003 14:55:40 +0200, Juergen Haible wrote:

> Alain GUERIN:

>>            IF VKInfo > -1 THEN

>              IF VKInfo <> -1 THEN

Thanks for the fix.

>> The next thing I would like, is a way to "read" the news group name in the
>> message creation window so I can adapt my prompt to each particular group
>> (at least have 'Bonjour,' or 'Hello,' following the common group language ).

> I see no easy way for doing so, but I'm rather sure most people will
> understand "Bonjour" as well ... ;-)

And I am afraid that will not be the only way to know where the writer comes
from ;-)

>> I also saw that the textfile functions are bugged so I will not build a text
>> file with a particular prompt for each group ;-(

> I rarely use textfile functions ... TStringList is much easier to use:

Thanks for this bypass.

-- 
A.G.
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