Jump to content
Sign in to follow this  
neidingd

Beginner Question: WinSetState

Recommended Posts

neidingd

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

Share this post


Link to post
Share on other sites
weaponx

WinActivate ( "title" [, "text"] ) instead of WinSetState.

Share this post


Link to post
Share on other sites
neidingd

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

Share this post


Link to post
Share on other sites
weaponx

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

Share this post


Link to post
Share on other sites
neidingd

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

Share this post


Link to post
Share on other sites
neidingd

Other Question,

give it a way to get the Window Class?

Posted Image

then i can change the code to:

$var = WinList()

For $i = 1 to $var[0][0]
  ...
Next

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.