我运行多个批处理文件来监控我的网络链接。我有下面的一组代码。我运行一个批处理文件来一次打开所有文件。然后我不得不在屏幕的顶部重新定位它们,这样我就可以打开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
)发布于 2014-12-03 07:32:59
如果您像这样启动每个窗口
start "A Window Title" cmd /k <optional command>转到窗口的属性。设置大小和颜色,取消勾选让窗口定位。
当你以后以同样的方式启动它时,它会记住它的大小和颜色。
发布于 2014-12-02 19:54:23
没有批处理文件命令可以做到这一点。也没有任何脚本(或.NET)命令可以对不是代码的(或由代码启动的)窗口执行任何操作。程序不应该扰乱其他人的。
我有一把的VB6非常基本的程序来调整大小,移动,在顶部,并改变标题栏(与源代码-每个是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发布于 2021-07-22 00:50:31
要调整批处理窗口的大小并将其设置在特定位置,请在命令提示符窗口打开后,右键单击标题栏,选择属性,转到布局选项卡,取消选中“让系统定位窗口”,然后根据需要选择窗口大小和窗口位置。您还可以选择其他属性(字体、字体大小、颜色等)从属性中的其他选项卡。从那时起,它将以设置格式打开。
https://stackoverflow.com/questions/27248528
复制相似问题