[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. [console]::BufferHeight=[console]::WindowHeight
  2. [console]::BufferWidth=[console]::WindowWidth
复制代码

TOP

绕一下
  1. #@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
  2. [console]::BufferHeight=[console]::WindowHeight
  3. [console]::BufferWidth=[console]::WindowWidth
  4. [console]::BackgroundColor=0xf
  5. [console]::ForegroundColor=0x0
  6. Add-Type -Ty @'
  7.     using System.Runtime.InteropServices;
  8.     public static class WinApi{
  9.         [DllImport("kernel32.dll")] public static extern uint GetConsoleWindow();
  10.         [DllImport("User32.dll")] public static extern int SetWindowLong(uint hWnd,int nIndex,int dwNewLong);
  11.         [DllImport("User32.dll")] public static extern bool SetWindowPos(uint hWnd,uint hAfter,uint x,uint y,uint cx,uint cy,uint flags);
  12.     }
  13. '@
  14. $a=[WinApi]::GetConsoleWindow()
  15. [void][WinApi]::SetWindowLong($a, -16, 369164288)
  16. [WinApi]::SetWindowPos($a,0,0,0,0,0,0x0087)
  17. [WinApi]::SetWindowPos($a,0,0,0,0,0,0x0047)
  18. cls
复制代码

TOP

本帖最后由 idwma 于 2022-4-10 20:37 编辑

再绕一下
  1. #@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
  2. [console]::BufferHeight=[console]::WindowHeight
  3. [console]::BufferWidth=[console]::WindowWidth
  4. Add-Type -Ty @'
  5.     using System.Runtime.InteropServices;
  6.     public static class WinApi{
  7.         [DllImport("kernel32.dll")] public static extern uint GetConsoleWindow();
  8.         [DllImport("User32.dll")] public static extern int SetWindowLong(uint hWnd,int nIndex,int dwNewLong);
  9.         [DllImport("User32.dll")] public static extern bool SetWindowPos(uint hWnd,uint hAfter,uint x,uint y,uint cx,uint cy,uint flags);
  10.     }
  11. '@
  12. $l=(Get-WmiObject win32_videocontroller).CurrentHorizontalResolution/2-200
  13. $a=[WinApi]::GetConsoleWindow()
  14. [void][WinApi]::SetWindowLong($a, -16, 369164288)
  15. [WinApi]::SetWindowPos($a,0,$l,0,0,0,1)
  16. [WinApi]::SetWindowPos($a,0,$l,0,400,500,2)
  17. [console]::BufferHeight=[console]::WindowHeight
  18. [console]::BufferWidth=[console]::WindowWidth
复制代码
1

评分人数

    • 5i365: 技术牛X, 乐于分享!技术 + 1

TOP

本帖最后由 idwma 于 2022-4-10 20:38 编辑

这里其实是搞错了,可以随便填两个数位置是不会变的
应该可以用以前went大的那个代码来居中
好像也不用那么复杂简单的修改了一下

TOP

返回列表