Close app by filename

%AppFile% should hold the name of the application's executable. It is then sent the WM_CLOSE message. If it doesn't react in 5 seconds (10 tries) the task gets killed.

TryClose:
  Process Exist, %AppFile%
  If ErrorLevel
    ProgPID = %ErrorLevel%
  Else
    Goto CloseDone
 
  WinClose ahk_pid %ProgPID%, , 0.5
  If Counter >= 10
    Process Close, %ProgPID%
  Counter += 1
  Goto TryClose
 
  CloseDone:

 
snippets/autohotkey/close-app-by-filename.txt · Last modified: 2009-02-03 21:39.03 by mbirth
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Contents powered by Club-Mate Contents powered by BassDrive.com Labelled with ICRA