[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
win10真不行,notepad.exe 连窗口位置都无法修改.得用别的方法
微信:flashercs
QQ:49908356

TOP

本帖最后由 flashercs 于 2019-11-21 16:23 编辑

批处理.bat
  1. <#*,:&cls
  2. @echo off
  3. pushd "%~dp0"
  4. Powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
  5. popd
  6. pause
  7. exit /b
  8. #>
  9. $x = 300
  10. $y = 200
  11. $xsize = 300
  12. $ysize = 200
  13. $app = "cmd.exe"
  14. $params = @('/k', 'echo hello&echo Lee')
  15. Add-Type -TypeDefinition @'
  16. using System;
  17. using System.Runtime.InteropServices;
  18. namespace User32
  19. {
  20.    public static class NativeMethods
  21.     {
  22.         [DllImport("user32.dll",EntryPoint = "SetWindowPos",SetLastError = true)]
  23.         public static extern Boolean SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, UInt32 uFlags);
  24.         
  25.     }
  26. }
  27. '@
  28. $proc = Start-Process -FilePath $app -ArgumentList $params -PassThru
  29. while ($proc.MainWindowHandle -eq 0) {
  30.   Start-Sleep -Milliseconds 10
  31. }
  32. [User32.NativeMethods]::SetWindowPos($proc.MainWindowHandle, 0, $x, $y, $xsize, $ysize, 0x4000 + 0x0004)
复制代码
微信:flashercs
QQ:49908356

TOP

返回列表