NirCmd-sendkey&sendkeypress

引入script [Script File]

复制代码
This command allows you to execute a sequence of commands stored inside the file specified in [Script File] parameter.
Example:
script "c:\temp\msg.ncl"
Example for a script:

infobox "Hello !" "This is the first message"
infobox "Hello !" "This is the second message"
infobox "Hello !" "This is the third message"

使用该命令可以进行批处理(.txt,.bat,.ncl...)

bash 复制代码
nircmd script example.txt

sendkey [Key] [press | down | up]

NirCmd Command Reference - sendkey (nirsoft.net)http://nircmd.nirsoft.net/sendkey.html

bash 复制代码
​
Sends a keystroke to the system. The operating system will behave exactly as the user really pressed the specified keys.
The [Key] parameter specifies the key as virtual key code (For example: 0x2e for Delete key), or as one of the following predefined values:

a - z and 0 - 9 (for alphanumeric keys), F1 - F24 (for Fxx keys), shift, ctrl, alt, enter, esc ,leftshift, rightshift, leftctrl, rightctrl, leftmenu, rightmenu, spc (space), down, up, left, right, home, end, insert, delete, plus, comma, minus, period, lwin, rwin (Windows key), apps, pageup, pagedown, tab, multiply, add, subtract, seperator, divide, backspace, pause, capslock, numlock, scroll, printscreen.
The second parameter specifies the key action: 'press', 'down', or 'up'. For each key down action, you should also add the appropriate key up action.

In the following script example, the system behaves like the user presses Shift+Ctrl+Esc (the task manager should appear):
sendkey shift down
sendkey ctrl down
sendkey esc down
sendkey shift up
sendkey ctrl up
sendkey esc up

More examples:
sendkey a press
sendkey f10 press
sendkey enter press
sendkey 0x2e press

​

向系统发送一个按键操作。操作系统将完全模拟用户实际按下指定键的行为。

Key\] 参数指定了按键,可以使用虚拟键码(例如:0x2e 代表 Delete 键),或者使用以下预定义值之一:a - z 和 0 - 9(字母数字键)、F1 - F24(功能键)、shift、ctrl、alt、enter、esc、leftshift、rightshift、leftctrl、rightctrl、leftmenu、rightmenu、spc(空格)、down、up、left、right、home、end、insert、delete、plus、comma、minus、period、lwin、rwin(Windows 键)、apps、pageup、pagedown、tab、multiply、add、subtract、separator、divide、backspace、pause、capslock、numlock、scroll、printscreen。 第二个参数指定了按键动作:'press'、'down' 或 'up'。对于每个按下动作,你也应该添加相应的释放动作。 在下面的脚本示例(example.txt)中,系统表现得就像用户按下了 Shift+Ctrl+Esc(任务管理器应该出现): ```bash nircmd script example.txt ``` sendkey shift down sendkey ctrl down sendkey esc down sendkey shift up sendkey ctrl up sendkey esc up ![](https://i-blog.csdnimg.cn/direct/94e820f760404e828105c40a86273c76.gif) 能检测到虚拟按键 更多示例: ```bash sendkey a press sendkey f10 press sendkey enter press sendkey 0x2e press ``` ![](https://i-blog.csdnimg.cn/direct/5618e50d1955405a8533cc92e8d2d533.gif) 这些示例展示了如何使用`sendkey`命令模拟按键操作,可以用于自动化键盘输入任务。 ## sendkeypress \[Keys Combination 1\] \[Keys Combination 2\] \[Keys Combination 3\] ... [NirCmd Command Reference - sendkeypress (nirsoft.net)![icon-default.png?t=O83A](https://csdnimg.cn/release/blog_editor_html/release2.3.7/ckeditor/plugins/CsdnLink/icons/icon-default.png)http://nircmd.nirsoft.net/sendkeypress.html](http://nircmd.nirsoft.net/sendkeypress.html "NirCmd Command Reference - sendkeypress (nirsoft.net)") ```bash ​ Sends one or more key press combinations to the system. The operating system will behave exactly as the user really pressed the specified keys combination. The [Key Combination] parameter specifies a single key press to send or a combination of a single key and shift/ctrl/alt/Windows keys, delimited by '+' character. The key in the [Key Combination] parameter can be specifed as numeric virtual key code (For example: 0x2e for Delete key), or as one of the following predefined values: a - z and 0 - 9 (for alphanumeric keys), F1 - F24 (for Fxx keys), shift, ctrl, alt, enter, esc ,leftshift, rightshift, leftctrl, rightctrl, leftmenu, rightmenu, spc (space), down, up, left, right, home, end, insert, delete, plus, comma, minus, period, lwin, rwin (Windows key), apps, pageup, pagedown, tab, multiply, add, subtract, seperator, divide, backspace, pause, capslock, numlock, scroll, printscreen. You can specify more than one [Key Combination] in a single sendkeypress command. Here's some examples for using sendkeypress: Send ctrl+shift+esc to show the task manager of Windows: sendkeypress ctrl+shift+esc Send ctrl+shift+esc to show the task manager of Windows and then move to the next window with alt+tab: sendkeypress ctrl+shift+esc alt+tab Switch the capslock mode: sendkeypress capslock Print 'Nir Sofer' to the current text editor in focus (The shift key combination is used to get the capital letters): sendkeypress Shift+n i r spc shift+s o f e r Save the current screen image into the clipboard (Ctrl+PrintScreen): sendkeypress Ctrl+printscreen Send Ctrl+Shift+K and then Ctrl+Shift+A and then Alt+Shift+P: sendkeypress ctrl+shift+k ctrl+shift+a alt+shift+p ​ ``` 向系统发送一个或多个按键组合。操作系统将完全模拟用户实际按下指定的键组合的行为。 \[Key Combination\] 参数指定了要发送的单个按键或单个键与shift/ctrl/alt/Windows键的组合,组合键之间用 '+' 字符分隔。 在\[Key Combination\]参数中,键可以指定为数字虚拟键码(例如:0x2e代表Delete键),或者以下预定义值之一:a - z 和 0 - 9(字母数字键)、F1 - F24(功能键)、shift、ctrl、alt、enter、esc、leftshift、rightshift、leftctrl、rightctrl、leftmenu、rightmenu、spc(空格)、down、up、left、right、home、end、insert、delete、plus、comma、minus、period、lwin、rwin(Windows键)、apps、pageup、pagedown、tab、multiply、add、subtract、separator、divide、backspace、pause、capslock、numlock、scroll、printscreen。 你可以在单个`sendkeypress`命令中指定多个\[Key Combination\]。 以下是一些使用`sendkeypress`的例子: 显示Windows任务管理器(使用Ctrl+Shift+Esc): sendkeypress ctrl+shift+esc ![](https://i-blog.csdnimg.cn/direct/727b518947844ea38c5c0c029bca1ff9.gif) 显示Windows任务管理器,然后使用Alt+Tab切换到下一个窗口: sendkeypress ctrl+shift+esc alt+tab 切换大写锁定模式: sendkeypress capslock 在当前聚焦的文本编辑器中打印"Nir Sofer"(使用Shift键组合来获取大写字母): sendkeypress Shift+n i r spc shift+s o f e r 将当前屏幕图像保存到剪贴板(使用Ctrl+PrintScreen): sendkeypress Ctrl+printscreen 发送Ctrl+Shift+K,然后Ctrl+Shift+A,然后Alt+Shift+P: sendkeypress ctrl+shift+k ctrl+shift+a alt+shift+p 这些示例展示了如何使用`sendkeypress`命令来模拟复杂的键盘操作,这对于自动化任务非常有用。 ## 后 单纯想实现自动化按键可以用python的pyautogui库 **侵删**

相关推荐
神秘人X7073 小时前
Ansible自动化运维介绍与安装
运维·自动化·ansible
007php00721 小时前
Jenkins+docker 微服务实现自动化部署安装和部署过程
运维·数据库·git·docker·微服务·自动化·jenkins
cxr8282 天前
自动化知识工作AI代理的工程与产品实现
运维·人工智能·自动化
未来之窗软件服务2 天前
浏览器开发CEFSharp+X86+win7(十三)之Vue架构自动化——仙盟创梦IDE
架构·自动化·vue·浏览器开发·仙盟创梦ide·东方仙盟
top_designer2 天前
作品集PDF又大又卡?我用InDesign+Acrobat AI构建轻量化交互式文档工作流
人工智能·pdf·自动化·设计规范·acrobat·indesign·交互式pdf
安全漏洞防治中心3 天前
Roadmap:一年实现安全漏洞防治自动化
运维·web安全·网络安全·自动化·漏洞管理·漏洞处置sop·漏洞紧急修复建议
文火冰糖的硅基工坊3 天前
[激光原理与应用-332]:结构设计 - Solidworks - 特征(Feature)是构成三维模型的基本单元,是设计意图的载体,也是参数化设计的核心。
系统架构·自动化·激光器·跨学科融合
xcs194054 天前
AI 自动化编程 trae 体验2 帮我分析一个项目
运维·自动化
Clownseven4 天前
Linux服务器健康检查Shell脚本:一键生成自动化巡检报告
linux·服务器·自动化
Jinkxs4 天前
告别人工建模:AI 自动化 ETL 工具对比,数据 pipeline 搭建时间缩短 60% 的实践
人工智能·自动化·etl