小编Jel*_*ean的帖子

将密钥发送到 PowerShell 中打开的窗口

我制作了一个打开某个程序的程序,然后在 x 时间后Ctrl+C它。

我现在正在使用这个[System.Windows.Forms.SendKeys]::SendWait("^{c}")。这个目标是某个窗口还是随机发送到当前窗口?

如何将其更改为某个窗口?

这是我的代码:

Write-Host "Safe Botting V0.1"
Write-Host "Initializing..."
Start-Sleep -s 3
Write-Host "Program started successfully with no errors."

While($true)
{
    Write-Host "Starting bot..."
    Start-Sleep -s 3
    Start-Process -FilePath E:\Documents\bot.exe
    Write-Host "Bot started successfully"
    $rnd = Get-Random -Minimum 1800 -Maximum 10800
    Write-Host "The bot will run for:"
    Write-Host $rnd
    Start-Sleep -s $rnd
    Write-Host "Bot will now stop!"
    [System.Windows.Forms.SendKeys]::SendWait("^{c}") 
    Write-Host "Bot terminated"
    Write-Host "Starting cooldown time"
    $rnb = Get-Random -Minimum 14400 -Maximum …
Run Code Online (Sandbox Code Playgroud)

powershell

2
推荐指数
1
解决办法
4925
查看次数

标签 统计

powershell ×1