By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIt WinKill Function

Use the WinKill function to force a window to close, skipping save dialogs etc.

Edited: 2015-02-12 19:45

The AutoIt WinKill function is used to forcibly close a window. A potential disadvantage is that the user wont be able to respond to prompts to save unsaved work, and as such they might lose their work.

If you want to close a window normally, and allow the window or program time to close - as well as display possible save dialogs - you should consider using WinClose instead

Parameters

TitleThe title of the window.
TextThe text of the window.

WinKill Example

Run("notepad.exe")

$hWnd = WinWait("[CLASS:Notepad]", "", 10)

; Wait a couple of seconds before closing the window
Sleep(2000)

; Closes the window
WinKill($hWnd, "")