Skip to content

Instantly share code, notes, and snippets.

@philipbjorge
Created June 2, 2012 23:39
Show Gist options
  • Save philipbjorge/2860507 to your computer and use it in GitHub Desktop.
Save philipbjorge/2860507 to your computer and use it in GitHub Desktop.
Notepad Instance Cleanup
; Stupid simple autoit script for cleaning up "orphaned" notepad instances
; I end up with dozens of notepad instances after a day of coding and it's a pain to close all these manually
; as I do want to keep some of them.
; Public Domain
; Philip Bjorge
; June 2, 2012
Local $windows=WinList()
For $i = 1 To $windows[0][0]
If StringInStr($windows[$i][0], "Notepad", 0) Then
WinSetState($windows[$i][1], "", @SW_MAXIMIZE)
If MsgBox(4, "Notepad Cleaner", "Do you want to kill this notepad instance?", 0, $windows[$i][1]) = 6 Then
WinClose($windows[$i][1])
WinWaitActive("Notepad", "Save")
;WinWaitActive("Notepad", "Do you want to save") ; When running under Windows XP
Send("!n")
EndIf
EndIf
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment