Problems with Macro Scheduler / WaitWindowClosed

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
EvilsResonance
Newbie
Posts: 4
Joined: Mon Dec 20, 2004 10:52 am

Problems with Macro Scheduler / WaitWindowClosed

Post by EvilsResonance » Mon Dec 20, 2004 11:34 am

Hi,

We have a licensed copy of Macro Scheduler here for commercial use, but we have some problems. I hope you can help us :-)

Our Macro runs a program with some parameters.
A new Window opens. After this operation i will wait until the opened window is closed. I use " WaitWindowClosed " for this instruction.

in principle this macro runs perfect, but however it occurs frequently that the instruction "WaitWindowClosed" has been ignored and the next Step of Macro will be executed. Our Macro is partitioned in three steps. Each step runs a program (window opens) and the Macro is holded until this window is closed. If this condition is true, the next Step will runs and opens a new window. These windows have the same window title. The program needs to be opened the whole day. For this reason I must terminate and then start the program with parameters again.

We can only run Macros in this program about parameters in the commandline. We close the program and restart it with the macro parameters. But if the WaitWindowClosed step is ignored, we have two windows with the same name opened. Now the macro hangs until the second window is closed.

How can I avoid this problem?

I hope you can understand my problem definition.
Im from Germany... sorry for bad english :-)


I would be pleased about your answers.



Macro:


// Navision Fenster bereits geöffnet ? Ansonsten starten
IfWindowOpen>C:\Navi\NAVIN.EXE,weiter
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=DV04,Temppath=c:\Navitemp\EDITemp
Wait>3
Label>weiter
Goto>Start

//Verschieben der orders.dat
Label>In
Let>quellein=d:\EDIalog\daten\appl\empf\orders.dat
Let>zielin=d:\x400\tmobil\in\
MoveFile>quellein,zielin
Wait>10
Goto>Macro1

//Ausführen von Navision Makro 1 [ M1 - Einlesung von orders.dat ]
Label>Macro1
CloseWindow>C:\Navi\NAVIN.EXE
Wait>1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM1,Temppath=c:\Navitemp\EDITemp,macro=c:\navi\m1
Wait>2
Let>WW_TIMEOUT=180
WaitWindowClosed>C:\Navi\NAVIN.EXE
Wait>1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM1,Temppath=c:\Navitemp\EDITemp
Wait>3
If>WW_RESULT=TRUE,Macro2
ScreenCapture>0,0,1024,768,P:\Error_M1.jpg
Goto>Error1

//Ausführen von Navision Makro 3 [ M3 - Stapel Aufträge anlegen ]
Label>Macro2
CloseWindow>C:\Navi\NAVIN.EXE
Wait>
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM2,Temppath=c:\Navitemp\EDITemp,macro=c:\navi\m3
Wait>2
Let>WW_TIMEOUT=180
WaitWindowClosed>C:\Navi\NAVIN.EXE
Wait>1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM2,Temppath=c:\Navitemp\EDITemp
Wait>3
If>WW_RESULT=TRUE,Macro3
ScreenCapture>0,0,1024,768,P:\Error_M3.jpg
Goto>Error2

//Ausführen von Navision Makro 4 [ M4 - Packlisten drucken ]
Label>Macro3
CloseWindow>C:\Navi\NAVIN.EXE
Wait>1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM4,Temppath=c:\Navitemp\EDITemp,macro=c:\navi\m4
Wait>3
Let>WW_TIMEOUT=180
WaitWindowClosed>C:\Navi\NAVIN.EXE
Wait>1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM4,Temppath=c:\Navitemp\EDITemp
Wait>3
If>WW_RESULT=TRUE,End
ScreenCapture>0,0,1024,768,P:\Error_M4.jpg
Goto>Error3

//Archivierung der orders.dat
Label>DoArchiv
Let>pfadin=d:\x400\tmobil\in\
Let>pfadarchiv=F:\x400\In\Archiv\
Let>quelle=d:\x400\tmobil\in\orders.dat
Let>endung=.dat
Let>ziel=d:\x400\tmobil\in\orders_%f1%%f2%%f3%_%f4%%f5%%endung%
CopyFile>quelle,ziel
Wait>10
MoveFile>ziel,pfadarchiv
Wait>10
DeleteFile>%quelle%
IfFileExists>d:\EDIalog\daten\appl\empf\orders.dat,In
Goto>End

//Überprüfung ob orders.dat vorhanden ist
Label>Archiv
IfFileExists>d:\x400\tmobil\in\orders.dat,DoArchiv
Goto>In

Label>Start
GetDate>thedate
GetTime>thetime
Day>f1
Month>f2
Year>f3
Hour>f4
Min>f5
IfFileExists>d:\EDIalog\daten\appl\empf\orders.dat,Archiv
Goto>End

//Ausgabe und versendung der E-Mail Nachricht, wenn Timeout in M1 erreicht ist
Label>Error1
GetDate>thedate
GetTime>thetime
CopyFile>c:\txt\error_M1_mail.txt,o:
WriteLn>c:\tmobil.txt,result, %thedate% %thetime% *** Fehler: [TIMEOUT] Makro: M1
Wait>5
DeleteFile>P:\Error_M1.jpg
Goto>ErrorArchiv

//Ausgabe und versendung der E-Mail Nachricht, wenn Timeout in M3 erreicht ist
Label>Error2
GetDate>thedate
GetTime>thetime
CopyFile>c:\txt\error_M3_mail.txt,o:
WriteLn>c:\tmobil.txt,result, %thedate% %thetime% *** Fehler: [TIMEOUT] Makro: M3
Wait>5
DeleteFile>P:\Error_M3.jpg
Goto>ErrorArchiv

//Ausgabe und versendung der E-Mail Nachricht, wenn Timeout in M4 erreicht ist
Label>Error3
CopyFile>c:\txt\error_M4_mail.txt,o:
GetDate>thedate
GetTime>thetime
WriteLn>c:\tmobil.txt,result, %thedate% %thetime% *** Fehler: [TIMEOUT] Makro: M4
Wait>5
DeleteFile>P:\Error_M4.jpg
Goto>ErrorArchiv

//Archivierung beim Auftreten eines Fehlers
Label>ErrorArchiv
Let>quelle=d:\x400\tmobil\in\orders.dat
Let>endung=.dat
Let>ziel=F:\x400\in\ErrorArchiv\orders_%f1%%f2%%f3%_%f4%%f5%%endung%
MoveFile>quelle,ziel
CopyFile>c:\txt\error_archiv_mail.txt,o:
Goto>End

Label>End

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Dec 20, 2004 12:07 pm

I think you mean WaitWindowClosed as I don't see a WaitWindowOpen in your script. Since you are not waiting for the window to open before waiting for it be closed (not existing) then what you describe is likely to happen.

Anyway, I think there is a better way for you. Looking at your script it looks like you are starting a program and just want to wait for it to finish before the script continues. If this is the case why not just do this:


Let>RP_WAIT=1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM4,Temppath=c:\Navitemp\EDITemp,macro=c:\navi\m4
etc


Setting RP_WAIT to 1 makes the Run Program wait until the program terminates before continuing.
MJT Net Support
[email protected]

Guest

Post by Guest » Mon Dec 20, 2004 12:34 pm

Hello,

thanks for the fast answer but i have one more question.
Is it possible to set an Timeout for the rp_wait procedure??

Let>RP_WAIT=1

works perfect, but i need to set an timeout if the programm runs longer than e.g. 10 Minutes or higher. In this case the program will run infinitly with no end.

----

Let>WW_TIMEOUT=180
WaitWindowClosed>C:\Navi\NAVIN.EXE
Wait>1
Run Program>C:\Navi\NAVIN.EXE serverno=1,ID=MacroM1,Temppath=c:\Navitemp\EDITemp
Wait>3
If>WW_RESULT=TRUE,Macro2
ScreenCapture>0,0,1024,768,P:\Error_M1.jpg
Goto>Error1

----

At present the script capture me an screenshot and sends it to my E-Mailadress if the window is longer than 180 seconds open.

thanks for your further information.

Greetings

EvilsResonance

EvilsResonance
Newbie
Posts: 4
Joined: Mon Dec 20, 2004 10:52 am

Post by EvilsResonance » Mon Dec 20, 2004 12:36 pm

Sorry, i was not logged in.

Last Posting is from me.

aquarious
Newbie
Posts: 3
Joined: Thu Feb 24, 2011 4:50 am

Post by aquarious » Thu Feb 24, 2011 5:07 am

Hi,

I m new it takes me a while to get one of the posting that related to Navision. I hope someone could help me as i new towards Macro Scheduler. I m trying a simple action to open Navision Database and then Close the Database. following is my script

kindly help

//Script Begin
//To Run and Open Navision Database
RunProgram>"C:\Program Files\Navision 3.70\Client\fin.exe" database="C:\Program Files\Navision 3.70\Client\database.fdb"

WAIT 3

//To Log out or Close Microsoft Navision Navision
Press ALT
SendText>fx
Release ALT

//Script END

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