[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
保存为 按键.bat
并替换 按键.vbs
ansi编码
  1. #&cls&@powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" &exit
  2. cls
  3. #Windows API
  4. $code=@"
  5.     using System;
  6.     using System.Runtime.InteropServices;
  7.     public static class GetApi{
  8.         [DllImport("user32.dll")]
  9.         public static extern bool SetWindowPos(int hwnd,int hwndAfter, int x, int y, int cx, int cy, int uFlags);
  10.     }
  11. "@
  12. Add-Type -TypeDefinition $code
  13. '执行程序'
  14. $p = Start-Process 'D:\fjeit\Start123\Start123.exe' -PassThru
  15. '5s后发送按键并置顶'
  16. Start-Sleep -Seconds 5
  17. $shell = New-Object -ComObject 'Wscript.Shell'
  18. $shell.SendKeys('1')
  19. '主窗口置顶'
  20. [GetApi]::SetWindowPos($p.MainWindowHandle,-1,0,0,0,0,3)
复制代码

TOP

返回列表