Powershell模拟键盘输入

今天和我的朋友在网上发癫,需要脚本进行轰炸,经过一番调查,便有了这一篇文章。

环境

1.安装了Powershell 2.允许powershell运行ps1脚本

代码

$shell = New-Object -com "Wscript.Shell";
Start-Sleep 1;
while($True){
    Start-Sleep 0.05;
    $shell.sendkeys("^{v}");
    $shell.sendkeys("{ENTER}");
}

引用

要注意的是,以下是{}中的内容。

(引用自Converting the Windows Script Host SendKeys Method

Key  | Code
-----------
*SHIFT  +
*CTRL   ^
*ALT    %
BACKSPACE   {BACKSPACE}, {BS}, or {BKSP}
BREAK   {BREAK}
CAPS LOCK   {CAPSLOCK}
DEL or DELETE   {DELETE} or {DEL}
DOWN ARROW  {DOWN}
END {END}
ENTER   {ENTER}or ~
ESC {ESC}
HELP    {HELP}
HOME    {HOME}
INS or INSERT   {INSERT} or {INS}
LEFT ARROW  {LEFT}
NUM LOCK    {NUMLOCK}
PAGE DOWN   {PGDN}
PAGE UP {PGUP}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW    {UP}
F1  {F1}
F2  {F2}
F3  {F3}
F4  {F4}
F5  {F5}
F6  {F6}
F7  {F7}
F8  {F8}
F9  {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Keypad add  {ADD}
Keypad subtract {SUBTRACT}
Keypad multiply {MULTIPLY}
Keypad divide   {DIVIDE}

其他按键直接输入,如{V}->V。 上表中Key处有*的是标识符,需要搭配其他键使用。 如^{V}->Ctrl+V


Powershell模拟键盘输入
https://www.insaua.com/2023/02/07/Powershell模拟键盘输入/
作者
Eason3Blue
发布于
2023年2月7日
许可协议