回答
有從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 snapin(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);
}
}
使用start
命令。
cmd box type help start
。
例如:start /MAX "xxx.bat"
這將啓動窗口最大化。 OP想要的是一個窗口對齊屏幕的左上角。 – 2009-12-09 09:15:36
對於cmd(蝙蝠),當最大化時,窗口將被捕捉到左上角。 – Francis 2009-12-09 10:27:58
cmd也將通過此命令最大化地啓動。 – 2009-12-09 10:31:32
這是一個有點混亂,但我認爲這是可以做到。
您需要安裝兩個程序:
AutoIt的
Winsplit革命
創建一個AutoIt腳本到:
1.打開你想要的程序或批處理文件
2.等待,直到該程序打開
3.將程序激活窗口
4.調用ctrl + alt + 7,「發送(」^!7「)」(Winsplit Revolution快捷方式將程序發送到左上角)
5.結束腳本
如果我有時間後,我會嘗試編寫腳本
- 1. 捕捉到桌面上(不是在文件/文件夾/窗口)
- 2. 桌面文字捕捉
- 3. OPENCV桌面捕捉
- 4. linux桌面可執行文件python腳本
- 5. 如何打開桌面上的文件
- 6. 在Gnome桌面上打開.jar文件
- 7. VB腳本打開.exe文件並執行4個活動
- 8. 打開文件列表並執行腳本
- 9. 從php執行shell腳本在Windows上打開文件(Xampp)
- 10. 文本菜單顯示在首次桌面的左上角
- 11. Sencha桌面打包程序可執行文件
- 12. 腳本:SSH命令執行並保持shell打開,管道輸出到文件
- 13. 捕捉請求打開或創建文件並重新路由
- 14. shell腳本 - 打開xterm窗口執行命令,並繼續執行腳本
- 15. 如何捕捉JVM中的OutOfMemoryError,並在腳本被捕獲時運行腳本?
- 16. 如何捕捉pywin32com例外,上打開文件
- 17. 用Windows bat文件打開Cygwin並運行腳本文件
- 18. 如何用已打開的可執行文件打開文件?
- 19. VBA:打開多個文件並在所有打開的文件上執行宏
- 20. 打開Excel文件並執行宏
- 21. crontab打開文件並執行代碼
- 22. NSMenu打開時捕捉按鍵事件
- 23. 用php打開可執行文件
- 24. 無法打開可執行jar文件
- 25. png格式的桌面捕捉
- 26. 帶音頻的桌面捕捉
- 27. 打開PDF文件並執行文本搜索使用excel vba
- 28. 打開桌面Word中的OneDrive文件
- 29. android編輯文本如何開始在左上角打字?
- 30. 獨角獸安裝腳本與RVM - 可執行文件?
我給你這個答案。但我會用你和弗朗西斯的方法。我的主腳本也調用了幾個.bat文件和可執行文件。 AutoHotKey方法看起來更容易;不是我以前使用過AutoHotKey。 +1知識:) – user226973 2009-12-10 02:04:44