gpt4 book ai didi

batch-file - 打开可执行文件并捕捉到桌面左上角的脚本

转载 作者:行者123 更新时间:2023-12-04 03:19:01 24 4
gpt4 key购买 nike

我只是想知道在 .bat 文件中是否有一种方法可以调用外部 .bat 文件,甚至是 *.exe 并使其打开,以便它“捕捉”到屏幕的左上角?

干杯

最佳答案

没有直接的方法可以从 Windows 命令提示符定位窗口。您基本上有以下选择:

  • 使用 GUI 自动化工具,例如AutoHotkey它使您可以编写窗口操作脚本。 AutoHotkey 例如提供WinMove命令:
    Run, calc.exe
    WinWait, Calculator
    WinMove, 0, 0 ; Move the window found by WinWait to the upper-left corner of the screen.
  • 使用 PowerShell,例如使用 WASP 管理单元 (http://wasp.codeplex.com/)。
  • 用 C/C++/.NET 编写一个短程序,将事件窗口定位在主屏幕的 0,0 位置。

  • 一个非常基本的 C# 程序,它以窗口标题作为参数,可能如下所示:
    using System;
    using System.Runtime.InteropServices;

    class Program
    {
    public const int SWP_NOSIZE = 0x0001;
    public const int SWP_NOZORDER = 0x0004;

    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);

    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    static void Main(string[] args)
    {
    IntPtr handle = FindWindow(null, args[0]);
    SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    }
    }

    关于batch-file - 打开可执行文件并捕捉到桌面左上角的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1872470/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com