Window to top/bottom half of the screen

Discussion, questions and support.
Post Reply
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Nov 16th, ’19, 15:40

Hi,

I'd appreciate your help.

Fastkeys has available in its library the commands "Window to Left Half of the Screen" / "Window to Right Half of the Screen" (screenshot and syntax below).

How to adapt that code to achieve:
- Window to top half of the screen
- Window to bottom half of the screen

Thanks for the assistance,
Carlos

Code: Select all

w:=A_ScreenWidth/2
h:=A_ScreenHeight-40
WinMove,A,,0,0,%w%,%h%
Image
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Nov 17th, ’19, 21:22

Use WinMove command: https://www.autohotkey.com/docs/commands/WinMove.htm

Code: Select all

WinMove, A,, 0, 0, A_ScreenWidth, A_ScreenHeight/2
;or
WinMove, A,, 0, A_ScreenHeight/2, A_ScreenWidth, A_ScreenHeight/2
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Nov 19th, ’19, 22:24

Hi @Tom,

Many thanks for the scripts and directions!

I would appreciate further help regarding a fine-tuning on:
WinMove, A,, 0, A_ScreenHeight/2, A_ScreenWidth, A_ScreenHeight/2
After running the script, the very bottom of the window is positioned behind Windows taskbar (you can't see it).
Would it be possible to tweak any parameter to avoid having part of the window hidden by the task bar?
The bottom limit for the resized window would be the taskbar.
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Nov 20th, ’19, 12:19

Assuming your Tray height is 40 pixels:

Code: Select all

WinMove, A,, 0, A_ScreenHeight/2, A_ScreenWidth, A_ScreenHeight/2-40
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Nov 20th, ’19, 12:35

Hi Marko,

Your suggestion worked perfectly, and now the window is positioned over the taskbar. Thanks!

I just noticed there is an issue regarding restoring the window to the last state it was before using any of the commands discussed in this thread, including the ones available in Fastkeys library (Window to top half of the screen / Window to bottom half of the screen).

As you can see in this screencast (http://bit.ly/2OsmM2R), before running the commands, my windows last state were “maximized”. Then after running the command and clicking to restore the window, it doesn’t restore to “maximized”. Instead, it is restored to an “unknown” state.

Do you know if it is possible to use the commands discussed in this thread, an restore the window to its last state later?

Thank you,
Carlos
Post Reply