[英]How can I configure Eclipse to that it saves all opened documents whenever the Eclipse window loses focus?
我如何配置 Eclipse 使其在 Eclipse window 失去焦點時保存所有打開的文檔? 我在 Microsoft Windows 7 和 10 上運行 Eclipse。
(動機:我在Eclipse上打碼,然后點擊其他window來測試代碼)
我寫了這個AutoHotkey腳本作為解決方法。 它在失去焦點時將 Ctrl+Shift+S 發送到 Eclipse window。
#SingleInstance force
#NoTrayIcon
Process, Priority, , High
CoordMode, ToolTip, Screen
onFocusChanged(wParam, lParam) {
local newWindowId, newWindowClass, newProcess
winGet newWindowId, ID, A
if (newWindowId == prevWindowId) {
return
}
winGetClass newWindowClass, A
winGet newProcess, ProcessName, A
;outputDebug focus to: %newWindowId% / %newWindowClass% / %newProcess%
if (pendingTooltipText != "" && prevWindowClass == "MultitaskingViewFrame") { ; Alt+Tab "dialog" done
;outputDebug, Alt+Tab done, pending tooltip: %pendingTooltipText%
ToolTip, %pendingTooltipText%, 200, 50
pendingTooltipText := ""
SetTimer, tooltipOff, -1500
ControlSend, , ^+s, ahk_id %prevEclipseWindowId%
} else if (prevProcess == "eclipse.exe" && prevWindowClass == "SWT_Window0") {
;outputDebug Eclipse lost focus.
local tooltipText := A_ScriptName . ": Ctrl+Shift+S in Eclipse"
if (newWindowClass == "MultitaskingViewFrame") { ; Alt+Tab "dialog" gets focus
prevEclipseWindowId := prevWindowId
pendingTooltipText := tooltipText
;outputDebug, in Alt+Tab, delaying tooltip: %pendingTooltipText%
} else {
ToolTip, %tooltipText%, 200, 50
SetTimer, tooltipOff, -1500
ControlSend, , ^+s, ahk_id %prevWindowId%
}
}
prevWindowId := newWindowId
prevWindowClass := newWindowClass
prevProcess := newProcess
}
onShellHook(wParam, lParam) {
if (wParam == 4 || wParam == 32772) { ;HSHELL_WINDOWACTIVATED || HSHELL_RUDEAPPACTIVATED
onFocusChanged(wParam, lParam)
}
}
;;outputDebug %A_ScriptName% starting
; detect focus: https://autohotkey.com/board/topic/66726-method-to-detect-active-window-change/
Gui +LastFound
DllCall("RegisterShellHookWindow", UInt, WinExist())
winGet prevWindowId, ID, A
winGetClass prevWindowClass, A
winGet prevProcess, ProcessName, A
;outputDebug initial: %prevWindowId% / %prevWindowClass% / %prevProcess%
prevEclipseWindowId := ""
pendingTooltipText := ""
OnMessage(DllCall("RegisterWindowMessage", Str, "SHELLHOOK"), "onShellHook")
tooltipOff:
ToolTip
return
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.