The macro seems to work well, but can anybody suggest some improvements?
Code: Select all
local function GetSearchString()
mf.clip(5,2)
Keys('CtrlIns') -- content of inputbox to clipboard
local s=mf.clip(0) -- load string from clipboard
if s==0 then s="" end
return s
end;
Macro {
key="CtrlShiftF7";
area="Shell";
description="Substring search **.*";
action=function()
Keys('AltF7')
local s=GetSearchString()
if s=='*.*' then -- if default value, replace it with **.* and set cursor to the second position
Keys('Multiply Multiply . Multiply Home Right') return
end
if s:find('*') then -- is * in inptutbox?
local b=mf.index(s,'*')+1 -- find the first *
s=mf.substr(s,b) -- position of * in inptubox
if not s:find('*') then return end -- is the second *?
local e=mf.index(s,'*')+b-1 -- find the second *
Keys'Home' -- select all between **
for i=1,b do Keys('Right') end
for i=1,e do Keys('ShiftRight') end
end
end;
}