Jump to content

if this window opens do this, but if this windows do that


Recommended Posts

Hi guys,

I'm hoping some of you brainboxes can help me solve this problem. I'm writing a little autoit program (my 1st actually, and i must say I'm enjoying it loads) which will automate system benchmarks. All is going really well expect for this little problem I'm trying to solve.

My program opens a benchmark and runs it, if all goes well the bench finishes and my program takes the results and logs them. The trouble is though, if the bench is aborted my program sits there waiting on a results window that will never appear. So what I am trying to do is something like this.

If <window A opens> then

<do window A function>

ElseIF <window B opens> then

<do window B function>

EndIF

I hope I explained that well enough...

I can't work out a way to do this, or if it's even possible, so any help given will be greatly appreciated.

Thanks in advance.

Link to comment
Share on other sites

Just a thought...

$time = TimerInit()
While TimerDiff($time) < 10000
    If <window A opens> then 
        <do window A function>
    ElseIF <window B opens> then
        <do window B function>
    EndIF
    Sleep(500)
WEnd
Link to comment
Share on other sites

While 1
  If WinExists("Window1") Then
    Window1Func()
    ExitLoop
  ElseIf WinExists("Window2") Then
    Window2Func()
    ExitLoop
  EndIf
WEnd

Perhaps this does the trick :D

Firstly, thanks for your prompt replies!

This does exactly what I need to do, the only problem is that the loop uses 100% cpu, which affects the benchmarks I'm trying to run. :P

Any ideas if this can be done without eating so much cpu time?

Edit: Ahha! Adding a sleep(500) cuts down a lot of cpu time. I'll play about to find the best balance but this method seems to work good. Thanks a lot. :D

Edited by ZepheR
Link to comment
Share on other sites

I think you will find the regexp support in the Win* functions helpfull

While 1
AutoItSetOption("WinTitleMatchMode", 4)
WinWaitActive("regexp=.*[Nn]otepad.*|[cC]:\\.*")
msgbox(0,"ACTIVE",WinGetTitle(""),20)
WEnd
Edited by Uten
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...