2014-12-02 627 views
0

我有多个批处理文件我运行监视我的网络链接。我有下面的代码集之一。我运行一个批处理文件来一次打开所有文件。然后,我必须在屏幕顶部重新定位它们,以便我可以打开Internet Explorer以在屏幕底部显示太阳风。我想添加我使用的代码来设置每个窗口的打开位置。预先感谢您的帮助。大小批处理窗口和设置在特定位置

@echo off 
TITLE = VoIP Link 
mode 50,20 

    setlocal enableextensions enabledelayedexpansion 

    rem Get address from command line 
    set "address=13.2.9.6" 
    if not defined address set "address=127.0.0.1" 

    rem Configure levels and colors 
    rem The format is initialValue:color in value descending format 
    set "levels=9000:4F 178:E0 146:2F 0:E0" 

    rem infinite loop 
    for /l %%i in() do (
     rem retrieve information from ping command 
     set "rtt=Timed Out" 
     set "ttl=?" 
     for /f "tokens=3,4 delims==^<" %%a in (
      'ping -n 1 "%address%" ^| find "TTL="' 
     ) do for /f "tokens=1 delims=m" %%c in ("%%a") do (
      set /a "rtt=%%c" 
      set "ttl=%%b" 
     ) 

     rem retrieve color 
     set "color=" 
     for %%z in (%levels%) do for /f "tokens=1,2 delims=:" %%a in ("%%z") do (
      if not defined color if !rtt! geq %%a set "color=%%b" 
     ) 

     rem show information 
     if defined color color !color! 
     echo(!time! - %address% - rtt[!rtt!] 

     rem save to log 
     for /f "tokens=1-4 delims=.:-/ " %%a in ("!date!") do (
      >> "%%b-%%c-%%d_%%a_VOIP Link 1.txt" echo(!date! - !time! - %address% - rtt[!rtt!] 
     ) 

     rem wait and repeat the process 
     ping -n 3 localhost >nul 2>nul 
    ) 
+0

也许[这](http://stackoverflow.com/a/24905911/2861476)可以帮助 – 2014-12-02 11:46:27

+0

或此http://www.commandline.co.uk/cmdow/ – 2014-12-02 11:48:25

回答

0

没有批处理文件命令来做到这一点。也没有任何脚本(或.NET)命令对任何不是代码(或由它启动)的窗口执行任何操作。程序不应该混淆他人的。

我有VB6的福非常基本的程序来调整大小,移动,ontop的,并改变标题栏(附源代码 - 每6行左右)在https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121

只有API调用可以做到这一点,所以你需要一个真正的编程语言。这样做违背了哲学。

现在CMD记得它是基于标题栏的窗口位置。使快捷方式利用,看到HKEY_CURRENT_USER\Console

我建议你看看CMD标题的事情。

她的VB6编移动窗口。

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long 
Public Const SWP_DRAWFRAME = &H20 
Public Const SWP_FRAMECHANGED = &H20  ' The frame changed: send WM_NCCALCSIZE 
Public Const SWP_HIDEWINDOW = &H80 
Public Const SWP_NOACTIVATE = &H10 
Public Const SWP_NOCOPYBITS = &H100 
Public Const SWP_NOMOVE = &H2 
Public Const SWP_NOOWNERZORDER = &H200  ' Don't do owner Z ordering 
Public Const SWP_NOREDRAW = &H8 
Public Const SWP_NOREPOSITION = &H200 
Public Const SWP_NOSIZE = &H1 
Public Const SWP_NOZORDER = &H4 
Public Const SWP_SHOWWINDOW = &H40 

Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long 

Sub Main() 
On Error Resume Next 
HWND_TOPMOST = -1 

CmdLine = Command() 

A = Split(CmdLine, Chr(32), 2, 1) 
B = Split(A(0), "x", 2, 1) 

hwindows = FindWindow(vbNullString, A(1)) 
Ret = SetWindowPos(hwindows, HWND_NOTOPMOST, B(0), B(1), 0, 0, SWP_NOREPOSITION + SWP_NOSIZE) 
If Ret = 0 Then MsgBox "Set Pos Error is " & Err.LastDllError 
End Sub 
+0

@carpetsmoker所以我如何使文件记得它是preious的位置?我无法从工作中访问您的skydrive链接 – phifer2088 2014-12-02 12:10:39

+0

我将编辑我的答案。你有vb6吗? – triggeradeadcat 2014-12-02 12:25:31

+0

我没有vb6。我们正在运行一个锁定的股票窗口7企业形象。 – phifer2088 2014-12-02 12:29:42

1

如果你开始喜欢这个

start "A Window Title" cmd /k <optional command> 

转到窗口的属性,每个窗口。设置大小和颜色,取消选中让Windows位置

当您在将来以相同的方式启动它时,它会记住它的大小和颜色。