How to get / set each position and size of the application window in VBScript?

I would like to write a script to arrange the windows that I was currently opening on my screen.

Example: moving all browsers to monitor 1 and everything else for monitoring 2 Example: make 4 maximally maximized windows on monitor 1, each of them occupies equal squares on the screen, etc.

I guess VBScript would be good for this? What objects would I use for this in Win7?

0
user-interface windows vbscript window
Jan 11 '13 at 8:50
source share
2 answers

In VBScript, this is not possible because it does not provide access to the Windows APIs used to manage windows.

AutoIt seems like the best tool to work with. Explore the following functions and macros:

  • WinMove - move windows
  • _WinAPI_GetSystemMetrics (80) - get the number of monitors
  • @DesktopWidth and @DesktopHeight - pixel size of the primary monitor
  • _WinAPI_GetSystemMetrics(78) and _WinAPI_GetSystemMetrics(79) - full width and height of the desktop

If the monitor sizes are different, you can use the Win32_DesktopMonitor WMI Win32_DesktopMonitor and its ScreenWidth and ScreenHeigth properties to get individual monitor sizes.

+3
Jan 11 '13 at 14:29
source share

I'm not sure if I can say that VBS would be good for this, I think I would prefer C ++ for this, as it will include Windows API calls, which, in my opinion, are easier in C ++, but it depends on your skills and VBS can be wonderful.

The API calls I would look at would be EnumWindows or FindWindow to find the windows you want to move, and then SetWindowPos to move them.

I think that if you want to move them to an additional monitor, you should do this by moving it to a position outside the main monitor (possibly a negative position if the additional monitor is expanded on the left example). To do this, you will need to find out the current resolution and those that, I think, you can get from the WMI class Win32_VideoController .

+1
Jan 11 '13 at 9:23
source share



All Articles