AutoHotkey Community

It is currently May 27th, 2012, 6:19 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: December 3rd, 2010, 11:30 pm 
Offline

Joined: March 28th, 2010, 1:32 am
Posts: 681
Location: United States
How can the screens resolution be detected and then set the GUI position to the bottom-left corner of my screen?

Gui, Show, xm -- This gets the GUI to the center left, but I need bottom left. Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2010, 12:33 am 
Offline

Joined: July 9th, 2009, 1:13 am
Posts: 140
You got close to what you are looking for. The x and y options actually use numbers to specify a screen position. It assumes 0, which is why your xm code put it on the left.

Gui, Show, x0 y%SomeValue%, YourWindowTitle

That will set it to the left, and then offset from the top to SomeValue. If you are aiming for the corner, the built in value A_ScreenHeight can be used, just subtract the height of your GUI.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2010, 12:39 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
There is nothing as simple as this for bottom or right.

You must know the size of your gui.
And then you must calculate the window location

With the A_ScreenHeight and the gui height, you can calculate the location of the upper left corner of the window.

there are variables A_ScreenWidth & A_ScreenHeight
http://www.autohotkey.com/docs/Variables.htm#Screen


If you have multiple screens you might need to get the left/to/right/bottom parameters,
see :arrow: Monitor [, N] in this command http://www.autohotkey.com/docs/commands/SysGet.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2010, 12:47 am 
Offline

Joined: March 28th, 2010, 1:32 am
Posts: 681
Location: United States
Here's what I tried:

Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance force
#Persistent

height := A_ScreenHeight-485

Gui, Margin, 0, 0
Gui, Add, Picture, x0 y0 w411 h485, picture.png
Gui -Caption -Border
Gui, Show, x0 y%height%
return


It is indeed in the bottom left corner like I want, but I would like it to be flush with the top of the windows taskbar, instead of behind it hiding part of the GUI. It should be able to rest along the top of the taskbar. How can I achieve this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2010, 12:51 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Code:
SysGet, Mon, MonitorWorkArea

This gets the area not including the taskbar. Then you can do MonRight-MonLeft (and the same for top and bottom) to get the width and height.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2010, 12:53 am 
Offline

Joined: March 28th, 2010, 1:32 am
Posts: 681
Location: United States
Thanks Frankie.

I've also found this to work:

Code:
WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,,
height := A_ScreenHeight-485-TrayHeight



Full Code
Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance force
#Persistent

WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,,
height := A_ScreenHeight-485-TrayHeight

Gui, Margin, 0, 0
Gui, Add, Picture, x0 y0 w411 h485, picture.png
Gui -Caption -Border
Gui, Show, x0 y%height%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2010, 5:10 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
SysGet also has the MonitorWorkArea [, N] sub-command
:arrow: Same as the above except the area is reduced to exclude the area occupied by the taskbar and other registered desktop toolbars.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: hd0202 and 56 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group