保存为 按键.bat
并替换 按键.vbs
ansi编码- #&cls&@powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" &exit
- cls
- #Windows API
- $code=@"
- using System;
- using System.Runtime.InteropServices;
- public static class GetApi{
- [DllImport("user32.dll")]
- public static extern bool SetWindowPos(int hwnd,int hwndAfter, int x, int y, int cx, int cy, int uFlags);
- }
- "@
- Add-Type -TypeDefinition $code
-
- '执行程序'
- $p = Start-Process 'D:\fjeit\Start123\Start123.exe' -PassThru
-
- '5s后发送按键并置顶'
- Start-Sleep -Seconds 5
- $shell = New-Object -ComObject 'Wscript.Shell'
- $shell.SendKeys('1')
-
- '主窗口置顶'
- [GetApi]::SetWindowPos($p.MainWindowHandle,-1,0,0,0,0,3)
复制代码
|