Window Positioner
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Window Positioner
Hey, this might be an easy task, but it's still a bit advance for me, so I ask for your help.
I want to make a script that will position every window at the center of the screen while taking it's size into the consideration.
So, the distance between each corner of the screen will be the same with windows that are wide, and also narrow.
Also, I want these windows to be positioned so their most bottom part will always touch the bottom of the screen, taking their height into to consideration.
So, if the window is really high, it will be placed higher so it's bottom part will touch the bottom, and the opposite with a lower window.
Hope I was able to be clear enough, any help will be appreciated, thank you!
I want to make a script that will position every window at the center of the screen while taking it's size into the consideration.
So, the distance between each corner of the screen will be the same with windows that are wide, and also narrow.
Also, I want these windows to be positioned so their most bottom part will always touch the bottom of the screen, taking their height into to consideration.
So, if the window is really high, it will be placed higher so it's bottom part will touch the bottom, and the opposite with a lower window.
Hope I was able to be clear enough, any help will be appreciated, thank you!
Re: Window Positioner
A centered window with its bottom at the screen's bottom sounds like a maximized window, or one that uses the full screen height.
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Window Positioner
Not always.
I have this so far:
Now I just need to figure out how to do the height stuff.
I have this so far:
Code: Select all
WinGetPos,,, Width, Height, A
TargetX := (A_ScreenWidth/2)-(Width/2)
TargetY := ; something here
WinMove, A, %TargetX%, %TargetY%
Last edited by hemsith14_ on 05 Jul 2022, 21:42, edited 1 time in total.
Re: Window Positioner
Code: Select all
WinGet, win, List
Loop, %win% {
WinExist("ahk_id" win%A_Index%)
WinGetTitle, title
If title in Program Manager,Start,Windows Task Manager,MainWindow
Continue
WinGet, winStyle, Style
WinGet, state , MinMax
If !(winStyle & 0x10000000) || !title || state = MAX := 1
Continue
WinGetPos,,, width, height
width := Min(width, A_ScreenWidth), height := Min(height, A_ScreenHeight)
WinMove,,, (A_ScreenWidth - width) / 2, A_ScreenHeight - height, width, height
}
MsgBox, 64, Done, Done!
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Window Positioner
I tried your solution but it didn't work as expected
Maybe I didn't explain myself well enough
Imagine the file explorer, I want that the script will always position it's bottom part at the bottom of the screen, regardless of it's height (it can be really long or short).
I don't want to maximize the window or enlarge it in any way
Thanks either way!
P.S I'd appreciate if it could be a simple solution
Something like
Maybe I didn't explain myself well enough
Imagine the file explorer, I want that the script will always position it's bottom part at the bottom of the screen, regardless of it's height (it can be really long or short).
I don't want to maximize the window or enlarge it in any way
Thanks either way!
P.S I'd appreciate if it could be a simple solution
Something like
Code: Select all
TargetY := ;Get bottom of window to touch bottom of screen
Re: Window Positioner
You tried the script?
Same thing:
Same thing:
Code: Select all
winTitle = ahk_class CabinetWClass
Run, explorer.exe
WinWait, %winTitle%
centerBottom(winTitle)
MsgBox, 64, Done, Done!
centerBottom(winTitle) {
WinExist(winTitle)
WinGet, state, MinMax
If state = MAX := 1
Return
WinGetPos,,, width, height
width := Min(width, A_ScreenWidth), height := Min(height, A_ScreenHeight)
WinMove,,, (A_ScreenWidth - width) / 2, A_ScreenHeight - height, width, height
}
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Window Positioner
I solved it with the following line:
Thanks either way for your help!
Code: Select all
TargetY := (A_ScreenHeight)-(Height)