制作Windows热键最简单的方法是什么? [英] What's the easiest way to make a hotkey for windows?

查看:68
本文介绍了制作Windows热键最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,按 Ctrl + V ,然后将缓冲区内容插入到窗口中.我该如何创建自己的热键?对不起,这个问题很抱歉.

For example , you push Ctrl+V and insert the buffer content into the window. How can I create my own hotkeys like that? Sorry for noobish question.

推荐答案

一种快速而轻松地执行此操作的好方法是使用专注于宏编程的脚本语言.我最喜欢的是 AutoIt ,正如它在AutoIt帮助文件的片段中所说的那样.

A great way to do this quickly and easily is with a script language that focuses on macro programming. My favorite is AutoIt as it says in a clip from the AutoIt help file...

AutoIt最初是为PC设计的 推出"情况以可靠地 自动化和配置成千上万 件.随着时间的流逝,它已成为 支持的强大语言 复杂的表达式,用户功能, 循环和其他所有老手 脚本作者会期望的.

AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.

在AutoIt中编写热键应用程序再简单不过了.例如,让我们说(出于某种原因)(不便提及),您可能希望 Alt + Q 在特定情况下作为数字键盘按键7做出反应,因此您不必必须跨键盘才能做到这一点.这是执行此操作的一些代码...

Writing a hotkey application in AutoIt couldn't be easier. For example lets say for some reason (to obscure to mention) you would like Alt+Q to react as number pad key 7 in a particular situation possibly so you don't have to reach across the keyboard for it. Here's some code that does that...

Func _num7()
    Send("{numpad7}")
EndFunc

HotKeySet("!{q}","_num7")

While 1
    sleep(10)
WEnd

如果这还不够直接,AutoIt帮助文件和论坛非常有帮助.如果您遇到任何有关AutoIt的特定问题,更不用说有很少的AutoIt开发人员可用了.

If that's not straight forward enough the AutoIt help file and forums are very helpful. Not to mention a (very) few AutoIt developers are available on SO if you end up with any AutoIt specific questions.

在上面的示例中,您只希望在使用特定应用程序时激活热键,以免干扰其他热键.这段代码就可以做到这一点.

In the example above lets say you only wanted the hotkeys to be active when a particular application was in use so as to not interfere with other hotkeys. This code would accomplish just that.

; The comment character in AutoIt is ;
Local $inTargetProg = False

Func _num7()
    Send("{numpad7}")
EndFunc

While 1
    If WinActive("Target Application Window Title") and Not $inTargetProg Then
        HotKeySet("!{q}","_num7") ; binds Alt+Q to the _num7() function
        $inWC3 = True
    EndIf

    If Not WinActive("Target Application Window Title") and $inTargetProg Then
        HotKeySet("!{q}") ; UnBind the hotkey when not in use
        $inWC3 = False
    EndIf

    sleep(5)
WEnd

这篇关于制作Windows热键最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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