Sign in to follow this  
Followers 0
Kangaroo

WinWaitClose

6 posts in this topic

#1 ·  Posted (edited)

I didnt use AutoIt for a while, but to autmate some administrative tasks I downloaded the current version today and started some coding.

But it seems I lost my touch, because I cant explain why WinClose seems to work fine for me and WinWaitClose doesnt.

If I start calc.exe

;-- close Window
WinClose("Rechner")
works fine and closes the calculators window.

But

;-- close Window
WinWaitClose("Rechner")
just sits there forever.

What's wrong here ?

Edited by Kangaroo

Share this post


Link to post
Share on other sites



moin moin,

das winwaitclose heisst das dein script wartet bis der rechner nicht mehr existiert.... nich das du ihn schliesst.

translation 4 all: winwaitclose just waits till "rechner" isnt present anymore, it dont close "rechner"

Share this post


Link to post
Share on other sites

hmpfh, of course ... should read the help file more closely in the future.

thx andygo

Share this post


Link to post
Share on other sites

But I think

ProcessClose ("calc.exe")
would be a better one, because it closes the process, not closes the window; your script MAY not work on other computers, because the language is different.

So...

I advise you to always use the process name; the language may be different, but the process name is not. :D


JPGRARMouse Lock | My website | Thanks so much for your help! ❤️

Share this post


Link to post
Share on other sites

But I think

ProcessClose ("calc.exe")
would be a better one, because it closes the process, not closes the window; your script MAY not work on other computers, because the language is different.

So...

I advise you to always use the process name; the language may be different, but the process name is not. :D

A belated welcome to the forums.

WinClose is "kinder" to the process being closed. ProcessClose does not let the app warn the user of any unsaved data. ProcessClose also prevents apps from writing some data to ini files or the the registry. It is not the preferred method... but for cacl.exe, it does not matter which you use. Unless you only want to close the cacl.exe that the script started and not the one that the user might have open :-)

You raise a good point about languages and window titles - but there are ways around that.

i.e. the OP mentioned "If I start calc.exe" - that could mean that the script started the app of interest.

If so, then the script can know the Process ID of the app that it started...

...and from that, the handles of the windows it spawns.

Window handles can be used in the place of window titles in the Win....() functions:

http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd.au3

If the script did not start the app that it is attempting to close, then use ProcessExiststo get the PID of calc.exe or notepad.exe


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  
Followers 0