# Keyboard maestro 当中，如何实现获取当前选中文字？

- Link: https://www.ixiqin.com/2022/10/11/the-rid_device_info_keyboard-maestro-how-to-realize-the-access-to-the-currently-selected-text/
- Published: 2022-10-11T06:00:00+08:00
- Author: 白宦成

在使用 Keyboard maestro 的过程中，可能你需要实现对选中文字进行特定的操作，这个时候
你可以选择配置如下的宏

![](https://files.ixiqin.com/2022/10/23065824/d2b5ca33bd970f64a6301fa75ae2eb22-7-
1024x976.png)

具体实现思路：

 1. 执行 Ctrl + C 执行复制（将选中内容放在剪贴板里）
 2. 执行 Delete 执行删除（将选中内容删除）
 3. 插入新的文本（并将系统剪贴板的内容作为变量放在里面）。

在[论坛](https://forum.keyboardmaestro.com/t/how-to-set-variable-to-currently-selected-text-on-mac/1958)
当中还看到另外一个解法，感兴趣的可以试试看

![](https://files.ixiqin.com/2022/10/23065824/d2b5ca33bd970f64a6301fa75ae2eb22-8.
png)
