Size batch windows and set in specific location

后端 未结 2 601
甜味超标
甜味超标 2021-01-26 01:01

I have multiple batch files I run to monitor my network links. I have one of the sets of code below. I run a single batch file to open all the files at once. I then have to r

2条回答
  •  深忆病人
    2021-01-26 01:25

    There is no batch file command to do that. Nor is there any scripting (or .NET) command to do anything to a window that isn't the code's (or started by it). Programs shouldn't mess with others'.

    I have a handfull of VB6 very basic programs to resize, move, ontop, and change titlebar (with source code - each is 6 lines or so) at https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121

    Only API calls can do this so you need a real programming language. It is against the philosophy to do this.

    Now CMD remembers it's windows position based on titlebar. Make shortcuts that take advantage of that, see HKEY_CURRENT_USER\Console

    I suggest you look at the CMD title thing.

    Hers a VB6 prog to move a window.

    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
    

提交回复
热议问题