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.
例如,按Ctrl + V并将缓冲区内容插入窗口。我怎样才能创建自己的热键呢?抱歉,这是一个非常棒的问题。
7 个解决方案
#1
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,因为它在AutoIt帮助文件的剪辑中说...
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最初是为PC“推出”情况而设计的,可以可靠地自动化和配置数千台PC。随着时间的推移,它已成为一种强大的语言,支持复杂的表达式,用户函数,循环以及资深脚本编写者期望的所有其他内容。
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...
在AutoIt中编写热键应用程序非常简单。例如,让我们说出于某种原因(模糊地提到),你希望Alt + Q在特定情况下作为数字键盘7做出反应,这样你就不必跨越键盘了。这里有一些代码可以做到......
Func _num7()
Send("{numpad7}")
EndFunc
HotKeySet("!{q}","_num7")
While 1
sleep(10)
WEnd
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.
如果这不够直接,AutoIt帮助文件和论坛非常有帮助。更不用说(很少)AutoIt开发人员可以在SO上找到,如果你最终得到任何AutoIt特定问题。
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
#2
Per-process keyboard shortcuts like Ctrl+V are usually defined in a resource (.rc) file and loaded via the Win32 API LoadAccelerators.
像Ctrl + V这样的每进程键盘快捷键通常在资源(.rc)文件中定义,并通过Win32 API LoadAccelerators加载。
Windows-wide keyboard shortcuts (hotkeys) are registered using the Win32 API RegisterHotKey.
使用Win32 API RegisterHotKey注册Windows范围的键盘快捷键(热键)。
#3
I've been using AutoHotkey at work for the best part of a year now.
我一直在使用AutoHotkey工作一年中最好的部分。
I just save the following file in my Windows Startup folder.
我只是将以下文件保存在Windows Startup文件夹中。
keyboard_shortcuts.ahk
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, Icon, Shell32.dll, 44
; Starting Directory for cmd.exe
EnvGet, HOMEDRIVE, HOMEDRIVE
EnvGet, HOMEPATH, HOMEPATH
#i:: Run, notepad
#f:: Run, firefox
#c:: Run, cmd /k, %HOMEDRIVE%%HOMEPATH%
#m:: Run, mailto:
#b:: Run, mailto:boss@mycompany.com
"#b" means Winkey+B
“#b”表示Winkey + B.
"Run, mailto:boss@mycompany.com" open a black email to my boss.
“Run,mailto:boss@mycompany.com”向我的老板发了一封黑色电子邮件。
#b:: Run, mailto:boss@mycompany.com
#4
You can create a simple hotkey in Windows by creating a shortcut and then assign a shortcut key to it. I have done this for launching some command line apps with parameters. The following link explains using a shortcut key to an app to mute the volume:Mute
您可以通过创建快捷方式在Windows中创建一个简单的热键,然后为其分配快捷键。我这样做是为了启动一些带参数的命令行应用程序。以下链接说明了使用应用程序的快捷键来静音音量:静音
Just replace the Target: and Shortcut Key: in the shortcut properties with whatever you need for your purposes.
只需将快捷方式属性中的目标:和快捷键替换为您的目的所需的任何内容。
#5
Simple script with windows with no third party software required.Just save as .vbs file and double click
带有Windows的简单脚本,不需要第三方软件。只需保存为.vbs文件并双击
currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
Set objShell = WScript.CreateObject("WScript.Shell")
Set lnk = objShell.CreateShortcut(currentDirectory & "search.LNK")
lnk.TargetPath = currentDirectory & "search.bat"
lnk.Arguments = ""
lnk.Description = "Abiram's search"
lnk.HotKey = "SHIFT+CTRL+C"
lnk.WindowStyle = "7"
lnk.WorkingDirectory = currentDirectory
lnk.Save
'Clean up
Set lnk = Nothing
Change the lnk.TargetPath to include your exe file or batch file to be called.
更改lnk.TargetPath以包含要调用的exe文件或批处理文件。
#6
Ok...the easiest way, for example On you desktop, you can use accelerated command by right click the icon > properties > shortcut key; Click on the empty space and it will seem like nothing happens, but this is when you assign your "hotkey" I used Shift+1 and whenever I combine Shift+1 Firefox opens.
好的......最简单的方法,例如在桌面上,您可以通过右键单击图标>属性>快捷键来使用加速命令;单击空白区域似乎没有任何反应,但这是当你分配你的“热键”我使用Shift + 1时,每当我组合Shift + 1 Firefox打开。
#7
First, welcome to Stack Overflow!
首先,欢迎来到Stack Overflow!
Second, this is a program by program thing. The only reason that Ctrl+C or Ctrl+V works across different programs is because there is operating system support for the clipboard and many programs follow the convention of using Ctrl+C or Ctrl+V. In your own programs, you can bind the keys however you like! For more details, we'll need more information about your program.
其次,这是一个程序式的程序。 Ctrl + C或Ctrl + V在不同程序中工作的唯一原因是因为操作系统支持剪贴板,许多程序遵循使用Ctrl + C或Ctrl + V的惯例。在您自己的程序中,您可以随意绑定键!有关详细信息,我们需要有关您的计划的更多信息。
If you want to make actual hotkeys for Windows itself, I'm not sure how (nor if you are able) to make your own hotkeys. You might want to look into AutoIt, which is a free program that can do all sorts of things you might want to use a hotkey for, such as automatically clicking through menus, etc.
如果你想为Windows本身制作实际的热键,我不确定如何(也不是你能够)制作自己的热键。您可能想要查看AutoIt,这是一个免费程序,可以执行您可能想要使用热键的各种事情,例如自动点击菜单等。
#1
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,因为它在AutoIt帮助文件的剪辑中说...
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最初是为PC“推出”情况而设计的,可以可靠地自动化和配置数千台PC。随着时间的推移,它已成为一种强大的语言,支持复杂的表达式,用户函数,循环以及资深脚本编写者期望的所有其他内容。
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...
在AutoIt中编写热键应用程序非常简单。例如,让我们说出于某种原因(模糊地提到),你希望Alt + Q在特定情况下作为数字键盘7做出反应,这样你就不必跨越键盘了。这里有一些代码可以做到......
Func _num7()
Send("{numpad7}")
EndFunc
HotKeySet("!{q}","_num7")
While 1
sleep(10)
WEnd
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.
如果这不够直接,AutoIt帮助文件和论坛非常有帮助。更不用说(很少)AutoIt开发人员可以在SO上找到,如果你最终得到任何AutoIt特定问题。
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
#2
Per-process keyboard shortcuts like Ctrl+V are usually defined in a resource (.rc) file and loaded via the Win32 API LoadAccelerators.
像Ctrl + V这样的每进程键盘快捷键通常在资源(.rc)文件中定义,并通过Win32 API LoadAccelerators加载。
Windows-wide keyboard shortcuts (hotkeys) are registered using the Win32 API RegisterHotKey.
使用Win32 API RegisterHotKey注册Windows范围的键盘快捷键(热键)。
#3
I've been using AutoHotkey at work for the best part of a year now.
我一直在使用AutoHotkey工作一年中最好的部分。
I just save the following file in my Windows Startup folder.
我只是将以下文件保存在Windows Startup文件夹中。
keyboard_shortcuts.ahk
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, Icon, Shell32.dll, 44
; Starting Directory for cmd.exe
EnvGet, HOMEDRIVE, HOMEDRIVE
EnvGet, HOMEPATH, HOMEPATH
#i:: Run, notepad
#f:: Run, firefox
#c:: Run, cmd /k, %HOMEDRIVE%%HOMEPATH%
#m:: Run, mailto:
#b:: Run, mailto:boss@mycompany.com
"#b" means Winkey+B
“#b”表示Winkey + B.
"Run, mailto:boss@mycompany.com" open a black email to my boss.
“Run,mailto:boss@mycompany.com”向我的老板发了一封黑色电子邮件。
#b:: Run, mailto:boss@mycompany.com
#4
You can create a simple hotkey in Windows by creating a shortcut and then assign a shortcut key to it. I have done this for launching some command line apps with parameters. The following link explains using a shortcut key to an app to mute the volume:Mute
您可以通过创建快捷方式在Windows中创建一个简单的热键,然后为其分配快捷键。我这样做是为了启动一些带参数的命令行应用程序。以下链接说明了使用应用程序的快捷键来静音音量:静音
Just replace the Target: and Shortcut Key: in the shortcut properties with whatever you need for your purposes.
只需将快捷方式属性中的目标:和快捷键替换为您的目的所需的任何内容。
#5
Simple script with windows with no third party software required.Just save as .vbs file and double click
带有Windows的简单脚本,不需要第三方软件。只需保存为.vbs文件并双击
currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
Set objShell = WScript.CreateObject("WScript.Shell")
Set lnk = objShell.CreateShortcut(currentDirectory & "search.LNK")
lnk.TargetPath = currentDirectory & "search.bat"
lnk.Arguments = ""
lnk.Description = "Abiram's search"
lnk.HotKey = "SHIFT+CTRL+C"
lnk.WindowStyle = "7"
lnk.WorkingDirectory = currentDirectory
lnk.Save
'Clean up
Set lnk = Nothing
Change the lnk.TargetPath to include your exe file or batch file to be called.
更改lnk.TargetPath以包含要调用的exe文件或批处理文件。
#6
Ok...the easiest way, for example On you desktop, you can use accelerated command by right click the icon > properties > shortcut key; Click on the empty space and it will seem like nothing happens, but this is when you assign your "hotkey" I used Shift+1 and whenever I combine Shift+1 Firefox opens.
好的......最简单的方法,例如在桌面上,您可以通过右键单击图标>属性>快捷键来使用加速命令;单击空白区域似乎没有任何反应,但这是当你分配你的“热键”我使用Shift + 1时,每当我组合Shift + 1 Firefox打开。
#7
First, welcome to Stack Overflow!
首先,欢迎来到Stack Overflow!
Second, this is a program by program thing. The only reason that Ctrl+C or Ctrl+V works across different programs is because there is operating system support for the clipboard and many programs follow the convention of using Ctrl+C or Ctrl+V. In your own programs, you can bind the keys however you like! For more details, we'll need more information about your program.
其次,这是一个程序式的程序。 Ctrl + C或Ctrl + V在不同程序中工作的唯一原因是因为操作系统支持剪贴板,许多程序遵循使用Ctrl + C或Ctrl + V的惯例。在您自己的程序中,您可以随意绑定键!有关详细信息,我们需要有关您的计划的更多信息。
If you want to make actual hotkeys for Windows itself, I'm not sure how (nor if you are able) to make your own hotkeys. You might want to look into AutoIt, which is a free program that can do all sorts of things you might want to use a hotkey for, such as automatically clicking through menus, etc.
如果你想为Windows本身制作实际的热键,我不确定如何(也不是你能够)制作自己的热键。您可能想要查看AutoIt,这是一个免费程序,可以执行您可能想要使用热键的各种事情,例如自动点击菜单等。