pop a message, wait few secs and show next text - how?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

pop a message, wait few secs and show next text - how?

Post by neutrox »

I am trying to learn this script thing but I'd like a bit less of pain in reading the documentation. Tried autoscroll on browsers and didn't liked it then i thought:

Code: Select all

   echo "hi";
   wait 3000;
   sendkeys "{ENTER}";
but now i realize the "wait" will wait for "echo" to be pressed. :cry:
Any autoclose function available i'm not aware of?

Any autohotkey'er who could bring a solution? Someone told me AHK could do this but i'm not into it...

The big thing would be the script reading paragraphs, splitting very large chunks into smaller if needed, and calculate the time of exhibition according to how many words or letters each chunk does have.

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

Re: pop a message, wait few secs and show next text - how?

Post by Stefan »

You can always involving an external script language
like VBScript with his popup() method.

You can create and call this VBScript from XYplorer too.


Example proof of concept:

Code: Select all

  //User Settings:
  $text = readfile("<xydata>\<xyini>",,1050);
  $waitSec = 10;


  //=====================================================
  //=====================================================
  // Code:
  // - - -
  //Prepare each line for VBS:
  $out="";
  foreach($line, $text, "<crlf>"){$out = $out . chr(34) . $line . chr(34) . " & vbCRLF _<crlf> & ";}
  $out = replace($out, "&", "", ,strlen($out) -3, 1);
  // - - -
  //Create the VBS file:
  $VBS = <<<HEREDOC
text =  $out 
SET WS = CreateObject("WScript.Shell")
'//WshShell.Popup   strMessage [,intSecondsToWait] [,strTitle] [,intType]
WS.popup text, $waitSec
HEREDOC;
    writefile("%tmp%\tempVBS.vbs", $VBS);
    // - - -
    //Execute the VBS:
    run ("wscript ""%tmp%\tempVBS.vbs""");
    // - - -
    //delete [recycle=1], [confirm], [itemlist]
    //delete 1, 0, "%tmp%\tempVBS.vbs";
   //=====================================================
  //=====================================================
The same without HEREDOC syntax:

Code: Select all

  //User Settings:
  $text = readfile("<xydata>\<xyini>",,1050);
  $waitSec = 10;


  //=====================================================
  //=====================================================
  // Code:
  //
  //Prepare each line for VBS:
  $out="";
  foreach($line, $text, "<crlf>"){ $out = $out . chr(34) . $line . chr(34) . " & vbCRLF _<crlf> & ";}
  $out = replace($out, "&", "", ,strlen($out) -3, 1);
  //
  //Create the VBS file:
  $VBS =        "text =  $out" . "<crlf>";
  $VBS = $VBS . "SET WS = CreateObject(""WScript.Shell"")" . "<crlf>";
  $VBS = $VBS . "'//WshShell.Popup   strMessage [,intSecondsToWait] [,strTitle] [,intType]" . "<crlf>";
  $VBS = $VBS . "WS.popup text, $waitSec" . "<crlf>";
  writefile("%tmp%\tempVBS.vbs", $VBS);
  //
  //Execute the VBS:
  run ("wscript ""%tmp%\tempVBS.vbs""");
  //delete [recycle=1], [confirm], [itemlist]
  //delete 1, 0, "%tmp%\tempVBS.vbs";
  //=====================================================
  //=====================================================

HTH? :wink:


.

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: pop a message, wait few secs and show next text - how?

Post by neutrox »

looks promising but i can't make it show a paragraph after each other...?

stepping didn't helped much. :oops: :roll:

sorry.

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

Re: pop a message, wait few secs and show next text - how?

Post by Stefan »

Since we have no real "user created function" at the moment with XYS
you have to use an pseudo function, build out of 'global vars' , 'hidden scripts' and 'sub' command


See help > Advanced Topics > Scripting
Script Files for the Advanced > Hiding scripts inside a script file
Variables Scope and Lifetime: Local, Global, and Permanent Variables > Global Variables

See help > Advanced Topics > Scripting Commands Reference > sub


Example:

Code: Select all

"Start"
  global $text, $waitSec;
  $waitSec = 5;
  
  // first call:
  $text = "first block 111";
  sub "_function"; 
  wait $waitSec . "000";
  

  // second call:
  $text = "second block 222222";
  sub "_function";
  wait $waitSec . "000";
  

  // third call:
  $text = "third block 3333333333";
  sub "_function";
  wait $waitSec . "000";




// --------------------------------
"_function"
  global $text, $waitSec;
  // pasting here the code block from my last post above:

  //=====================================================
  //=====================================================
  // Code:
  //
  //Prepare each line for VBS:
  $out="";
  foreach($line, $text, "<crlf>"){ $out = $out . chr(34) . $line . chr(34) . " & vbCRLF _<crlf> & ";}
  $out = replace($out, "&", "", ,strlen($out) -3, 1);
  //
  //Create the VBS file:
  $VBS =        "text =  $out" . "<crlf>";
  $VBS = $VBS . "SET WS = CreateObject(""WScript.Shell"")" . "<crlf>";
  $VBS = $VBS . "'//WshShell.Popup   strMessage [,intSecondsToWait] [,strTitle] [,intType]" . "<crlf>";
  $VBS = $VBS . "WS.popup text, $waitSec" . "<crlf>";
  writefile("%tmp%\tempVBS.vbs", $VBS);
  //
  //Execute the VBS:
  run ("wscript ""%tmp%\tempVBS.vbs""");
  //delete [recycle=1], [confirm], [itemlist]
  //delete 1, 0, "%tmp%\tempVBS.vbs";
  //=====================================================
  //=====================================================

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: pop a message, wait few secs and show next text - how?

Post by neutrox »

that solved, thanks!

Post Reply