Page 1 of 1

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

Posted: 02 Apr 2012 16:22
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.

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

Posted: 02 Apr 2012 20:56
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:


.

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

Posted: 03 Apr 2012 16:22
by neutrox
looks promising but i can't make it show a paragraph after each other...?

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

sorry.

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

Posted: 03 Apr 2012 17:15
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";
  //=====================================================
  //=====================================================

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

Posted: 04 Apr 2012 11:37
by neutrox
that solved, thanks!