"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, files or images until they have at least 4 posts.
Post Reply
xpclient
Member
Posts: 21
Joined: Sun Oct 20, 2013 8:22 am

"Center a window" action

Post by xpclient »

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: 7666
Joined: Sun Apr 06, 2003 11:12 pm

Re: "Center a window" action

Post by phil »

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/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
xpclient
Member
Posts: 21
Joined: Sun Oct 20, 2013 8:22 am

Re: "Center a window" action

Post by xpclient »

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: 7666
Joined: Sun Apr 06, 2003 11:12 pm

Re: "Center a window" action

Post by phil »

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/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Post Reply