關閉所有視窗的小工具:CloseAll.exe

因為在Windows 2000上同時要開啟許多個文字檔來檢查,在檢查後再逐一關閉視窗,檔案一開多這些關閉的動作變得異常煩人,找看看有沒有全部關閉的工具,結果只發現適用於Windows XP、Windows 7的CloseAll.exe NTWind Software,只好用Autohotkey寫個簡單的工具來用。

以下是關閉所有視窗的Autohotkey腳本:

;====CLOSE ALL WINDOWS====

;; 比對Window class, 清單裡的不關閉
MatchList = CabinetWClass,ConsoleWindowClass,VNCMDI_Window,EmEditorMainFrame3

;;^!BackSpace::
WinGet, ID, List, , , Program Manager
Loop, %ID% {
  StringTrimRight, This_ID, ID%A_Index%, 0
  WinGetTitle, This_Title, ahk_id %This_ID%
  WinGetClass, This_Class, ahk_id %This_ID%
  StringGetPos, iPos, MatchList, %This_Class%
  ;;MsgBox %This_Title%: %iPos%, cls=%This_Class%
  ;;If This_Title in %MatchList%
  if (iPos >= 0) {
    ;;MsgBox "don't clode %This_Title%"
    Continue
  }
  WinClose, %This_Title%
  ;;MsgBox close %This_Class%
}
Return 

寫好後再用ahk2exe.exe將.ahk轉換成執行檔:

ahk2exe /in closeall.ahk

##

您可能也會有興趣的類似文章

簡睿

服務於軟體業的資訊老兵。興趣廣泛,學習力佳,樂於分享所知所學。

您可能也會喜歡…

2 個回應

  1. 見人表示:

    請問,這裡的StringTrimRight, This_ID, ID%A_Index%, 0和This_ID := ID%A_Index%有什麼不同嗎?

    • 簡睿表示:

      看起來結果似乎是相同的…請用messageBox 顯示看看。

      這個程式主要是搜尋後copy and paste的,再稍微用class做例外處理。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *