"Center a window" action

x64 Replacement/Alternative to Microsoft's IntelliMouse application.
Forum rules
Please read the forum rules before posting for the first time.
The more information you can provide, the quicker and more accurately someone can help.
NOTE: To reduce spam, new users can not post links or images until they have at least 4 posts.
Post Reply
xpclient
Member
Posts: 19
Joined: Sun Oct 20, 2013 8:22 am

"Center a window" action

Post by xpclient » Fri Aug 09, 2019 8:41 am

Feature request: Center a window (I noticed Minimize, Maximize, Restore but not Center).

Is it possible? Sorry in advance if it exists and I didn't notice it. :P

XMBC Version: 2.18.7
Windows Version: Windows 8.1
Mouse Information (brand/model): Microsoft Bluetooth Mobile Mouse 3600
Relevant Computer Information (CPU, RAM etc): Intel Core i5 Quad Core, 8 GB RAM, 256 GB SSD

User avatar
phil
Site Admin
Posts: 5960
Joined: Sun Apr 06, 2003 11:12 pm

Re: "Center a window" action

Post by phil » Fri Aug 09, 2019 9:02 am

Its not there (there isn't a Windows API call to do that like there is for min/max etc.) but it should be possible to do something like that.
I presume you are talking about centering it relative to the desktop of the current monitor that the window is on?
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

xpclient
Member
Posts: 19
Joined: Sun Oct 20, 2013 8:22 am

Re: "Center a window" action

Post by xpclient » Sat Sep 07, 2019 6:33 am

Yes. I found a AutoHotkey to make it work.

Code: Select all

^+Home::
global windowName
global X
global Y
global begWidth
global begHeight
WinGetTitle, windowName, A
WinGetPos, X, Y, begWidth, begHeight, %windowName%
CenterWindow(windowTitleVariable)
{
    WinGetPos,,, Width, Height, %windowTitleVariable%
    WinMove, %windowTitleVariable%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2    )-(Height/2)
}
CenterWindow(windowName)
return
^+End::
WinMove, %windowName%,, X, Y, begWidth, begHeight
return
Ctrl+Shift+Home centers a window, Ctrl+Shift+End restores it. Converted it into an EXE

User avatar
phil
Site Admin
Posts: 5960
Joined: Sun Apr 06, 2003 11:12 pm

Re: "Center a window" action

Post by phil » Sat Sep 07, 2019 10:19 am

Nice,

I'll still aim to add it natively to XMBC - but good that you have a solution in the meantime.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

Post Reply