๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #126136

Re: [Dialog] Postkey in scripts

#126136
From: 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-
Technical Details
Message-ID: <1v0b6a1fkg6ee.dlg@ndqf.elbiah.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail
References: <3ee42df7$0$12450$626a54ce@news.free.fr>

Show Full Headers
Complete Article Headers
Message-ID: <1v0b6a1fkg6ee.dlg@ndqf.elbiah.de>
Subject: Re: [Dialog] Postkey in scripts
Date: Mon, 9 Jun 2003 18:10:21 +0200
From: Juergen Haible <juergen.haible@t-online.de>
References: <3ee42df7$0$12450$626a54ce@news.free.fr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail
Newsgroups: news.software.readers
Organization: T-Online
Lines: 101
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: news.t-online.com 1055175045 03 14214 8A2GVGebSS-nSH 030609 16:10:45
X-Complaints-To: usenet-abuse@t-online.de
X-ID: bExdfZZBgeIQXwXtoQslaAuQiyxuxWf1q4uOImUJZvefdbr+N+KArW
User-Agent: 40tude_Dialog/2.0.4.1 (0adaf536.402.120) Hamster-Pg/1.10.0.4