忽略掉我包装的异步 curl 库,代码只用了几十行,编辑控件使用了 MsFtEdit。
fanyi(st) {
#DllLoad "MsFtEdit.dll"
ui := Gui("+AlwaysOnTop -Caption -DPIScale")
ui.BackColor := "0x52718B"
ui.title := st := Trim(st, "`r`t`n ")
ui.MarginY := ui.MarginX := sz := 7
w := A_ScreenWidth * 10 // 40, h := A_ScreenHeight * 10 // 16, h4 := (h // 5)
ui.li := [ft_st := ui.Add("Custom", opt := "ClassRICHEDIT50W 0x0004 0x1000 0X0040 0x200000 w" (w - sz * 2) " h" (h4 - sz)),
ft_gg := ui.Add("Custom", opt),
ft_de := ui.Add("Custom", opt),
ft_bi := ui.Add("Custom", opt),
ft_sg := ui.Add("Custom", opt)]
DllCall("SendMessage", "ptr", ft_st.hwnd, "uint", 0x0461, "uint64*", 8 | 4, "str", st)
ui.show('w' w ' h' (h + sz) ' x' (A_ScreenWidth - w + sz - 2) ' y' ((A_ScreenHeight - (h + sz)) // 2))
ui.OnEvent "Close", fanyi_close
ui.OnEvent "Size", fanyi_size.bind(sz)
curl { mode: "task", task:[* get_methodologies *]}
}
fanyi_size(sz, ui, t, w, h) {
h4 := ((h - sz) // 5)
for n in ui.li
n.Move(sz, sz + (h4 * (A_Index - 1)), w - sz * 2, h4 - sz)
}
fanyi_close(ui) {
ui.Destroy()
ExitApp()
}
丑是丑了点,但总得来说,AutoHotkey 撸工具还是蛮方便的。