How to script a non-modal msg to the user?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

How to script a non-modal msg to the user?

Post by Jeff Bellune »

Is there a command that will generate a message to the user (me!) that doesn't have to be dismissed before actions can be taken in XY?

Here's what I want to do: I want a msg to be shown as a reminder at the beginning of a script. It will say, "Make sure that all the files and folders that you want to process are selected in the list. Click OK when your selection is complete." Then I can select files or folders in the list while the message box stays on top of the main XY window. When I click OK, the script will continue.

So far, all the methods I've tried (msg and the inputsomething() flavors) are modal and have to be dismissed before any activity can take place in the list.

Cheers,
Jeff

Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: How to script a non-modal msg to the user?

Post by Filehero »

Jeff Bellune wrote:Is there a command that will generate a message to the user (me!) that doesn't have to be dismissed before actions can be taken in XY?
Afaik there's currently only the status bar where you can place a non-modal message to the user. Yet I'm afraid it won't be prominent enough.

Besides that you may could use a html page to mimic a non modal XY message popup.


Cheers,
Filehero

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: How to script a non-modal msg to the user?

Post by PeterH »

You could try to fool around:

with the text to display generate a Popupmenu, where all actions result in Cancel.
If you click the menu, or anything else, or press ESC, it will vanish.

The problem might be that the script is "hanging" till Cancel...

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to script a non-modal msg to the user?

Post by highend »

Even a html page is modal for XY. You can't click anywhere else in the lists as long as it is displayed.

Atm the only thing I can think of is an external tool (e.g. AHK / AutoIt) if it should "look right" as long Don wouldn't allow us to control this behavior via a flag for these commands.
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: How to script a non-modal msg to the user?

Post by TheQwerty »

The "best" solution available today is to have the script check for a selection and if none is made display a message (End Get('CountSelected') < 2, 'You must select more than 1 item...';). The user then closes that dialog (ending the script), makes a selection, and re-runs the script, but there is no good way to show a non-modal message and pause the script while allowing the user to interact with XY.

You might also be interested in this thread: http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=12450

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: How to script a non-modal msg to the user?

Post by Jeff Bellune »

Thanks for the input everyone. I was afraid I was missing something. The selection check is clever. :-)

@Don:
May I request a feature for an option to allow a message box to be non-modal, yet stay on top of the XY window? Thanks.

Cheers,
Jeff

Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: How to script a non-modal msg to the user?

Post by Filehero »

highend wrote:Even a html page is modal for XY. You can't click anywhere else in the lists as long as it is displayed.
Didn't know that, I stand corrected.

... and next time I - again - try before I post. :oops:

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: How to script a non-modal msg to the user?

Post by Stefan »

Hi Jeff.
Jeff Bellune wrote:Is there a command that will generate a message to the user (me!) that doesn't have to be dismissed before actions can be taken in XY?
Maybe this

Code: Select all

writefile("%tmp%\xytmp","ATTENTION<crlf 3>Make sure that all the files and folders that you want to process are selected in the list.<crlf 3>Click OK when your selection is complete."); run notepad "%tmp%\xytmp";

   msg "next command";
   text "another command";
   sel 4;

 

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: How to script a non-modal msg to the user?

Post by Jeff Bellune »

^^^^
Also clever!

Thanks,
Jeff

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: How to script a non-modal msg to the user?

Post by TheQwerty »

NonModal.xys
:whistle:
The demo must be run as a script file, but if you only want to read it...

Code: Select all

"Main"
  // This is the main entry point that is run by default.


  // You can do some checking here to skip the dialog if you want...
  // For instance:
  if (Get('CountSelected') < 2) {
    // Show the dialog if the user has less than 2 items already selected.
    Sub '_ShowNonModalDialog';

    // It's important to end after showing the dialog since we don't want the
    // script to be running while the user interacts with XY.
    // The dialog will kick off the script again when the user finishes.
    End true;
  } else {
    Sub '_Continue';
  }


"_Continue"
  // This is the script that gets called after the dialog is closed.
  Text Get('SelectedItemsPathNames'), /*width*/, /*height*/, 'You selected the following items:';


"_ShowNonModalDialog"
  // This is the script which shows our non-modal dialog.

  // This doesn't necessarily have to be a script file, but it is far
  // easier to demo the concept when it is.
  $scriptFile = Self('file');
  End $scriptFile == '', 'This script must be saved and executed from a file.';


  // ===== DIALOG OPTIONS =====
  // Title of the "dialog".
  $title = 'XYplorer Script';

  // One-line message to display.
  // If you're ambitious you can make it show many lines, the contents of a
  // file, or even ASCII art if you wanted... but I'm lazy. ;)
  $msg = 'Make your selection in XYplorer now.';

  /* Change the colors of the dialog using the following:
  **   0 = Black       8 = Gray
  **   1 = Blue        9 = Light Blue
  **   2 = Green       A = Light Green
  **   3 = Aqua        B = Light Aqua
  **   4 = Red         C = Light Red
  **   5 = Purple      D = Light Purple
  **   6 = Yellow      E = Light Yellow
  **   7 = White       F = Bright White
  **
  **   This helps make it not look like a command prompt.
  */
  $backgroundClr = 'F';
  $foregroundClr = '0';

  // Script to run when the user dismisses the dialog.
  // This needs to be a short one-liner and cannot contain double-quotes (").
  // It is passed as a command line switch to XY, so follow the rules here:
  // ::help('idh_commandlineswitches.htm');
  $script = <<<SCRIPT
::Load '$scriptFile', '_Continue', 'f';
SCRIPT;
  // For this demo there is really no need to call the '_Continue' label, since
  // Main will do so if the selection is valid. Thus we could replace this with
  // just the path to the script file, but this way demos that it can really
  // call any script, even an entirely different one, after the user responds to
  // the dialog.



  // ===== DIALOG OPTIONS - END =====

  // There should some option validation here but, again, I'm lazy.
  // Since we're building this fragile command below nothing can contain
  // multiple lines, '&&', double-quotes ("), etc.

  /* Build the "dialog" "script"...
  **   Here's the breakdown of the command...
  **     "cmd.exe"                            = Run what follows in a command prompt.
  **     /K                                   = Keep the prompt open.
  **     @color $backgroundClr$foregroundClr  = Set the prompt's colors.
  **     &&                                   = And then...
  **     @echo $msg                           = Display our message
  **     &&                                   = And then...
  **     @title $title                        = Set the title (Oddly if done earlier the pause overrides it!?)
  **     &&                                   = And then...
  **     @pause                               = Pause until the user presses the any key.
  **     &&                                   = And then...
  **     @start "Notifying XY..." /B          = Start a process without creating a new window.
  **     "<xy>" /hwnd=<hwnd>                  = That process is the same instance of XY that is running this script.
  **     /flg=2                               = XY arg: Leave the tab locations alone.
  **     /script="$script";                   = XY arg: The script to execute.
  **     &&                                   = And then...
  **     @exit                                = Close the command prompt.
  **
  ** The @s prevent the command prompt from showing the commands.
  */
  $cmd = <<<CMD
"cmd.exe" /K @color $backgroundClr$foregroundClr && @echo $msg && @title $title && @pause && @start "Notifying XY..." /B "<xy>" /hwnd=<hwnd> /flg=2 /script="$script" && @exit
CMD;

  // Show the dialog by running the command - don't wait just continue.
  run $cmd,, 0, 1;
[/size]
To see the attached files, you need to log into the forum.

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to script a non-modal msg to the user?

Post by highend »

Nice TheQwerty :)

I have a slightly different solution:

Code: Select all

    $vbsFile = "%TEMP%\wait.vbs";
    $vbsContent = <<<>>>
MsgBox "Make sure that all the files and folders that you want to process are selected in the list. Click OK when your selection is complete.", vbInformation+vbSystemModal
>>>;

    writefile($vbsFile, $vbsContent);
    run """wscript"" ""$vbsFile""", , 2, 0;
    delete 0, 0, $vbsFile;
    text "end";
Not with any fancy backgrounds but... it stays on top so it can't be overlooked...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: How to script a non-modal msg to the user?

Post by klownboy »

Very impressive TheQwerty :appl: After doing a little research, it doesn't appear there's any way natively to force that cmd message window to stay on top (e.g., on top while selecting the files in this case so you wouldn't have to bring it to the foreground to dismiss it).

I see highend posted another version I'll have to try.

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: How to script a non-modal msg to the user?

Post by Jeff Bellune »

@TheQwerty, @highend:

Very nice work done by both of you! Thank you for taking the time to post solutions.

My wish is for an option in XY's Scripting Commands to make message boxes be application modal or system modal.

I suppose that many of the current features of SC came about as a result of discussions just like this one. A user wants to do something in XY --> the command doesn't exist --> possible workarounds are discussed --> the complexity of the workaround or the logic behind it is beyond most normal humans --> Don agrees that the feature is useful and adds it to XY. The brilliant workarounds (which never would have crossed my mind) that are shown in this thread have gotten us to the last step. I hope Don agrees, and that last step gets executed.

I will post a brief topic in the Wishes forum requesting this.

Cheers,
Jeff

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: How to script a non-modal msg to the user?

Post by TheQwerty »

Jeff Bellune wrote:I will post a brief topic in the Wishes forum requesting this.
No need - Don reads all.

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: How to script a non-modal msg to the user?

Post by Jeff Bellune »

<sigh> Too late. :ninja:

Post Reply