#SingleInstance ignore package = installer ; 載入訊息字串檔 #include strings.ahk ; 設定系統列圖示及選單 Menu, Tray, Tip, %TrayTipInstaller% Menu, Tray, Icon, opera.ico, 1, 1 Menu, Tray, NoStandard Menu, Tray, Add, %TrayMenuItemDebugWindow%, debugwindow Goto, mainscript debugwindow: ListVars return mainscript: #include magicword.ahk ; 取得目前螢幕可用區域解析度資訊 SysGet, MonitorWorkArea, MonitorWorkArea ; 顯示安裝進度 Progress, a b2 m p0 r0-100 t w%MonitorWorkAreaRight% x0 y0 c11, %ProgressBarSubTextStartFull% (0`%), %ProgressBarMainTextFull%, %ProgressBarTitleFull% ; 顯示套件資訊 MsgBox, 65, %TitleFullPackage%, %MessageFullPackage% IfMsgBox, Cancel { ExitApp } ; 關閉所有執行中的 Opera Progress, 5, %ProgressBarSubTextCloseOpera% (5`%) Process, Exist, opera.exe OperaRunning = %ErrorLevel% if (OperaRunning = 1) { MsgBox, 36, %TitleOperaRunning%, %MessageOperaRunning% IfMsgBox, No { ExitApp } Process, Close, opera.exe } ; 安裝前先檢查是否有殘留先前的 Opera 檔案 Progress, 10, %ProgressBarSubTextBackupOpera% (10`%) ; 從登錄讀取 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 != "") { ; 有安裝過的話就會讀出東西來,接著檢查實際的這個目錄是否存在 IfExist, %OperaInstallPath% { Goto, previousfound } } ; 檢查 Opera 的 APPDATA 路徑是否存在 Progress, 11, %ProgressBarSubTextBackupOpera% (11`%) IfExist, %APPDATA%\Opera { Goto, previousfound } ; 檢查 Opera 的 Local Settings 路徑是否存在 Progress, 12, %ProgressBarSubTextBackupOpera% (12`%) IfExist, %USERPROFILE%\Local Settings\Application Data\Opera { Goto, previousfound } ; 如果通通都沒有,就清掉顯然有誤的登錄資料,然後回到正常的安裝步驟 RegDelete, HKLM, SOFTWARE\Classes\Opera.HTML Goto, installopera previousfound: ; 詢問是否要使用 Stu's Opera Settings Import & Export Tool Progress, 13, %ProgressBarSubTextBackupOpera% (13`%) MsgBox, 36, %TitleInvokeOSIE%, %AskInvokeOSIE% IfMsgBox, Yes { Progress, 14, %ProgressBarSubTextBackupOpera% (14`%) RunWait, osie\osie.exe } ; 詢問是否要移除所有 Opera 留下來的檔案(移到備份目錄去) Progress, 15, %ProgressBarSubTextBackupOpera% (15`%) MsgBox, 36, %TitleDelete%, %AskDeleteInstall% IfMsgBox, No { ExitApp } AskUserOperaInstallPathForBackup: if (OperaInstallPath = "") { ; 如果讀不到路徑,纔詢問使用者 FileSelectFolder, OperaInstallPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 0, %SelectOperaPath% %ProgramFiles%\Opera } if (OperaInstallPath = "") { ; 如果從登錄讀不到路徑,使用者又沒有設定(按了取消),就用預設值 OperaInstallPath = %ProgramFiles%\Opera } ; 如果安裝路徑等於任何系統路徑則要求使用者重選 if OperaInstallPath in %SystemPathCheckList% { MsgBox, 16, %TitleError%, %MessageOperaBackupFromPathError% FileSelectFolder, OperaInstallPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 0, %SelectOperaPath% %ProgramFiles%\Opera Goto, AskUserOperaInstallPathForBackup } Progress, 15, %ProgressBarSubTextBackupOpera% (15`%) ; 取得 Opera 安裝路徑後,接著先建立備份要用到的目錄 %APPDATA%\Opera Nalakuvara Backup\年月日 FileCreateDir, %APPDATA%\Opera Nalakuvara Backup\%A_YYYY%%A_MM%%A_DD% ; 然後把 Opera 安裝路徑整個移到備份目錄 %APPDATA%\Opera Nalakuvara Backup\年月日\ProgramFile FileMoveDir, %OperaInstallPath%, %APPDATA%\Opera Nalakuvara Backup\%A_YYYY%%A_MM%%A_DD%\ProgramFiles, 1 ; 把安裝路徑變數清空 OperaInstallPath = ; 接著把 %APPDATA%\Opera 移到備份目錄 %APPDATA%\Opera Nalakuvara Backup\年月日\AppData FileCreateDir, %APPDATA%\Opera Nalakuvara Backup\%A_YYYY%%A_MM%%A_DD% FileMoveDir, %APPDATA%\Opera, %APPDATA%\Opera Nalakuvara Backup\%A_YYYY%%A_MM%%A_DD%\AppData, 1 ; 最後把 %USERPROFILE%\Local Settings\Application Data\Opera 移到備份目錄 %APPDATA%\Opera Nalakuvara Backup\年月日\LocalSettings FileCreateDir, %APPDATA%\Opera Nalakuvara Backup\%A_YYYY%%A_MM%%A_DD% FileMoveDir, %USERPROFILE%\Local Settings\Application Data\Opera, %APPDATA%\Opera Nalakuvara Backup\%A_YYYY%%A_MM%%A_DD%\LocalSettings, 1 ; 告知備份完成 Progress, 16, %ProgressBarSubTextBackupOpera% (16`%) MsgBox, 64, %TitleDone%, %MessageDeleteDoneInstall% installopera: ; 顯示 EULA GUI 要求使用者同意 Progress, 17, %ProgressBarSubTextEULA% (17`%) #include eula.ahk ; 載入安裝選項 GUI Progress, 18, %ProgressBarSubTextInstallerGUI% (18`%) #include installergui.ahk InstallOperaSelectPath: ; 讓使用者自訂 Opera 安裝路徑 Progress, 20, %ProgressBarSubTextInstallOperaSelectPath% (20`%) if (InstallCustomizeInstallPath = 1) { FileSelectFolder, OperaInstallPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 1, %SelectInstallPath% %ProgramFiles%\Opera } if (OperaInstallPath != "") { ; 如果安裝路徑等於任何系統路徑則要求使用者重選 if OperaInstallPath in %SystemPathCheckList% { MsgBox, 16, %TitleError%, %MessageOperaInstallPathError% Goto, InstallOperaSelectPath } ; 確認一下安裝路徑,若使用者按否則重問一次 MsgBox, 36, %TitleConfirmInstallPath%, %AskConfirmInstallPath% %OperaInstallPath% IfMsgBox, No { Goto, InstallOperaSelectPath } ; 把 Opera 安裝到使用者指定的路徑 Progress, 25, %ProgressBarSubTextInstallOperaMSI% (25`%) RunWait, msiexec /i %OperaInstaller% /qn CREATE_DESKTOP_ICON_REG=%InstallCreateDesktopIcon% CREATE_DESKTOP_ICON_REG_USR=%InstallCreateDesktopIcon% CREATE_QUICKLAUNCH_ICON_REG=%InstallCreateQuicklaunchIcon% CREATE_QUICKLAUNCH_ICON_REG_USR=%InstallCreateQuicklaunchIcon% CREATE_STARTMENU_ICONS=%InstallCreateStartmenuIcons% CREATE_STARTMENU_ICONS_REG_USR=%InstallCreateStartmenuIcons% ISCHECKFORPRODUCTUPDATES=0 ALLUSERS=1 LAUNCH_OPERA_ON_FINISH=0 SET_DEFAULT_BROWSER=%InstallSetDefaultBrowser% INSTALLDIR="%OperaInstallPath%" } if (OperaInstallPath = "") { ; 用預設值安靜安裝 Opera Progress, 25, %ProgressBarSubTextInstallOperaMSI% (25`%) RunWait, msiexec /i %OperaInstaller% /qn CREATE_DESKTOP_ICON_REG=%InstallCreateDesktopIcon% CREATE_DESKTOP_ICON_REG_USR=%InstallCreateDesktopIcon% CREATE_QUICKLAUNCH_ICON_REG=%InstallCreateQuicklaunchIcon% CREATE_QUICKLAUNCH_ICON_REG_USR=%InstallCreateQuicklaunchIcon% CREATE_STARTMENU_ICONS=%InstallCreateStartmenuIcons% CREATE_STARTMENU_ICONS_REG_USR=%InstallCreateStartmenuIcons% ISCHECKFORPRODUCTUPDATES=0 ALLUSERS=1 LAUNCH_OPERA_ON_FINISH=0 SET_DEFAULT_BROWSER=%InstallSetDefaultBrowser% ; 再次從登錄讀取 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 = "") { ; 如果讀不到路徑,就採用預設值 OperaInstallPath = %ProgramFiles%\Opera } } AskUserOperaInstallPath: Progress, 27, %ProgressBarSubTextAskUserOperaInstallPath% (27`%) ; 檢查此路徑下是否真的有 opera.exe 存在,否則就把 OperaInstallPath 變數設回空白,以便詢問使用者 IfNotExist, %OperaInstallPath%\opera.exe { OperaInstallPath = } if (OperaInstallPath = "") { ; 如果讀不到路徑,纔去詢問使用者 FileSelectFolder, OperaInstallPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 0, %SelectOperaPath% %ProgramFiles%\Opera } if (OperaInstallPath = "") { ; 如果從登錄讀不到路徑,使用者又沒有設定(按了取消),就用預設值 OperaInstallPath = %ProgramFiles%\Opera } ; 檢查此路徑下是否真的有 Opera.exe 存在,否則就重新詢問使用者 IfNotExist, %OperaInstallPath%\opera.exe { MsgBox, 16, %TitleError%, %MessageOperaInstalledPathError% Goto, AskUserOperaInstallPath } ; 用正規表示式從 Opera 安裝路徑當中切出最後一段 Progress, 28, %ProgressBarSubTextAskUserOperaInstallPath% (28`%) OperaInstallPathPart := RegExReplace(OperaInstallPath, ".:\\.+\\(.+)$", "$1") if (OperaInstallPathPart = "") { ; 如果切不出來,就用預設值 OperaInstallPathPart = Opera } ; 把預先準備好的檔案複製到 Opera 安裝路徑 Progress, 29, %ProgressBarSubTextCopyFiles% (29`%) FileCopyDir, ProgramFiles\Opera, %OperaInstallPath%, 1 ; 複製 Stu's Opera Settings Import & Export Tool 到 Opera 的安裝路徑內的 osie\ FileCopyDir, osie, %OperaInstallPath%\osie, 1 ; 詢問要使用哪些三太子功能 Progress, 30, %ProgressBarSubTextOptionsGUI% (30`%) #include optionsgui.ahk ; 按照字型設定來複製基礎的 operaprefs.ini Progress, 31, %ProgressBarSubTextApplyOptions% (31`%) if (OptionsFontBaseMingLiUMingLiU = 1) { FileCopyDir, fontbase\MingLiU-MingLiU\ProgramFiles\Opera, %OperaInstallPath%, 1 } Progress, 32, %ProgressBarSubTextApplyOptions% (32`%) if (OptionsFontBaseMingLiUMSJH = 1) { FileCopyDir, fontbase\MingLiU-MSJH\ProgramFiles\Opera, %OperaInstallPath%, 1 } Progress, 33, %ProgressBarSubTextApplyOptions% (33`%) if (OptionsFontBaseMSJHMSJH = 1) { FileCopyDir, fontbase\MSJH-MSJH\ProgramFiles\Opera, %OperaInstallPath%, 1 } Progress, 34, %ProgressBarSubTextApplyOptions% (34`%) if (OptionsFontBaseOperaDefault = 1) { FileCopyDir, fontbase\OperaDefault\ProgramFiles\Opera, %OperaInstallPath%, 1 } ; 修改預設快速鍵 Progress, 35, %ProgressBarSubTextApplyOptions% (35`%) if (OptionsKeyboard = 1) { FileCopyDir, options\keyboard\ProgramFiles\Opera, %OperaInstallPath%, 1 } ; 滑鼠手勢 Progress, 36, %ProgressBarSubTextApplyOptions% (36`%) if (OptionsGestures = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Enable Gesture } ; 超級拖放 Progress, 37, %ProgressBarSubTextApplyOptions% (37`%) if (OptionsDrag = 1) { IniWrite, 255, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Enable Drag } ; 在分頁頁籤雙擊就關閉頁籤 Progress, 38, %ProgressBarSubTextApplyOptions% (38`%) if (OptionsDoubleClickCloseTab = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Doubleclick to Close Tab } ; 不要重新使用目前的頁籤 Progress, 39, %ProgressBarSubTextApplyOptions% (39`%) if (OptionsNewWindow = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, New Window } ; 在背景開新分頁 (10.60 起失效) Progress, 40, %ProgressBarSubTextApplyOptions% (40`%) if (OptionsOpenBackground = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Open New Window in Background } ; 在背景分頁開啟拖曳的鏈結 Progress, 41, %ProgressBarSubTextApplyOptions% (41`%) if (OptionsOpenDragLinkBackground = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Open Dragged Link In Background } ; 顯示面板切換區域 Progress, 42, %ProgressBarSubTextApplyOptions% (42`%) if (OptionsPanelToggle = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Show panel toggle } ; 設定瀏覽列 Progress, 43, %ProgressBarSubTextApplyOptions% (43`%) if (OptionsNavigationBar = 1) { IniWrite, 2, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, NavigationBar Alignment IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, NavigationBar Auto Alignment } ; 不主動載入 Flash Progress, 44, %ProgressBarSubTextApplyOptions% (44`%) if (OptionsEnableOnDemandPlugin = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Enable On Demand Plugin } ; 修正瀏覽網頁時優先使用語系順序 Progress, 45, %ProgressBarSubTextApplyOptions% (45`%) if (OptionsHttpAcceptLanguage = 1) { IniWrite, zh-tw`,en`;q=0.9, %OperaInstallPath%\custom\defaults\operaprefs.ini, Network, HTTP Accept Language } ; 輸入無效網址時自動用 Google 搜尋 Progress, 46, %ProgressBarSubTextApplyOptions% (46`%) if (OptionsAddressBar = 1) { IniWrite, 0, %OperaInstallPath%\custom\defaults\operaprefs.ini, Network, Check Local HostName IniWrite, 0, %OperaInstallPath%\custom\defaults\operaprefs.ini, Network, Enable HostName Expansion IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, Network, Enable HostName Web Lookup IniWrite, http://www.google.com/search?q=`%s&sourceid=opera&num=`%i&ie=utf-8&oe=utf-8, %OperaInstallPath%\custom\defaults\operaprefs.ini, Network, HostName Web Lookup Address } ; 在源料預覽畫面加入 feed: 鏈結 Progress, 47, %ProgressBarSubTextApplyOptions% (47`%) if (OptionsFeedPrevew = 1) { FileCopyDir, options\feedprevew\ProgramFiles\Opera, %OperaInstallPath%, 1 } ; 修改預設網頁郵件服務清單 Progress, 48, %ProgressBarSubTextApplyOptions% (48`%) if (OptionsWebmailServices = 1) { FileCopyDir, options\webmailservices\ProgramFiles\Opera, %OperaInstallPath%, 1 } ; 修改預設書籤 Progress, 49, %ProgressBarSubTextApplyOptions% (49`%) if (OptionsBookmark = 1) { FileCopyDir, options\bookmark\ProgramFiles\Opera, %OperaInstallPath%, 1 } ; 修改預設快速翻頁字串 Progress, 50, %ProgressBarSubTextApplyOptions% (50`%) if (OptionsFastForward = 1) { FileCopyDir, options\fastforward\ProgramFiles\Opera, %OperaInstallPath%, 1 } ; 阻擋 CNNIC 根憑證 Progress, 51, %ProgressBarSubTextApplyOptions% (51`%) if (OptionsCACert = 1) { FileCopyDir, options\cacert\APPDATA\Opera\Opera, %APPDATA%\Opera\%OperaInstallPathPart%, 1 } ; 針對某些網站偽造使用者代理字串 Progress, 52, %ProgressBarSubTextApplyOptions% (52`%) if (OptionsOverride = 1) { FileCopyDir, options\override\APPDATA\Opera\Opera, %APPDATA%\Opera\%OperaInstallPathPart%, 1 } ; 偵測第三方下載管理軟體 Progress, 53, %ProgressBarSubTextApplyOptions% (53`%) if (OptionsDownloadManager = 1) { FileCopyDir, options\downloadmanager\ProgramFiles\Opera, %OperaInstallPath%, 1 IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Show Download Manager Selection Dialog IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Use External Download Manager } ; 詢問是否要安裝各項額外功能 Progress, 60, %ProgressBarSubTextExtensionsGUI% (60`%) #include extensionsgui.ahk ; 啟用使用者 JavaScript 的功能並設定目錄路徑 Progress, 61, %ProgressBarSubTextInstallExtensions% (61`%) enableuserjs: if (InstallExtensions = 1) { if (CustomizeUserJSPath = 1) { ; 詢問使用者 JavaScript 目錄的路徑 FileSelectFolder, UserJSPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 1, %SelectUserJSPath% %OperaInstallPath%\UserJS } if (UserJSPath = "") { ; 如果按了取消,就用預設值 UserJSPath = %OperaInstallPath%\UserJS } ; 檢查指定的使用者 JavaScript 路徑是否安全可用 if UserJSPath in %SystemPathCheckList%,%OperaInstallPath% { UserJSPath = MsgBox, 16, %TitleError%, %MessageUserJSPathError% Goto, enableuserjs } ; 要先把路徑字串轉為 UTF-8 才能寫入 ini Progress, 62, %ProgressBarSubTextInstallExtensions% (62`%) ; 先把目前剪貼簿內的東西另存起來 ClipSaved := ClipboardAll ; 清空剪貼簿 clipboard = ; 把使用者選擇的路徑放進剪貼簿 clipboard = %UserJSPath% ; 稍微等一下,確保資料已經全部放進剪貼簿 ClipWait ; 把剪貼簿的內容轉換成 UTF-8 Transform, UserJSPathUTF8, Unicode ; 把使用者 JavaScript 目錄的路徑寫進自訂的預設 operaprefs.ini,並啟用使用者 JavaScript IniWrite, %UserJSPathUTF8%, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, User JavaScript File IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, User JavaScript IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Always Load User JavaScript ; 把原先另存的剪貼簿內容還原到剪貼簿 clipboard := ClipSaved ; 清掉剪貼簿另存的副本,以節省記憶體 ClipSaved = ; 如果使用者想要在 HTTPS 網頁啟用 UserJS 的話,就在 operaprefs.ini 寫入設定值 Progress, 63, %ProgressBarSubTextInstallExtensions% (63`%) if (EnableUserJSonHTTPS = 1) { IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, User JavaScript on HTTPS } } ; 安裝 AdBlock Plus 功能 Progress, 64, %ProgressBarSubTextInstallExtensions% (64`%) adblockplus: if (InstallAdBlockPlus = 1) { ; 把 AdBlock Plus 用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\adblockplus, %UserJSPath%, 1 Progress, 65, %ProgressBarSubTextInstallExtensions% (65`%) ; 記錄一下「使用者有安裝 AdBlock Plus 功能」,最後要用來處理工具列按鈕 useadblockplus = 1 } ; 安裝 IE Tab 功能 Progress, 66, %ProgressBarSubTextInstallExtensions% (66`%) ietab: if (InstallIETab = 1) { ; 複製外掛模組檔案到預設路徑 FileCopyDir, plugins\ietab, %OperaInstallPath%\program\plugins, 1 Progress, 67, %ProgressBarSubTextInstallExtensions% (67`%) ; 把 IE Tab 用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\ietab, %UserJSPath%, 1 Progress, 68, %ProgressBarSubTextInstallExtensions% (68`%) ; 記錄一下「使用者有安裝 IE Tab 功能」,最後要用來處理工具列按鈕 useietab = 1 ; 修改自動以 IE Tab 開啟的網頁清單 if (TweakIETab = 1) { Progress, 69, %ProgressBarSubTextInstallExtensions% (69`%) RunWait, notepad.exe "%UserJSPath%\Autorender_in_IE.js" } } ; 安裝簡繁轉換功能 Progress, 70, %ProgressBarSubTextInstallExtensions% (70`%) hanconvert: if (InstallHanConvert = 1) { ; 把簡繁轉換會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\hanconvert, %UserJSPath%, 1 Progress, 71, %ProgressBarSubTextInstallExtensions% (71`%) ; 記錄一下「使用者有安裝簡繁轉換功能」,最後要用來處理工具列按鈕 usehanconvert = 1 } ; 安裝 W3C Ruby 支援增強功能 Progress, 72, %ProgressBarSubTextInstallExtensions% (72`%) htmlruby: if (InstallHTMLRuby = 1) { ; 把會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\htmlruby, %UserJSPath%, 1 Progress, 73, %ProgressBarSubTextInstallExtensions% (73`%) ; 修改 HTML Ruby 的設定 if (TweakHTMLRuby = 1) { Progress, 74, %ProgressBarSubTextInstallExtensions% (74`%) RunWait, notepad.exe "%UserJSPath%\ruby_settings.js" } } ; 安裝圖片自動縮小功能 Progress, 75, %ProgressBarSubTextInstallExtensions% (75`%) autosizer: if (InstallAutosizer = 1) { ; 把會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\autosizer, %UserJSPath%, 1 Progress, 76, %ProgressBarSubTextInstallExtensions% (76`%) } ; 安裝長按滑鼠把連結開到背景新分頁功能 Progress, 77, %ProgressBarSubTextInstallExtensions% (77`%) openinbgwithlongpress: if (InstallOpenBGLongPress = 1) { ; 把會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\openinbgwithlongpress, %UserJSPath%, 1 Progress, 78, %ProgressBarSubTextInstallExtensions% (78`%) ; 允許 UserJS 把鏈結開到背景 IniWrite, 1, %OperaInstallPath%\custom\defaults\operaprefs.ini, User Prefs, Allow script to lower window Progress, 79, %ProgressBarSubTextInstallExtensions% (79`%) } ; 安裝文字輸入區域自動備份功能 Progress, 80, %ProgressBarSubTextInstallExtensions% (80`%) textareabackup: if (InstallTextareaBackup = 1) { ; 把會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\textareabackup, %UserJSPath%, 1 Progress, 81, %ProgressBarSubTextInstallExtensions% (81`%) ; 修改備份保留的時間 if (TweakTextareaBackup = 1) { Progress, 82, %ProgressBarSubTextInstallExtensions% (82`%) RunWait, notepad.exe "%UserJSPath%\textareabackup.js" } } ; 安裝自訂 Google 功能 Progress, 83, %ProgressBarSubTextInstallExtensions% (83`%) customizegoogle: if (InstallCustomizeGoogle = 1) { ; 把會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\customizegoogle, %UserJSPath%, 1 Progress, 84, %ProgressBarSubTextInstallExtensions% (84`%) ; 調整各項 Google 自訂值 if (TweakCustomizeGoogle = 1) { Progress, 85, %ProgressBarSubTextInstallExtensions% (85`%) RunWait, notepad.exe "%UserJSPath%\customizegoogle_prefs.js" } } ; 安裝滑鼠軌跡功能 Progress, 86, %ProgressBarSubTextInstallExtensions% (86`%) gesturetrail: if (InstallGestureTrail = 1) { ; 把會用到的 JavaScript 複製到使用者 JavaScript 目錄 FileCopyDir, UserJS\gesturetrail, %UserJSPath%, 1 Progress, 87, %ProgressBarSubTextInstallExtensions% (87`%) } ; 在本地安裝 ZTerm Applet,否則就會採用連到網頁使用的方式 Progress, 88, %ProgressBarSubTextInstallExtensions% (88`%) ztermapplet: if (InstallZTermAppletLocal = 1) { ; 把 ZTermApplet 安裝到 C:\ZTerm if (CustomizeZTermAppletPath = 1) { FileSelectFolder, ZTermLocalPath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 1, %SelectZTermLocalPath% %ZTermLocalPathDefault% } if (ZTermLocalPath = "") { ; 如果按了取消,就用預設值 ZTermLocalPath = %ZTermLocalPathDefault% } ; 檢查指定的使用者 JavaScript 路徑是否安全可用 if ZTermLocalPath in %SystemPathCheckList%,%OperaInstallPath% { ZTermLocalPath = MsgBox, 16, %TitleError%, %MessageZTermLocalPathError% Goto, ztermapplet } ; 要先把路徑字串轉為 UTF-8 才能寫入 ini ClipSaved := ClipboardAll clipboard = clipboard = %ZTermLocalPath% ClipWait Transform, ZTermLocalPathUTF8, Unicode clipboard := ClipSaved ClipSaved = ZTermLocalURI := RegExReplace(ZTermLocalPathUTF8, "\\", "/") ZTermURI = file:///%ZTermLocalURI%/ZTermApplet.html FileCopyDir, ZTerm, %ZTermLocalPath%, 1 IfExist, %ZTermLocalPath%\ZTermApplet.html { FileSetAttrib, -RHS, %ZTermLocalPath%\ZTermApplet.html FileDelete, %ZTermLocalPath%\ZTermApplet.html } FileAppend, `n`n `n ZTerm Applet v%ZTermAppletVersion%`n`n, %ZTermLocalPath%\ZTermApplet.html FileAppend, `n `n

Java Required!

`n

Please download and install Java First!

`n
`n`n, %ZTermLocalPath%\ZTermApplet.html Progress, 89, %ProgressBarSubTextInstallExtensions% (89`%) ; 記錄一下「使用者有在本地安裝 ZTerm Applet」,最後要用來處理工具列按鈕 localztermapplet = 1 } Progress, 90, %ProgressBarSubTextCopyFiles% (90`%) ztermappletrc: ; 複製預先準備好的 .ztermrc FileCopyDir, USERPROFILE, %USERPROFILE%, 1 ; 要先把路徑字串轉為 UTF-8 才能寫入 ini Progress, 91, %ProgressBarSubTextCopyFiles% (91`%) ; 先把目前剪貼簿內的東西另存起來 ClipSaved := ClipboardAll ; 清空剪貼簿 clipboard = ; 把 Opera 安裝路徑放進剪貼簿 clipboard = %OperaInstallPath% ; 稍微等一下,確保資料已經全部放進剪貼簿 ClipWait ; 把剪貼簿的內容轉換成 UTF-8 Transform, OperaInstallPathUTF8, Unicode ; 在 .ztermrc 附加上以 Opera 來開啟鏈結的設定 FileAppend, external-browser-command::"%OperaInstallPathUTF8%\opera.exe" "`%u", %USERPROFILE%\.ztermrc ; 把原先另存的剪貼簿內容還原到剪貼簿 clipboard := ClipSaved ; 清掉剪貼簿另存的副本,以節省記憶體 ClipSaved = Progress, 92, %ProgressBarSubTextCopyFiles% (92`%) ; 以下要複製預先準備好的工具列按鈕檔案。根據使用者的選項,總共會有 8 種組合 ; 所以用目錄名稱來區分這 8 種狀況。目錄名稱是三位二進制的數值: ; 有安裝 AdBlock Plus 就會是 100, ; 有安裝 IE Tab 就會是 010, ; 有安裝簡繁轉換是 001, ; 把三個選項都加起來就會有 000~111 等 8 種。 if (useadblockplus = "") { if (useietab = "") { if (usehanconvert = "") { FileCopyDir, ui\000, %OperaInstallPath%\ui, 1 ButtonCount = 6 } if (usehanconvert != "") { FileCopyDir, ui\001, %OperaInstallPath%\ui, 1 ButtonCount = 8 } } if (useietab != "") { if (usehanconvert = "") { FileCopyDir, ui\010, %OperaInstallPath%\ui, 1 ButtonCount = 8 } if (usehanconvert != "") { FileCopyDir, ui\011, %OperaInstallPath%\ui, 1 ButtonCount = 10 } } } if (useadblockplus != "") { if (useietab = "") { if (usehanconvert = "") { FileCopyDir, ui\100, %OperaInstallPath%\ui, 1 ButtonCount = 11 } if (usehanconvert != "") { FileCopyDir, ui\101, %OperaInstallPath%\ui, 1 ButtonCount = 13 } } if (useietab != "") { if (usehanconvert = "") { FileCopyDir, ui\110, %OperaInstallPath%\ui, 1 ButtonCount = 13 } if (usehanconvert != "") { FileCopyDir, ui\111, %OperaInstallPath%\ui, 1 ButtonCount = 15 } } } ; 處理 ZTerm Applet 的按鈕 Progress, 93, %ProgressBarSubTextCopyFiles% (93`%) FileAppend, Button%ButtonCount%`, `"BBS`"=`"Go to page`, `"%ZTermURI%`"`, `, `"BBS`"`, `"A`"`"`n, %OperaInstallPath%\ui\standard_toolbar.ini ButtonCount := ButtonCount + 1 ; 註冊 feed: 協定 If (InstallRegFeedProtocolApp = 1) { Progress, 94, %ProgressBarSubTextRegFeedProtocolApp% (94`%) MsgBox, 36, %TitleRegFeedProtocolApp%, %AskTitleRegFeedProtocolApp% IfMsgBox, No { MsgBox, 48, %TitleAborted%, %MessageRegFeedProtocalAppAborted% Goto, OpenFeaturePage } Progress, 95, %ProgressBarSubTextRegFeedProtocolApp% (95`%) FileSelectFile, FeedAppPath, 3, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}, %RegFeedProtocolAppTitle%, %RegFeedProtocolAppFileType% If FeedAppPath = { MsgBox, 48, %TitleAborted%, %MessageRegFeedProtocalAppAborted% Goto, OpenFeaturePage } Progress, 96, %ProgressBarSubTextRegFeedProtocolApp% (96`%) RegWrite, REG_SZ, HKEY_CLASSES_ROOT, feed, , URL:feed protocol RegWrite, REG_SZ, HKEY_CLASSES_ROOT, feed, URL Protocol, RegWrite, REG_SZ, HKEY_CLASSES_ROOT, feed\DefaultIcon, ,"%FeedAppPath%" RegWrite, REG_SZ, HKEY_CLASSES_ROOT, feed\shell\open\command, ,"%FeedAppPath%" "`%1" Progress, 97, %ProgressBarSubTextRegFeedProtocolApp% (97`%) MsgBox, 64, %TitleDone%, %MessageRegFeedProtocalAppDone% Goto, OpenFeaturePage } OpenFeaturePage: ; 在桌面建立 Stu's Opera Settings Import & Export Tool 的捷徑 if (InstallCreateDesktopIcon = 1) { Progress, 98, %ProgressBarSubTextFinishedFull% (98`%) FileCreateShortcut, %OperaInstallPath%\osie\osie.exe, %USERPROFILE%\桌面\%ShortcutOSIEFileName%.lnk, %OperaInstallPath%, , %ShortcutOSIEDescription%, %OperaInstallPath%\osie\osie.exe, , 1, 1 FileCreateShortcut, %OperaInstallPath%\osie\osie.exe, %USERPROFILE%\袤醱\%ShortcutOSIEFileName%.lnk, %OperaInstallPath%, , %ShortcutOSIEDescription%, %OperaInstallPath%\osie\osie.exe, , 1, 1 FileCreateShortcut, %OperaInstallPath%\osie\osie.exe, %USERPROFILE%\Desktop\%ShortcutOSIEFileName%.lnk, %OperaInstallPath%, , %ShortcutOSIEDescription%, %OperaInstallPath%\osie\osie.exe, , 1, 1 } ; 安裝完成,開啟 Opera 並連到三太子功能說明網頁 Progress, 99, %ProgressBarSubTextFinishedFull% (99`%) #include domagic.ahk Run, %OperaInstallPath%\opera.exe http://Jedi.org/opera/feature.html ; 離開 AutoHotKey 腳本 Progress, b2 m p100 r0-100 t w%MonitorWorkAreaRight% x0 y0 c11, %ProgressBarSubTextFinishedFull% (100`%), %ProgressBarMainTextFull%, %ProgressBarTitleFull% Sleep, 1000 Progress, Off ExitApp