Jump to content

Beginner Question: WinSetState


 Share

Recommended Posts

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 :D

can anyone give me a little help?

David

Link to comment
Share on other sites

still don't work :D

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
next

The Windows still don't get activated.. :P

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

Link to comment
Share on other sites

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 by weaponx
Link to comment
Share on other sites

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 by neidingd
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...