Newby question - need a script to stop another script

Discussion in 'Javascript' started by Steve Henderson, Oct 6, 2003.

  1. I have really surprised myself and written a script that actually works!
    <grin>. As you will be able to tell, I'm really, really new to this
    scripting stuff... My script does a task and then sleeps for 5 seconds, and
    does it again (which is what I want). My trouble is that I can't find a way
    to stop it without pulling up "task manager" and killing it using brute
    force. I think I can use the Popup method with a nsecondstowait value so
    that everytime thru the while loop, it pops up and gives me a chance to push
    an "OK" button to send the script to an exit, otherwise it times out, and
    runs thru the loop again. However, the popup wants to come up in the exact
    middle of my screen... and the REAL task I'm doing is to capture parts of
    the screen that's changing. When the popup comes up, it gets captured (bad).
    So I need another way to kill this thing. Can I write another little script
    that will kill this one?

    Just for an example, I submit this script below (not the actual one I'm
    doing, to save space here). If someone can tell me how to kill this one, I
    can apply that to my real one... this really sounds like it should be
    simple, but I just can't figure it out...

    Example.js (just brings up Word, and sends the character "A" to it over
    and over...)
    ==================================
    var WshShell = WScript.CreateObject("WScript.Shell");
    WshShell.Run("Winword");
    while(1)
    {
    WshShell.AppActivate("Winword");
    WshShell.SendKeys("A");
    WScript.Sleep(5000);
    }

    ===================================

    Steve Henderson
     
    Steve Henderson, Oct 6, 2003
    #1
    1. Advertising

  2. Steve Henderson

    Erwin Moller Guest

    Why post this question in this javascript ng?

    Regards,
    Erwin Moller
     
    Erwin Moller, Oct 6, 2003
    #2
    1. Advertising

  3. What you have is an infinite loop, which is why it never quits. What you
    need is some variable at the end of the loop that increases its value by
    1 each time through the loop. Then, instead of while(1) you write

    ....
    while(somevariable < x)
    {
    ...
    somevariable = somevariable + 1
    }

    where x is set to some number 1 greater than the number of times you
    want the loop to run.

    HTH,

    Dave

    "Steve Henderson" <> wrote in message
    news:dr1gb.2545$...
    : I have really surprised myself and written a script that actually
    works!
    : <grin>. As you will be able to tell, I'm really, really new to this
    : scripting stuff... My script does a task and then sleeps for 5
    seconds, and
    : does it again (which is what I want). My trouble is that I can't find
    a way
    : to stop it without pulling up "task manager" and killing it using
    brute
    : force. I think I can use the Popup method with a nsecondstowait value
    so
    : that everytime thru the while loop, it pops up and gives me a chance
    to push
    : an "OK" button to send the script to an exit, otherwise it times out,
    and
    : runs thru the loop again. However, the popup wants to come up in the
    exact
    : middle of my screen... and the REAL task I'm doing is to capture parts
    of
    : the screen that's changing. When the popup comes up, it gets captured
    (bad).
    : So I need another way to kill this thing. Can I write another little
    script
    : that will kill this one?
    :
    : Just for an example, I submit this script below (not the actual one
    I'm
    : doing, to save space here). If someone can tell me how to kill this
    one, I
    : can apply that to my real one... this really sounds like it should be
    : simple, but I just can't figure it out...
    :
    : Example.js (just brings up Word, and sends the character "A" to it
    over
    : and over...)
    : ==================================
    : var WshShell = WScript.CreateObject("WScript.Shell");
    : WshShell.Run("Winword");
    : while(1)
    : {
    : WshShell.AppActivate("Winword");
    : WshShell.SendKeys("A");
    : WScript.Sleep(5000);
    : }
    :
    : ===================================
    :
    : Steve Henderson
    :
    :
    :


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.522 / Virus Database: 320 - Release Date: 9/29/2003
     
    J. David Kent, Oct 9, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    698
    Iain Norman
    Feb 16, 2005
  2. Blue Streak
    Replies:
    1
    Views:
    314
    Bruce Barker
    Dec 14, 2005
  3. Darren
    Replies:
    1
    Views:
    431
    Martin Honnen
    Mar 13, 2007
  4. Andrew Jocelyn
    Replies:
    2
    Views:
    1,561
    Allen Chen [MSFT]
    Apr 27, 2009
  5. Rodrigo Cortés

    Do i need a framework??? [newby question]

    Rodrigo Cortés, Feb 13, 2008, in forum: Ruby
    Replies:
    1
    Views:
    102
    Marc Heiler
    Feb 13, 2008
Loading...

Share This Page