Size batch windows and set in specific location

只谈情不闲聊 提交于 2019-12-02 08:48:24

If you start each window like this

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

Goto the Window's properties. Set size and colour, untick Let Windows Position.

When you start it the same way in the future it will remember it's size and color.

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!