Code: Select all
CentreWindow()
{
Wingetpos, ,, sizW, sizH, A
offX := (%A_screenwidth%/2) - (sizW/2)
offY := (%A_screenwidth%/2) - (sizH/2)
Winmove, %offX%, %offY%
}
Code: Select all
CentreWindow()
{
Wingetpos, ,, sizW, sizH, A
offX := (%A_screenwidth%/2) - (sizW/2)
offY := (%A_screenwidth%/2) - (sizH/2)
Winmove, %offX%, %offY%
}
http://www.autohotkey.com/docs/commands/SysGet.htmMonitorWorkArea [, N]: Same as the above except the area is reduced to exclude the area occupied by the taskbar and other registered desktop toolbars.
Code: Select all
WinGetPos , , , Width, Height, Program Manager
Code: Select all
Sysget, var, Monitor
msgbox % varBottom
Indeed! I didn't notice that.gregster wrote:You are currently using A_screenwidth for determing both offsets!?
Code: Select all
offX := (%A_screenwidth%/2) - (sizW/2)
Code: Select all
CenterWindow(WinTitle)
{
WinGetPos,,, Width, Height, A
WinMove, A,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
}
Code: Select all
WinMovePos(p_Pos="",offX=0,offY=0,p_WinTtl="A",p_WinTxt="",p_ExcTtl="",p_ExcTxt="")
{
; adapted from MasterFocus's WinMoveSpecial
; First parameter: TOP | TOPRIGHT | RIGHT | BOTTOMRIGHT | BOTTOM | BOTTOMLEFT | LEFT | TOPLEFT | CENTER
; (anything else will result in CENTER)
; The other parameters: WinTitle, WinText, ExcludeTitle, ExcludeText
WinGetPos,,,l_W,l_H,%p_WinTtl%,%p_WinTxt%,%p_ExcTtl%,%p_ExcTxt%
l_X:=InStr(p_Pos,"LEFT",0) ? 0 : InStr(p_Pos,"RIGHT",0) ? A_ScreenWidth-l_W+offX : (A_ScreenWidth-l_W)/2
l_Y:=InStr(p_Pos,"TOP",0) ? 0 : InStr(p_Pos,"BOTTOM",0) ? A_ScreenHeight-l_H+offY : (A_ScreenHeight-l_H)/2
WinMove,%p_WinTtl%,%p_WinTxt%,%l_X%,%l_Y%,,,%p_ExcTtl%,%p_ExcTxt%
}
The colored parts are the possible values for each variable. Notice they can both be 0.l_X:=InStr(p_Pos,"LEFT",0) ? 0 : InStr(p_Pos,"RIGHT",0) ? A_ScreenWidth-l_W+offX : (A_ScreenWidth-l_W)/2
l_Y:=InStr(p_Pos,"TOP",0) ? 0 : InStr(p_Pos,"BOTTOM",0) ? A_ScreenHeight-l_H+offY : (A_ScreenHeight-l_H)/2
Users browsing this forum: Joey5, Londolozi, ShatterCoder and 113 guests