Jump to content

Recommended Posts

Hi all, I am writing some scripts to control some lab equipment, and sometimes I observe that the script "misses" one of the steps, leading to cascading errors. For example, at one part of the code I wrote this:

WinClose("Port_Configuration")
Sleep(1000)
WinClose("Hype")
Sleep(1000)
Run("C:\Users\cabrunco\Desktop\Hype!Terminal.exe")

Most of the times this works, but I found that in some occasions the windows fail to close. Then, the code becomes a mess, because a second instance of the program will launch, and both windows now have the same title. I think I can solve this problem with this code:

While WinExists("Hype")
    WinClose("Port_Configuration")
    Sleep(1000)
    WinClose("Hype")
    Sleep(1000)
WEnd
Run("C:\Users\matheus\Desktop\Hype!Terminal.exe")

I would like to know if anybody has any other suggestions for this kind of redundant code. Thanks,

Matheus

 

 

 

Link to comment
Share on other sites

To more accurately target a specific window, perhaps look at getting the Handle and maybe even using the PID.

You may also be able to close the main process, to make sure the window(s) close.

Testing the status of the window to allow exiting the loop, beyond what you have done, could also be used ... as in have an alternate response upon repeated failure.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
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
 Share

×
×
  • Create New...