I think I was trying to make it more complicated than necessary in order to
avoid running it when it wasn't in the right context. Improving slightly on
Bruce's version, here's one that can be assigned to an F2 hotkey targeting
filedialog,=explorer and that does the wanted three-way toggle:
local hwnd=win.getfocus
if (win.class(hwnd)!=="edit") do
win.sendkeys("{sinp}{F2}")
hwnd=win.getfocus
if (win.class(hwnd)!=="edit")
quit
endif
static lasthwnd
static toggle
if (not hwnd)
quit
local text=win.gettext(hwnd)
local EM_SETSEL=0x00B1
local dot=revfind(text, ".")
if (dot>=1) do
if (lasthwnd==hwnd) do
toggle = toggle + 1
else
toggle = 0
endif
if (toggle == 3)
toggle = 0
if (toggle == 0) do
win.sendmessage(hwnd, EM_SETSEL, 0, dot)
elseif (toggle == 1)
win.sendmessage(hwnd, EM_SETSEL, dot+1, -1)
elseif (toggle == 2)
win.sendmessage(hwnd, EM_SETSEL, 0, -1)
endif
else
win.sendmessage(hwnd, EM_SETSEL, 0, -1)
endif
lasthwnd=hwnd