Close Message Window in Looping Script

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kriemer
Pro Scripter
Posts: 57
Joined: Fri Oct 30, 2009 2:59 pm

Close Message Window in Looping Script

Post by kriemer » Fri Jan 15, 2010 5:34 pm

I apologize if this should be considered a continuation of previous posts, but I thought this is a different question hence a different thread.

The code below does everything I want, except display that the script is still running (timer is set to 2 hours and can loop a number of times). I've added a message>LoopCount (which works), my problem is that the window interrupts the script until the ok button is clicked.

Any suggestions are welcome.

Code: Select all

//Delete Output Files
  DeleteFile>C:\Users\Output\Estimates_a\*.*
  DeleteFile>C:\Users\Output\Estimates_b\*.*
 
  //Set Script Variables
  Let>loopcounter=0
  Let>Missing=Missing:%CRLF%

  //Loop Counter
  Repeat>loopcounter
  Let>loopcounter=loopcounter+1

  //Exit Script If ALL Files Exist,
  IfFileExists>C:\Users\Output\Estimates_a\Estimates a_data,,Skip
  IfFileExists>C:\Users\Output\Estimates_b\Estimates b_data,,Skip
  Exit>0
  Label>Skip

?????????????????????????????????????????????????????
  IfWindowOpen>Macro Scheduler Message
     CloseWindow>Macro Scheduler Message
  else
     //Do nothing
  endif>
  Message>Loop Count = %loopcounter% of 4%CRLF%Loop Time = 2 hours
??????????????????????????????????????????????????????

  IfFileExists>C:\Users\Output\Estimates_a\Estimates a_data.xls
    //Do nothing
  else
    Let>Missing=%Missing%(%loopcounter%)Estimates a %CRLF%
    run>"C:\Program Files\RunProject.exe" "C:\Users\Estimates a.rip"
  endif>

  IfFileExists>C:\Users\Output\Estimates_b\Estimates b_data.xls
    //Do nothing
  else
    Let>Missing=%Missing%(%loopcounter%)Estimates b %CRLF%
    run>"C:\Program Files\RunProject.exe" "C:\Users\Estimates b.rip"
  endif>

      //Pause Loop <<<<Set>7200

  //Kill RunProject
  VBSTART
  set wmi = getobject("winmgmts:")
  sQuery = "select * from win32_process where name = 'RunProject.exe'"
  set processes = wmi.execquery(sQuery)
    for each process in processes
    process.terminate
  next
  VBEND

  //Loop Script "n" Times <<<<Set>loopcounter>3

    //On File Exists Error > 1; Save Log File
  Let>LogFile=C:\Users\Log\Log.txt
  GetDate>vToday
  Timestamp>LogFile,%vToday%, %Missing%
Regards

k

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Works for me

Post by gdyvig » Fri Jan 15, 2010 11:55 pm

Hi kriemer,

Your message should not be interupting the script because it is non-modal.

One option is to leave it displayed.
With each iteration of the loop the message in the window changes.
You don't have to close it, though your code to do so works for me.


Gale

kriemer
Pro Scripter
Posts: 57
Joined: Fri Oct 30, 2009 2:59 pm

Post by kriemer » Sat Jan 16, 2010 3:12 am

I finally figured out what is not working. This part of the code exits the script if both files exists. This bypasses saving to the logfile.

Code: Select all

 //Exit Script If ALL Files Exist,
  IfFileExists>C:\Users\Output\Estimates_a\Estimates a_data,,Skip
  IfFileExists>C:\Users\Output\Estimates_b\Estimates b_data,,Skip
  Exit>0
  Label>Skip
My objective is:
1. Delete existing files
2. Run "run>"C:\Program Files\RunProject.exe" "C:\Users\Estimates a.rip"
endif>" ONLY if files a does not exist, etc.
3. Kill RunProject if it is hung-up
4. Loop and test if files exist, i.e RunProject created file
5. Log the steps

The "//Exit Script If ALL Files Exist" part of the code is an attempt to end the macro on the 1st pass if that is all that is required.

The logic of "one file does not exist so loop", is not quite the same as "all files exist so end.

Hope I was clear.

Thanks 10^6 for your comments.

k

kriemer
Pro Scripter
Posts: 57
Joined: Fri Oct 30, 2009 2:59 pm

I feel like the sounth end of a horse facing north (again)

Post by kriemer » Mon Jan 18, 2010 3:20 am

I now see that the script does all the things I thought it did not, i.e., Tests if all files are present then "Exits" (or whatever), passes code after message window.

Apologies for wasting anyone's time looking at this.

Regards

k

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts