我正在尝试使用hammpersppon中的lua创建脚本。在这里按“ x”将为用户提供将他们想要粘贴的模板类型粘贴到Web文本字段中的选项。
不幸的是,我无法弄清楚如何将文本格式化为表格(带有行和列)?
我尝试将Google表格(excel)中的表格粘贴到lua代码中,但是仍然无法在文本字段中将其呈现为表格。
-- Focus the last used window.
local function focusLastFocused()
local wf = hs.window.filter
local lastFocused = wf.defaultCurrentSpace:getWindows(wf.sortByFocusedLast)
if #lastFocused > 0 then lastFocused[1]:focus() end
end
-- On selection, copy the text and type it into the focused application.
local chooser = hs.chooser.new(function(choice)
if not choice then focusLastFocused(); return end
hs.pasteboard.setContents(choice["subText"])
focusLastFocused()
hs.eventtap.keyStrokes(hs.pasteboard.getContents())
end)
chooser:choices({
{
["text"] = "Option 1",
["subText"] = [[ Text 1 Text 2
Text 3 Text 4]]
},
{
["text"] = "Option 2",
["subText"] = [[ Text 1 Text 2
Text 3 Text 4]]
},
})
hs.hotkey.bind({"X"}, "X", function() chooser:show() end)