找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 4438|回复: 1

[问题求助] 运行后弹出的游戏窗口在桌面上的位置VBS怎么设置?

[复制链接]
发表于 2025-4-16 23:00:59 | 显示全部楼层 |阅读模式
  1. dim a
  2. a="D2loader.exe -w -nohide -lq -direct -skiptobnet -pdir zcms -title AAAAAAAA"
  3. set ea=Wshell.Exec(a)
  4. wscript.Sleep 3000                                rem 启动到登录界面的延时时间,网速慢的稍微调成3000(3秒)以上
  5. Wshell.SendKeys "123456"                        rem 前面双引号内为账号a密码
  6. wscript.Sleep 200
  7. Wshell.SendKeys "{TAB}"
  8. wscript.Sleep 200
  9. Wshell.SendKeys "账号a"                                rem 前面双引号内为账号a名称
  10. wscript.Sleep 200
  11. Wshell.SendKeys "{ENTER}"
复制代码
运行多游戏窗口,不想多个游戏窗口重叠在一起,怎么单独设置每个窗口在桌面上的位置使之均匀分布
发表于 2025-4-17 08:26:27 | 显示全部楼层
Exec 和 Run 和 批处理的 start 都没有定位功能
你可以换个思路,全部登录完成后,再移动窗口大小
  1. <# : 另存为 ANSI 编码 bat
  2. @echo off
  3. cls
  4. PowerShell.exe -NoProfile -ExecutionPolicy Bypass "Invoke-Expression (${%~f0} | Out-String)"
  5. pause
  6. exit /b
  7. #>

  8. Add-Type @"
  9. using System;
  10. using System.Text;
  11. using System.Runtime.InteropServices;

  12. public class WindowAdjuster {
  13.     public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

  14.     [DllImport("user32.dll", CharSet = CharSet.Auto)]
  15.     public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);

  16.     [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
  17.     public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

  18.     [DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)]
  19.     public static extern bool IsWindowVisible(IntPtr hWnd);

  20.     [DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)]
  21.     public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);

  22.     [DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)]
  23.     public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

  24.     public struct RECT {
  25.         public int Left;
  26.         public int Top;
  27.         public int Right;
  28.         public int Bottom;
  29.     }

  30.     public static void AdjustWindows() {
  31.         EnumWindowsProc enumProc = new EnumWindowsProc(EnumWindowsCallback);
  32.         EnumWindows(enumProc, IntPtr.Zero);
  33.     }

  34.     private static bool EnumWindowsCallback(IntPtr hWnd, IntPtr lParam) {
  35.         if (IsWindowVisible(hWnd)) {
  36.             StringBuilder title = new StringBuilder(1024);
  37.             int length = GetWindowText(hWnd, title, title.Capacity);
  38.             if (length > 0) {
  39.                 RECT rect;
  40.                 if (GetWindowRect(hWnd, out rect)) {
  41.                     int width  = rect.Right  - rect.Left;
  42.                     int height = rect.Bottom - rect.Top;

  43.                     Console.WriteLine("Found window handle: " + hWnd.ToString()
  44.                         + ", Title: " + title.ToString()
  45.                         + ", Position: (" + rect.Left + ", " + rect.Top + ")"
  46.                         + ", Size: (" + width + "x" + height + ")");

  47.                     if (rect.Left > 0 && rect.Top > 0) {
  48.                         MoveWindow(hWnd, 144, 79, 1632, 892, true);
  49.                     }
  50.                 }
  51.             }
  52.         }
  53.         return true;
  54.     }
  55. }
  56. "@

  57. [WindowAdjuster]::AdjustWindows()
复制代码
这个可以显示当前所有窗口的大小和位置,并把所有窗口移动到指定坐标指定大小

你去powershell区问下怎么修改
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-16 22:41 , Processed in 0.017047 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表