Link to home
Start Free TrialLog in
Avatar of bmcnulty
bmcnulty

asked on

WinWaitActive parameters

I am trying to use autoit to create a script that will wait until a folder is opened, then execute a bat file. So far i have it compiled and running , waiting for me to open the "test" folder, but i think i may be missing another parameter for it.


WinWaitActive("test")
RunWait(@COMSPEC & " /c c:\test.bat")
Avatar of LockDown32
LockDown32
Flag of United States of America image

You have the parameters correct. It must be active. Click on it once it is opened. Doesn't it work?
I just tried it. When I open the folder in XP it is C:\Test not just Test. Look at the Window Title carefully....
Avatar of bmcnulty
bmcnulty

ASKER

Ok so that works, now the problem i see is it will also run anytime i set focus to the test window, is there a parameter for when i open a folder?
It will only run every time you activate the window if you put it in an infinite loop. What are you trying to do? Just do it one time only?
Yes, i need to run a batch file when a user opens a folder. Then it needs to restart itself once finished so it's ready if they open it again.
Still not clear enough. The first time they open that folder (which will be the active window) it runs. You didn't answer but you put this in a infinite loop?

Anyway... after you run the bat file close the Windows. That way it will only run again if they re-open that folder...

WinWaitActive("test")
RunWait(@COMSPEC & " /c c:\test.bat")
Winclose("test")
I set it to restart itself once finished, since it needs to be ready again if they decide to close and re-open the folder, otherwise the exe runs once and closes when done..so it becomes a loop if they set focus on a different window, then back to the test folder.

Maybe i can have the script start a "restart" script on close?  That way when they are done working in the folder it restarts the first script.
 first script:
WinWaitActive ("test")
RunWait(@COMSPEC & " /c c:\test\test.bat" , "C:\test" )
RunWait(@ComSpec & " /c c:\test\restart.exe", "C:\test" )


run on closing the folder?
WinWaitClose ("test")
RunWait(@ComSpec & " /c c:\test\Copy.exe", "C:\test" )
I am still struggling with what you want to do. The first time they open that folder it is obvious. Run the bat. OK now they have a couple choices.

1) They can keep clicking on that window which will re-running the bat file
2) They can close the Window

What do you want to do in each case?
1: they open the folder and it runs the batch file
2: I do not want it to run again  while they are working in that folder, I.E clicking on that window.
3: when they are done, they will close the folder and the next time they open the folder, it will run the batch file again. Which is why i think i need to have a script that will trigger off them closing the folder, starting the first script that runs the batch file.
ASKER CERTIFIED SOLUTION
Avatar of LockDown32
LockDown32
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect! thanks!
Got to love AutoIT :)