#Requires AutoHotkey v2.0 #SingleInstance Force ; EasyFarmToggle v2.2.0 ; EasyFarm を全窓まとめて ON/OFF し、最後に元の FF11 窓へフォーカスを戻す版 SetTitleMatchMode 2 GetActiveFFXIWindow() { activeId := WinGetID("A") if !activeId return 0 try proc := WinGetProcessName("ahk_id " activeId) catch proc := "" try cls := WinGetClass("ahk_id " activeId) catch cls := "" if (proc = "pol.exe" || cls = "FFXiMainClass" || cls = "FFXiClass") return activeId return 0 } GetAnyFFXIWindow() { for pattern in ["ahk_class FFXiMainClass", "ahk_class FFXiClass", "ahk_exe pol.exe"] { try ids := WinGetList(pattern) catch ids := [] if (ids.Length > 0) return ids[1] } return 0 } RestoreFFXIFocus(targetId := 0) { if (targetId) { try { if WinExist("ahk_id " targetId) { WinActivate "ahk_id " targetId WinWaitActive "ahk_id " targetId,, 1 return true } } } fallbackId := GetAnyFFXIWindow() if (fallbackId) { try { WinActivate "ahk_id " fallbackId WinWaitActive "ahk_id " fallbackId,, 1 return true } } return false } EF_ToggleAll() { originalFFXI := GetActiveFFXIWindow() try idList := WinGetList("EasyFarm") catch idList := [] if (idList.Length = 0) { RestoreFFXIFocus(originalFFXI) return } for thisId in idList { try { if !WinExist("ahk_id " thisId) continue WinActivate "ahk_id " thisId WinWaitActive "ahk_id " thisId,, 1 Sleep 120 Send "!f" Sleep 100 Send "{Down}" Sleep 100 Send "{Enter}" Sleep 140 } catch { } } Sleep 120 RestoreFFXIFocus(originalFFXI) } EF_ToggleAll() ExitApp