#SingleInstance ignore ; 載入訊息字串檔 #include strings.ahk ; 設定系統列圖示及選單 Menu, Tray, Tip, %TrayTipDeleteAllOperaFiles% Menu, Tray, NoStandard Menu, Tray, Add, %TrayMenuItemDebugWindow%, debugwindow Goto, mainscript debugwindow: ListVars return mainscript: ; 關閉所有執行中的 Opera Process, Close, opera.exe ; 詢問是否要刪除所有 Opera 留下來的檔案 MsgBox, 36, %TitleDelete%, %AskDelete% IfMsgBox, No ExitApp ; 從登錄讀取 Opera 的安裝路徑(如果有的話),讀出來的東西會是類似 "PATH\Opera.exe" "%1" 這樣的字串 RegRead, OperaInstallPathReg, HKLM, SOFTWARE\Classes\Opera.HTML\shell\open\command ; 祇有 PATH 那串有用,所以用正規表示式切出來 OperaInstallPath := RegExReplace(OperaInstallPathReg, ".(.:.+)\\[Oo]pera\.exe.+$", "$1") if (OperaInstallPath = "") { ; 如果讀不到路徑,纔去詢問使用者 FileSelectFolder, OperaInstallPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 0, %SelectOperaPath%`n%ProgramFiles%\Opera } if (OperaInstallPath = "") { ; 如果從登錄讀不到路徑,使用者又沒有設定(按了取消),就用預設值 OperaInstallPath = %ProgramFiles%\Opera } ; 取得 Opera 安裝路徑後,就整個刪除 FileRemoveDir, %OperaInstallPath%, 1 ; 刪除後把安裝路徑變數也清空 OperaInstallPath = ; 接著刪除 %APPDATA%\Opera FileRemoveDir, %APPDATA%\Opera, 1 ; 最後刪除 %USERPROFILE%\Local Settings\Application Data\Opera FileRemoveDir, %USERPROFILE%\Local Settings\Application Data\Opera, 1 ; 告知刪除完成 MsgBox, 64, %TitleDone%, %MessageDeleteDone% ; 離開 AutoHotKey 腳本 ExitApp