我如何模仿 Visual Studio 的“Ctrl-K,C"?使用 Autoit/Autohotkey 的两步宏行为? [英] How can I mimic Visual Studio's "Ctrl-K, C" two-step macro behaviour using Autoit / Autohotkey?

查看:30
本文介绍了我如何模仿 Visual Studio 的“Ctrl-K,C"?使用 Autoit/Autohotkey 的两步宏行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为一些常见任务设置 AutoHotkey 宏,我希望热键能够模仿 Visual Studio 的两步快捷方式"行为——即按下 Ctrl-K 将启用宏模式";在宏模式下,按某些键将运行宏然后禁用宏模式",任何其他键只会禁用宏模式.

I'm trying to set up AutoHotkey macros for some common tasks, and I want the hotkeys to mimic Visual Studio's "two-step shortcut" behaviour - i.e. pressing Ctrl-K will enable "macro mode"; within macro mode, pressing certain keys will run a macro and then disable 'macro mode', and any other key will just disable macro mode.

示例 - 在输入文件名时,我希望能够通过点击 Ctrl-K,然后按 D 来插入今天的日期.

Example - when typing a filename, I want to be able to insert today's date by tapping Ctrl-K, then pressing D.

有没有人有一个像这样行为的有状态 AutoHotkey 脚本的好例子?

Does anyone have a good example of a stateful AutoHotkey script that behaves like this?

推荐答案

这个 Autohotkey 脚本,当你按下 ctrl+k 时,会等待你按下一个键如果你按d,它会输入当前日期.

This Autohotkey script, when you press ctrl+k, will wait for you to press a key and if you press d, it will input the current date.

^k::
Input Key, L1
FormatTime, Time, , yyyy-MM-dd
if Key = d
    Send %Time%
return

这篇关于我如何模仿 Visual Studio 的“Ctrl-K,C"?使用 Autoit/Autohotkey 的两步宏行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆