ZepheR Posted June 4, 2006 Share Posted June 4, 2006 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 More sharing options...
MHz Posted June 4, 2006 Share Posted June 4, 2006 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 More sharing options...
Emperor Posted June 4, 2006 Share Posted June 4, 2006 While 1 If WinExists("Window1") Then Window1Func() ExitLoop ElseIf WinExists("Window2") Then Window2Func() ExitLoop EndIf WEnd Perhaps this does the trick Link to comment Share on other sites More sharing options...
ZepheR Posted June 4, 2006 Author Share Posted June 4, 2006 (edited) While 1 If WinExists("Window1") Then Window1Func() ExitLoop ElseIf WinExists("Window2") Then Window2Func() ExitLoop EndIf WEnd Perhaps this does the trick 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. 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. Edited June 4, 2006 by ZepheR Link to comment Share on other sites More sharing options...
Emperor Posted June 4, 2006 Share Posted June 4, 2006 (edited) Yes, add a Sleep() just before the WEnd. Edited June 4, 2006 by Emperor Link to comment Share on other sites More sharing options...
Uten Posted June 4, 2006 Share Posted June 4, 2006 (edited) 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 June 4, 2006 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now