用于打开可执行文件并捕捉到桌面左上角的脚本

时间:2009-12-09 08:48:05

标签: batch-file scripting

我只是在一个.bat文件中,如果有办法调用外部.bat文件,或者甚至是* .exe并将其打开以便它“快照”到左上角屏幕?

干杯

4 个答案:

答案 0 :(得分:3)

没有直接从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);
    }
}

答案 1 :(得分:1)

在cmd框中输入help start

示例:start /MAX "xxx.bat"

答案 2 :(得分:0)

使用start命令。

答案 3 :(得分:0)

这有点乱,但我认为可以做到。

您需要安装两个程序:
AutoIt的
Winsplit革命

创建一个自动脚本:
1.打开您想要的程序或批处理文件 2.等待程序打开 3.使程序成为活动窗口
4.调用ctrl + alt + 7,“发送(”^!7“)”(Winsplit Revolution快捷方式将程序发送到左上角)
5.结束脚本

如果我有时间,我会尝试编写脚本