[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 idwma 于 2022-2-20 16:26 编辑

http://www.bathome.net/redirect. ... 1741&ptid=61628
学点基础,进入练气期,很多方法都通用的改一下就能用
  1. #&cls&@powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression" &pause&exit
  2. 1..3|%{start C:\"Program Files (x86)"\Tencent\WeChat\WeChat.exe}
  3. while($j -ne 3){sleep 1;if($j -ne $null){rv j};ps wechat|%{if(!($_.mainwindowtitle -eq '')){$j++}}}
  4. cls
  5. #Windows API
  6. $code=@'
  7.     using System;
  8.     using System.Runtime.InteropServices;
  9.     public struct RECT{
  10.         public uint left;
  11.         public uint top;
  12.         public uint right;
  13.         public uint bottom;
  14.     }
  15.     public static class WinApi{
  16.         [DllImport("user32.dll")]
  17.         public static extern bool SetWindowPos(uint hWnd,uint hAfter,uint x,uint y,uint cx,uint cy,uint flags);
  18.         [DllImport("kernel32.dll")]
  19.         public static extern uint GetConsoleWindow();
  20.         [DllImport("user32.dll")]
  21.         public static extern bool GetWindowRect(uint hwnd, ref RECT rect);
  22.         [DllImport("user32.dll")]
  23.         public static extern uint GetDC(uint hwnd);
  24.         [DllImport("gdi32.dll")]
  25.         public static extern uint GetDeviceCaps(uint hdc, int index);
  26.         public static uint[] GetScreen(){
  27.             uint[] arr = {0,0};
  28.             uint hdc = GetDC(0);
  29.             arr[0] = GetDeviceCaps(hdc,118);
  30.             arr[1] = GetDeviceCaps(hdc,117);
  31.             return arr;
  32.         }
  33.     }
  34. '@
  35. Add-Type -TypeDefinition $code
  36. #获取记事本窗口句柄
  37. #$hwnd = (Get-Process 'notepad')[0].MainWindowHandle
  38. #获取窗口信息
  39. $rect = New-Object 'RECT'
  40. [void][WinApi]::GetWindowRect([int]$hwnd,[ref]$rect)
  41. $screen = [WinApi]::GetScreen()
  42. #计算水平居中坐标
  43. #$x = ($screen[0] - ($rect.right - $rect.left))/2
  44. #设置记事本水平居中
  45. $a=Get-Process 'WeChat'
  46. while($i++ -le $a.count){
  47. $hwnd = $a[$i-1].MainWindowHandle
  48. [WinApi]::SetWindowPos([int]$hwnd,$null,$i*100,$i*100,0,0,1)
  49. }
复制代码

TOP

回复 3# 5i365
  1. #获取记事本窗口句柄
  2. $a=Get-Process 'WeChat'
  3. $hwnd = $a[0].MainWindowHandle
  4. #获取窗口信息
  5. $rect = New-Object 'RECT'
  6. [void][WinApi]::GetWindowRect([int]$hwnd,[ref]$rect)
  7. $screen = [WinApi]::GetScreen()
  8. $mw=$rect.right - $rect.left
  9. #计算水平居中坐标
  10. $x=($screen[0]-$mw*$a.count)/2
  11. $y = ($screen[1] - ($rect.bottom - $rect.top))/2
  12. #设置记事本水平居中
  13. while($i++ -lt $a.count){
  14. $hwnd = $a[$i-1].MainWindowHandle
  15. [WinApi]::SetWindowPos([int]$hwnd,$null,$x,$y,0,0,1)
  16. $x+=$mw
  17. }
复制代码
1

评分人数

TOP

回复 6# 5i365
  1. #计算水平居中坐标
  2. $x = ($screen_w - $mw * $a.count)/($a.count-1)
  3. $y = ($screen_h - ($rect.bottom - $rect.top))/2
  4. #设置记事本水平居中
  5. while ($i++ -lt $a.count)
  6. {
  7. $hwnd = $a[$i - 1].MainWindowHandle
  8. [WinApi]::SetWindowPos([int]$hwnd, $null, $xx, $y, 0, 0, 1)
  9. $xx = $xx+$x+$mw
  10. }
复制代码

TOP

返回列表