Jump to content


Photo

Maximize a window to half of screen (like win 7) PART 2


  • Please log in to reply
5 replies to this topic

#1 etech0

etech0
  • Members
  • 73 posts

Posted 29 April 2012 - 06:07 AM

This is a followup to my previous question here: <!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?f=1&t=85410">viewtopic.php?f=1&t=85410</a><!-- l -->

I now have AHK maximizing a specific window to half of the screen. However, I'd like it to do it a drop differently.

When I do this manually in Win 7, the window fills half of the screen, but does not go all the way to the bottom, rather, it stops at the taskbar. That is what I want.

In contrast, the code I have maximizes the window to half screen, but it goes to the very bottom of the screen, and some of the window is hidden under the taskbar.

Here is the code:

WinMove - Notepad,,0,0,A_ScreenWidth/2,A_ScreenHeight

How can I fix this?

#2 JSLover

JSLover
  • Members
  • 920 posts

Posted 29 April 2012 - 06:28 AM

You should specify if you mean half the width or height...& where your start bar is...it's normally at the bottom, so I thought you meant half the height...then the code does /2 on the width & I'm like...wtf?!?...wait, you did say "bottom"...now I'm really confused!

Anyway, this is why I want A_ScreenWidthWA & A_ScreenHeightWA to be built-in vars...since they are not, let's create them...

SetTitleMatchMode, 2

SysGet, WA_, MonitorWorkArea

A_ScreenWidthWA:=WA_Right-WA_Left
A_ScreenHeightWA:=WA_Bottom-WA_Top

WinMove, Notepad, , WA_Left, WA_Top, A_ScreenWidthWA/2, A_ScreenHeightWA


#3 etech0

etech0
  • Members
  • 73 posts

Posted 29 April 2012 - 06:31 AM

I want the window to be half the width of the screen, and to go the entire height of the screen, not including the taskbar, which is at the bottom.

#4 Leef_me

Leef_me
  • Moderators
  • 7704 posts

Posted 29 April 2012 - 06:51 AM

Please be involved in your own education. :arrow: learn :)
Read the Winmove docs, and experiment with the script that JSLover provided.

for example, what happens if you changed A_ScreenWidthWA/2 to A_ScreenWidthWA/4 ??

#5 etech0

etech0
  • Members
  • 73 posts

Posted 29 April 2012 - 08:14 PM

After some testing, I found out that the taskbar is 40 pixels high.

WinMove - Notepad,,0,0,A_ScreenWidth/2,A_ScreenHeight-40

Did the trick.

#6 JSLover

JSLover
  • Members
  • 920 posts

Posted 29 April 2012 - 11:19 PM

After some testing, I found out that the taskbar is 40 pixels high.

...on your computer, that is...

OMFG... :evil: :twisted: :roll: ...did you not see my reply???

A_ScreenHeightWA would do that for you!!! A_ScreenHeight does the entire screen, so I made a new var called A_ScreenHeightWA...with a "WA" (meaning "Work Area") on the end...Work Area means "the space not occupied by the taskbar"!...my code does exactly what you want, run it.