Jump to content
Sign in to follow this  
Juppedia

Problems with syntax sleep(500) and processes etc. on a Terminal Server

Recommended Posts

Juppedia

Hello,

i am a beginner in Using AutoIT or programming batches.

But I have to start with an difficult example. I need to make it work on an terminal server.

The code shell open the "PROG.exe". Maybe there is a possibility to ask, if this programm/process is running more then once and shut all the other "Prog.exe"-processes.

Besides, does s.b. know how to close this process in all terminal sessions?

But this is my main question:

I need some help with the syntax. Here is my Code:

WinKill("PROG")
WinKill("PROG")
Run("C:\Programme\PROG.exe")
WinWaitActive("PROG)
Send("!D")
Send("S")
Send("A")
Send("{Enter}")
Send("{Enter}")
Sleep(5000)
Send("{Enter}")
Send("{Enter}")
sleep(5000)
Send("!D")
Send("S")
Send("P")
Send("{Enter}")
Send("{Enter}")
sleep(10000)
Send("{Enter}")
Send("{Enter}")
sleep(5000)
WinClose("PROG")

I would like to change the "sleep(5000)" against correct syntax.

It should be checked, if the step is done and then AutoIT can go on.

The reason is, because I cant get fix times for this. The processes can take just 5 seconds or 30 Minutes.

Thank you for every help.

Regards

Jupp

Share this post


Link to post
Share on other sites
Zedna

There are some questions needed for help:

- what is that PROG

- what PROG does

- how you recognize end of work in PROG

Be more specific to get more help ...

Edited by Zedna

Share this post


Link to post
Share on other sites
Juppedia

There are some questions needed for help:

- what is that PROG

- what PROG does

- how you recognize end of work in PROG

http://www.autoitscript.com/forum/style_im...link-button.png

Insert Link

Be more specific to get more help ...

thanks for your answer.

that prog is a "ERP"-Software working on a SQL 2005 DB.

If it's done with copying, it shows a messagebox, with "job done" and a button "OK".

If you press the "return"-button you can go on with next.

got uploaded a screenshot of this msgbox... its nothing special.

post-38343-1217185675_thumb.jpg

Share this post


Link to post
Share on other sites
herewasplato

...The processes can take just 5 seconds or 30 Minutes...

Use the tool named "AutoIt Window Info" to see if there is any unique/visible text that can be used to let the script know when to continue.

Do
    ProcessClose("PROG.exe")
    Sleep(1000)
Until ProcessExists("PROG.exe") = 0

Run("C:\Programme\PROG.exe")
WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("!D")
Send("S")
Send("A")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("!D")
Send("S")
Send("P")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinClose("PROG window title", "some unique text")

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
TerarinKerowyn

If Not ProcessExists("<The name of your programs>") Then

... Execute your code inside this here ...

EndIf

Now any programmer knows that this code can be overcame by changing the letters of the filename or changing the location

Edited by TerarinKerowyn

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites
Juppedia

Use the tool named "AutoIt Window Info" to see if there is any unique/visible text that can be used to let the script know when to continue.

Do
    ProcessClose("PROG.exe")
    Sleep(1000)
Until ProcessExists("PROG.exe") = 0

Run("C:\Programme\PROG.exe")
WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("!D")
Send("S")
Send("A")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("!D")
Send("S")
Send("P")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinActivate("PROG window title", "some unique text")
WinWaitActive("PROG window title", "some unique text")
Send("{Enter}")
Send("{Enter}")

WinWait("PROG window title", "some unique text")
WinClose("PROG window title", "some unique text")
thanks a lot four your answers guys! ;-)

Do you think, this is gonna work on a terminalserver.

My main problem is, that I can't get closed the processes in the terminal sessions.

Or would this script do this?

Share this post


Link to post
Share on other sites
herewasplato

...Do you think, this is gonna work on a terminalserver...

I was kinda hoping you would follow Zedna's advise and "Be more specific to get more help ..."

According to http://en.wikipedia.org/wiki/Terminal_server - the term "terminal server" can mean a few different things... I don't know much about such things. Perhaps others can help.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Zedna

Do you think, this is gonna work on a terminalserver.

If you run your ERP from MSTSC client then try to use ImageSearch

http://www.autoitscript.com/forum/index.ph...mp;#entry488195

Make screenshot of your messagebox save it as BMP file and in your script in While loop wait till this image is recognized on the screen by ImageSearch.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×