neidingd Posted January 18, 2008 Posted January 18, 2008 Hello, i started today with AutoIt to solve a problem in our Firm. We have to check before our backup start if all programs are closed. So i had the idea that we could close all programs at 19:00. The Idea for the script ist - get the process for wrun32.exe (runtime for all of our programs) - activate window of the process - Hit F7 until the process is closed (F7 = Key to finish anything in our software) here is the code i wrote atm: $list = ProcessList("wrun32.exe") for $i = 1 to $list[0][0] If not WinActive($list[$i][1]) then MsgBox(0, "", "Window was not active") WinSetState($list[$i][1], "", @SW_ENABLE) WinWaitActive($list[$i][1], "", 5) EndIf If ProcessExists($list[$i][1]) Then Do Send("{F7}") Until Not ProcessExists($list[$i][1]) EndIf next The problems seems to be the WinSetState ( "title", "text", flag ) i tested it with @SW_SHOW and @SW_ENABLE but nothing happens can anyone give me a little help? David
weaponx Posted January 18, 2008 Posted January 18, 2008 WinActivate ( "title" [, "text"] ) instead of WinSetState.
neidingd Posted January 18, 2008 Author Posted January 18, 2008 still don't work i changed the code to:$list = ProcessList("wrun32.exe") for $i = 1 to $list[0][0] If not WinActive($list[$i][1]) Then MsgBox(0, "", "Window was not active") WinActivate($list[$i][1], "") WinWaitActive($list[$i][1], "", 5) EndIf If WinActive($list[$i][1]) Then If ProcessExists($list[$i][1]) Then Do Send("{F7}") Until Not ProcessExists($list[$i][1]) EndIf EndIf nextThe Windows still don't get activated.. and i also added a test if the window is activated before i send the F7-Key..without it my pc crashed 2 times ^^David
weaponx Posted January 18, 2008 Posted January 18, 2008 (edited) I'm confused as to why you are using ProcessList(). This will return a list of ALL PID's for "wrun32.exe", how many instances are there?. You are trying to use Win* functions against PID's and that doesn't fly. You need to be using window handles with Win* functions. Edited January 18, 2008 by weaponx
neidingd Posted January 21, 2008 Author Posted January 21, 2008 (edited) could be many instances... the programs are codec in AcuCobol and Acu use a runtime called wrun32.exe to execute the code... so every program in our firm is a wrun32.exe process. If i use ProcessList("wrun32.exe") i get all running processes which i have to close. but i can't kill the process because the open files should be closed proper. Edited January 21, 2008 by neidingd
neidingd Posted January 21, 2008 Author Posted January 21, 2008 Other Question,give it a way to get the Window Class?then i can change the code to:$var = WinList() For $i = 1 to $var[0][0] ... Next
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