2014-12-02 158 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位置

當您在將來以相同的方式啓動它時,它會記住它的大小和顏色。