0

Is it possible to set an application's height and width using WMI? If so, how? For example, change the height and width of Notepad.

Thanks

  • Would WASP help? archive.codeplex.com/?p=wasp – Andrew Lau Feb 12 '18 at 19:29
  • No. WMI is a Management Interface, not an application interface. You should edit this question and make it about the actual problem you're trying to solve. – Ƭᴇcʜιᴇ007 Feb 12 '18 at 20:05
  • @Ƭᴇcʜιᴇ007, that is the actual problem I am trying to solve. I was wondering/hoping the WMI had the ability to change the height/width of a running application. The question is formed in a very general question, which is what I intended. An even more general form of the question might be, how do I change the width and height of a running application through an API (VBScript, WMI, etc). – lordhog Feb 12 '18 at 22:47
  • @AndrewLau, not sure WASP would help, but I have never heard of it. I will check it out and might be promising since it's PowerShell. Thanks. – lordhog Feb 12 '18 at 23:10
  • "An even more general form of the question might be, how do I change the width and height of a running application through an API (VBScript, WMI, etc). " would be a answerable question in this format. As-is you've made it specific about a proposed solution instead of the problem (known as an XP Problem), so the answer to the question, as-is, is simply "No". And as such, not a great fit for SU. – Ƭᴇcʜιᴇ007 Feb 13 '18 at 14:14
0

From VBScript, VBA, etc is is indeed possible to resize a window. Below is an example of how to resize a window using its handle. You would need to provide the hWnd (windows handle) of the specific window you'd want to resize. Other win32 apis can be used to determine the hWnd from, for example, the window's title.

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

SetWindowPos function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.