🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #218543

40tude Dialog: Sorting on watched flag. Need help with script.

#218543
From: VanguardLH
Date: Sat, 05 Apr 2008 00:44
98 lines
6124 bytes
The sort parameters for the message list do not include flags, like the
watch flag.  So I figured to up the score of a message when the watched
flag was set on it.

No, I do not want to use a "!watched <criteria> <parm>" line in the
scroing rules.  That marks a message as watched if the criteria is met.
That is the wrong way around.  I don't want to watch all messages, for
example, that I post.  Instead I want to decide which threads to watch
(I have Dialog configured to not just flag on a subthread but instead on
the whole thread).  I want to set a score for the message based on
whether or not *I* set watch flag.  Since I can sort on the message's
score value, I want to assign a high score to any thread where I
*choose* to watch it.  If I clear the watch flag, the score should be
low or zero to get it out of the top of the sorted list (i.e., it isn't
being watched anymore).

40tude Dialog has scripting to perform some user-defined functions.
However, it does not provide attributes or methods to the current
selected object.  So, for example, I can't merely use something in a
custom script like:

if AEnabled('Watch') then 
    <objectname>.score := 9999"
else
    <objectname>.score := 0;

So I had to find another way.  When I right-click on a message, there is
a context-menu entry for the message's properties which includes
changing its scoring value.  So I can manually change the score for a
message but this would be a real pain.  I'd have to add the watch flag
and then have to wade through the menus and dialog to up the score for
that message.  However, because there is a dialog that lets me change
the message's score value, I figured that I could use the PostKey()
function in a custom script for a toolbar button.  Several examples at
http://dialog.datalist.org/scripts/script_library.html show using the
ADo() function to open a dialog window and then using PostKey() to enter
the keystrokes that I would otherwise have to enter manually.  So I
wrote the following script (but it doesn't work correctly):


Program WatchedwithHighScore;

Begin
   lockdisplay;             
   ADo('Watch');
   ADo('MessageProperties');
   PostKey(77,false,true,false,false,false,false,false,false);
   PostKey(9,false,false,false,false,false,false,false,false);
   if ( AEnabled('Watch') ) then  
      begin
         PostKey(57,false,false,false,false,false,false,false,false); 
         PostKey(57,false,false,false,false,false,false,false,false);
         PostKey(57,false,false,false,false,false,false,false,false);
         PostKey(57,false,false,false,false,false,false,false,false);
      end
   else
         PostKey(48,false,false,false,false,false,false,false,false);
   PostKey(79,false,true,false,false,false,false,false,false);
   unlockdisplay;
end.

What it does (or what I expected it to do was):
- Lock the painting (refresh) of the windows to eliminate flicker and
possibly timing problems.
- Toggles the watch flag (on or off).
- Opens the 'MessageProperties' dialog (where I can change the score).
- 77 is the keycode for Alt+m which should select and enable "Set
message score" checkbox.
- 9 is the Tab key to move the cursor into the value field.
- If the watch flag is enabled, 9999 is entered for the score value
(each 57 is the keycode for the "9" character); else, 0 is entered (the
48 keycode).
- 79 is the keycode for "O" (oh) and the 2nd 'true' parameter is for the
Alt key, so Alt+O is used to click the OK button to close the dialog
window.
- The display is unlocked to show the changes.

It seems like this should work.  However, what happens is that the
message properties window appears like it does not get focus for the
keystrokes.  The watch flag gets toggled as expected, the
MessageProperties window appears, but nothing gets changed inside the
window.  The window gets close but then the "Online" menu goes active
(because the window is close so the Alt+O gets seen by the main window's
menubar).

I've looked at several other scripts that used the PostKey() function to
issue keystrokes to whatever is the current focused window.  The other
scripts just used ADo() to open the dialog and that dialog supposedly
got focus so the keystrokes would apply to it.

The script would probably work and give me a toolbar button for the
script where I could mark a message as watched and get it sorted to the
top of the message list with a high score assigned to it - *if*
PostKey() worked to manipulate the controls in the MessageProperties
dialog.  I didn't see a function that I could use to force focus to that
window.  I tried not locking/unlocking the display (just in case that
also locked out the properties window that pops up) during the flag and
score changes but that didn't help.
Technical Details
Message-ID: <ft6i1v$clo$1@registered.motzarella.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.albasani.net!news.motzarella.org!motzarella.org!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <ft6i1v$clo$1@registered.motzarella.org>
Subject: 40tude Dialog: Sorting on watched flag. Need help with script.
Date: Fri, 4 Apr 2008 19:44:54 -0500
From: VanguardLH <V@nguard.LH>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.albasani.net!news.motzarella.org!motzarella.org!not-for-mail
Newsgroups: news.software.readers
Organization: A noiseless patient Spider
Lines: 98
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: feeder.motzarella.org
 U2FsdGVkX1+0ZuhdO5q2qe5abnacmwGG6pyAjJ5L2/QHrHgxiW2nN7C8dB1iEmIahb6KJOzSRwnYKKHgDVztPFbxAm8n3OK0reRi71TC1To+jRCzAy0Fi3xgL3ewSW6CTpEOaVQyS47yUVxuDC3FYA==
X-Complaints-To: Please send complaints to abuse@motzarella.org with full
 headers
NNTP-Posting-Date: Sat, 5 Apr 2008 00:44:47 +0000 (UTC)
X-Auth-Sender: U2FsdGVkX18x7InZpEXeWxosYBdTt+WXCX66JdLxHN7DV2hLUo2KNA==
Cancel-Lock: sha1:06WPnz9SFsEm8J0GP9bro1Obvws=
User-Agent: 40tude_Dialog/2.0.15.1