是否可以使用 WMI 设置应用程序的高度和宽度?如果可以,如何设置?例如,更改记事本的高度和宽度。
谢谢
答案1
从 VBScript、VBA 等确实可以调整窗口大小。下面是如何使用窗口句柄调整窗口大小的示例。您需要提供要调整大小的特定窗口的 hWnd(窗口句柄)。可以使用其他 win32 api 来确定 hWnd,例如,从窗口的标题中确定。
Const HWND_TOPMOST = -1
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub 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)
Private Sub ResizeWindow(ByVal hWnd as Long,ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long)
SetWindowPos hWnd, HWND_TOPMOST, X, Y, cx, cy, SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub