Store windows positions
Moderator: DosItHelp
-
- Posts: 82
- Joined: 30 Dec 2013 10:16
- Location: United States by the big waterfall
Store windows positions
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
Thanks,
Matt
Last edited by Matt Williamson on 27 Feb 2018 08:48, edited 1 time in total.
Re: Store windows positions
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
Steffen
-
- Posts: 4
- Joined: 23 Feb 2018 08:52
Re: Store windows positions
I think that is not possible with DOS Batch.
Maybe this: https://github.com/adamsmith/WindowsLayoutSnapshot
Maybe this: https://github.com/adamsmith/WindowsLayoutSnapshot
-
- Posts: 82
- Joined: 30 Dec 2013 10:16
- Location: United States by the big waterfall
Re: Store windows positions
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.
-
- Posts: 82
- Joined: 30 Dec 2013 10:16
- Location: United States by the big waterfall
Re: Store windows positions
This doesn't work in Windows 10. I tested it and all of the forks. Thanks for your contribution though.gustavo.lago wrote: ↑27 Feb 2018 11:53I think that is not possible with DOS Batch.
Maybe this: https://github.com/adamsmith/WindowsLayoutSnapshot
-
- Posts: 82
- Joined: 30 Dec 2013 10:16
- Location: United States by the big waterfall
Re: Store windows positions
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.Squashman wrote: ↑27 Feb 2018 12:03Maybe one of these?
http://www.snapfiles.com/get/windock.html
http://www.snapfiles.com/get/wilma.html
Re: Store windows positions
Yeah, that happens at my work as well. Majority of file sharing sites and others are blocked.Matt Williamson wrote: ↑27 Feb 2018 12:31I 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.Squashman wrote: ↑27 Feb 2018 12:03Maybe one of these?
http://www.snapfiles.com/get/windock.html
http://www.snapfiles.com/get/wilma.html
Re: Store windows positions
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
Antonio
Re: Store windows positions
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
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
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Store windows positions
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
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:
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>