aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2019-08-12 22:00:10 +0200
committerTeddy Wing2019-08-12 22:00:10 +0200
commit226b08165986920ecd30fbe1776009396e114ba1 (patch)
treefc357a7a6f46e74d7a08de5759cf32692d7fa33f
parentfe8abdbb5e3a51bb17e6364df706851015081913 (diff)
downloaddothammerspoon-226b08165986920ecd30fbe1776009396e114ba1.tar.bz2
ufo: Add a mode binding to edit, save, and close a text file
-rw-r--r--ufo.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/ufo.lua b/ufo.lua
index c374a65..3713514 100644
--- a/ufo.lua
+++ b/ufo.lua
@@ -18,3 +18,18 @@ ufo_mode:bind({}, 'r', function()
ufo_mode:exit()
end)
+
+-- Edit, close, and save an MS Word document
+ufo_mode:bind({}, 'w', function()
+ math.randomseed(os.time())
+ local number = math.random(0, 9)
+
+ hs.eventtap.keyStroke({}, 'forwarddelete')
+ hs.eventtap.keyStroke({}, tostring(number))
+ hs.eventtap.keyStroke({'command'}, 'w')
+ hs.timer.doAfter(0.05, function()
+ hs.eventtap.keyStroke({}, 'return')
+ end)
+
+ ufo_mode:exit()
+end)