|
3 | 3 |
|
4 | 4 | CommandPost allows you to create Lua code snippets, which appear as actions in CommandPost's Search Console.
|
5 | 5 |
|
6 |
| -This means you can trigger a snippet via a shortcut key or control surface button. |
| 6 | +This means you can trigger a Snippet via a shortcut key or control surface button. |
7 | 7 |
|
8 | 8 | For example, to launch Final Cut Pro, you can use this simple Lua code:
|
9 | 9 |
|
10 | 10 | `cp.apple.finalcutpro:launch()`
|
11 | 11 |
|
12 | 12 | CommandPost is also compatible with Hammerspoon, so you can also use any of the examples on the Hammerspoon website:
|
13 | 13 |
|
14 |
| -http://www.hammerspoon.org/go/ |
| 14 | +[http://www.hammerspoon.org/go/](http://www.hammerspoon.org/go/) |
15 | 15 |
|
16 | 16 | You can learn more about Lua here:
|
17 | 17 |
|
18 |
| -https://dev.commandpost.io/lua/lua-overview |
| 18 | +[https://dev.commandpost.io/lua/lua-overview](https://dev.commandpost.io/lua/lua-overview) |
19 | 19 |
|
20 | 20 | Here's a link to Hammerspoon's API reference:
|
21 | 21 |
|
22 |
| -http://www.hammerspoon.org/docs/index.html |
| 22 | +[http://www.hammerspoon.org/docs/index.html](http://www.hammerspoon.org/docs/index.html) |
23 | 23 |
|
24 | 24 | Here's some direct links to some useful Hammerspoon functions:
|
25 | 25 |
|
26 | 26 | - [`hs.timer.usleep(microsecs)`](http://www.hammerspoon.org/docs/hs.timer.html#usleep) - Add a delay
|
27 | 27 | - [`hs.eventtap.keyStroke(modifiers, character[, delay, application])`](http://www.hammerspoon.org/docs/hs.eventtap.html#keyStroke) - Trigger a virtual key stroke
|
28 | 28 | - [`hs.application:selectMenuItem(menuitem[, isRegex])`](http://www.hammerspoon.org/docs/hs.application.html#selectMenuItem) - Trigger an application menu item
|
29 | 29 |
|
| 30 | +Here's some direct links to some useful CommandPost functions: |
| 31 | + |
| 32 | +- [`cp.tools`](https://dev.commandpost.io/commandpost-api/cp.tools) |
| 33 | + |
30 | 34 | ---
|
31 | 35 |
|
32 | 36 | # Examples
|
33 | 37 |
|
| 38 | +## Press "CMD+C" |
| 39 | + |
| 40 | +```lua |
| 41 | +hs.eventtap.keyStroke({"cmd"}, "c") |
| 42 | +``` |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Type "test" |
| 47 | + |
| 48 | +```lua |
| 49 | +hs.eventtap.keyStrokes("test") |
| 50 | +``` |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Trigger Shortcuts with Delay's in-between |
| 55 | + |
| 56 | +```lua |
| 57 | +-- Type "t" |
| 58 | +hs.eventtap.keyStroke({}, "t") |
| 59 | + |
| 60 | +-- Wait 1 second |
| 61 | +cp.just.wait(1) |
| 62 | + |
| 63 | +-- Type "e" |
| 64 | +hs.eventtap.keyStroke({}, "e") |
| 65 | +``` |
| 66 | + |
| 67 | +--- |
| 68 | + |
34 | 69 | ## Forcefully restart an application by its bundle identifier
|
35 | 70 |
|
36 | 71 | ```lua
|
|
0 commit comments