Page 1 of 1
Store windows positions
Posted: 27 Feb 2018 08:44
by Matt Williamson
I'm not sure if this is possible or has been previously covered. I've done some searching but haven't found anything yet. I have multiple monitors at work. 2 24" and the display from my laptop. I use all 3 of them when I'm working but I have to take my laptop with me when I'm out in the field. When I do so, all of my windows go back to my laptop and when I plug it back in, I have to manually move all of my windows back. Is there any way I can store the locations so I can just run a script so they go back to the original positions? I'm running Windows 10 10.0.15063
Thanks,
Matt
Re: Store windows positions
Posted: 27 Feb 2018 11:51
by aGerman
That's not possible using Batch. I have a rough idea how to manage it using C and Windows API but I don't want to reinvent the wheel. Try to find an existing 3rd party. Most likely you're not the only one who wants to restore the window positions ...
Steffen
Re: Store windows positions
Posted: 27 Feb 2018 11:53
by gustavo.lago
I think that is not possible with DOS Batch.
Maybe this:
https://github.com/adamsmith/WindowsLayoutSnapshot
Re: Store windows positions
Posted: 27 Feb 2018 12:03
by Squashman
Re: Store windows positions
Posted: 27 Feb 2018 12:29
by Matt Williamson
aGerman wrote: ↑27 Feb 2018 11:51
That's not possible using Batch. I have a rough idea how to manage it using C and Windows API but I don't want to reinvent the wheel. Try to find an existing 3rd party. Most likely you're not the only one who wants to restore the window positions ...
Steffen
Hi Steffan
Thanks for your reply. I looked pretty extensively before posting here and I didn't find any that work with this particular version of windows 10.
Re: Store windows positions
Posted: 27 Feb 2018 12:30
by Matt Williamson
This doesn't work in Windows 10. I tested it and all of the forks. Thanks for your contribution though.
Re: Store windows positions
Posted: 27 Feb 2018 12:31
by Matt Williamson
I can't get to these from work. I'll have to take home an encrypted drive and grab them from home and hope they aren't blocked when I try to run them. Thanks for your contribution though.
Re: Store windows positions
Posted: 27 Feb 2018 12:56
by Squashman
Matt Williamson wrote: ↑27 Feb 2018 12:31
I can't get to these from work. I'll have to take home an encrypted drive and grab them from home and hope they aren't blocked when I try to run them. Thanks for your contribution though.
Yeah, that happens at my work as well. Majority of file sharing sites and others are blocked.
Re: Store windows positions
Posted: 27 Feb 2018 16:24
by Aacini
How the windows are manually moved back to the other monitors? I wonder if this could be done using my
SendMessage.exe auxiliary program.
Antonio
Re: Store windows positions
Posted: 27 Feb 2018 18:17
by aGerman
Maybe using WM_MOVE and WM_SIZE messages you could restore a window. But I'm not sure how to get those values using SendMessage.
If I had to write such a tool I would probably use EnumWindows to get the handles of all top-level windows. Then use GetWindowPlacement to get the neccessary data and save it for every window, maybe along with the window title or the window class name or even the process name it belongs to in order to be able to perform a proper comparison if the windows have to be restored. Restoring could be done using SetWindowPlacement. I have no clue if that would work with multiple monitors though.
Steffen
Re: Store windows positions
Posted: 27 Feb 2018 20:23
by ShadowThief
I don't know about restoring positions, but I know that you can use powershell to access the Win32 API and set window positions to predefined sizes and locations.
Re: Store windows positions
Posted: 06 Mar 2018 03:07
by jfl
There's a PowerShell script called
window.ps1 in my system management library for doing this.
There are many options. Run (window -?) or (help window -detailed) for details.
Example:
Code: Select all
PS C:\WINDOWS\system32> window | ft -a
hWnd Program Left Top Width Height Title
---- ------- ---- --- ----- ------ -----
1247580 ApplicationFrameHost.exe 567 310 1061 801 Settings
11863656 chrome.exe 488 24 1348 1080 Store windows positions - DosTips.com - Google Chrome
2951190 cmd.exe 177 87 993 999 Administrator: Command Prompt
197872 cmd.exe 84 61 993 999 Administrator: Command Prompt
787874 javaw.exe 628 0 1282 1087 jEdit - FileW32.cpp
1114136 notepad.exe 484 240 1176 967 t.bat - Notepad
984636 notepad.exe 484 240 1176 967 Work log 2018-03-06.txt - Notepad
983346 Notepad2.exe 405 8 1218 1080 Catalog.md - Notepad2
66566 OUTLOOK.EXE 0 554 1920 581 Inbox - jf.larvoire@hpe.com - Outlook
723232 powershell.exe 400 30 993 999 Administrator: Windows PowerShell
524344 SystemSettings.exe 0 0 1045 793 Settings
263442 Explorer.EXE 486 48 1441 1044 Docs
395230 Explorer.EXE 486 48 1441 1044 JFL
1312270 javaw.exe 1078 42 504 493 Search And Replace
1116284 Notepad2.exe 773 439 482 218 Find Text
PS C:\WINDOWS\system32> window "t.bat - Notepad" -MoveTo 200,80 -Resize 1200,1000 -OnTop
PS C:\WINDOWS\system32>