By the way, here's a version for Windows 7. There are a couple slight quirks compared to the Vista version in that the Volume Mixer window cannot be minimized, and the borderless window mode doesn't align with the task bar correctly (overlaps it a little).
Code:
/*
Windows 7 Media Center Multitool
Created by Blahman (blah238 at gmail dot com)
v0.2
10/17/2009
Features:
- Virtual full-screen modes provide seamless mouse movement across screens and allows full-screen Media Center usage on second monitor while playing full-screen games on primary monitor
- Causes the Mute button to only affect Windows Media Center as long as it's running. Works without stealing focus from active application/game window, using the Volume Mixer window. Automatically launches and closes the Volume Mixer when Media Center is launched/closed.
- Uses a context-specific hotkey (default: Shift-3) to cycle between 3 different windowed modes, 4 if you have a secondary monitor:
- Virtual full-screen on primary monitor (full-size window without borders)
- Small window in the bottom-right corner (windowed with borders)
- Small window in the bottom-right corner (windowed without borders)
- Virtual full-screen on secondary monitor (full-size window without borders)
- Listens for resolution changes on the primary monitor and automatically adjusts the positioning of the Media Center window to fit properly when using the virtual full-screen mode on secondary monitor.
- Hides the cursor when it hovers over the Media Center window for 5 seconds.
Feel free to customize this code or use it any way you wish. I only ask that you please post your improvements/tweaks to the code on the AHK forums for all to see and use.
*/
#SingleInstance, Force
;SetTitleMatchMode, 3
;SetTitleMatchMode, slow
SetDefaultMouseSpeed, 0
CoordMode, Mouse, Screen
cycle = 1 ; counter to keep track of the windowing mode to use next in a cycle
WaitForWMC:
Process, Wait, ehshell.exe ; Waits for Windows Media Center to be run
WMCPID = %ErrorLevel%
Process, Exist, SndVol.exe ; Windows' Volume Mixer is used to mute Media Center independently from other apps
SndVolPID = %ErrorLevel%
If SndVolPID = 0
Run, SndVol.exe, , , SndVolPID
ScrW := A_ScreenWidth
ScrH := A_ScreenHeight
SetTimer, CheckForResChange, On ; Sets a Timer that listens for primary monitor resolution changes
Gosub, MouseHideOn ; Sets a Timer that hides the cursor if it hovers over Media Center's window
; All timers use the default 250ms resolution -- feel free to speed them up if desired
; Cleans up whenever Media Center is closed
Process, WaitClose, %WMCPID%
WinClose, ahk_pid %SndVolPID%
SetTimer, CheckForResChange, Off
Gosub, MouseHideOff
Goto WaitForWMC
return
; Adjusts window when primary monitor resolution changes, e.g. when launching a full-screen game that uses a different resolution than the desktop
CheckForResChange:
if (A_ScreenWidth <> ScrW or A_ScreenHeight <> ScrH)
{
SysGet, monitorcount, MonitorCount
if (monitorcount = 1 or cycle <> 5) ; Only interested when using virtual full-screen on second monitor
return
sleep, 2500 ; sometimes resolution changes take a while...
SysGet, Mon2, Monitor, 2
Mon2W := Mon2Right - Mon2Left
Mon2H := Mon2Bottom - Mon2Top
WinGetPos, WMCx, WMCy,,, ahk_pid %WMCPID%
if (WMCx <> Mon2Left or WMCy <> Mon2Top)
WinMove, ahk_pid %WMCPID%,, Mon2Left, Mon2Top, Mon2W, Mon2H
ScrW := A_ScreenWidth
ScrH := A_ScreenHeight
}
return
#IfWinActive, ahk_class eHome Render Window ; This is the classname of the Windows Media Center application
+3::
; "Restores" the window if it is in true full-screen mode
WinGet, winstyle, Style, ahk_pid %WMCPID%
if (winstyle = 0x16000000) or (winstyle & 0x20000000)
{
PostMessage, 0x112, 0xF120,,, ahk_pid %WMCPID%
sleep, 1500
}
SysGet, monitorcount, MonitorCount
SysGet, Wk1, MonitorWorkArea, 1 ; used to avoid placing the window on top of the taskbar
If monitorcount = 2 ; provides 4 different windowing modes, the last places it on the second monitor in virtual full-screen
{
SysGet, Mon2, Monitor, 2
Mon2W := Mon2Right - Mon2Left
Mon2H := Mon2Bottom - Mon2Top
if cycle in 1,5 ; virtual full-screen on primary monitor
{
WinSet, Style, -0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , 0, 0, A_ScreenWidth, A_ScreenHeight
WinActivate, ahk_pid %WMCPID%
cycle = 2
return
}
if cycle = 2 ; small window with borders, bottom-right of primary monitor
{
WinSet, Style, +0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , A_ScreenWidth - (A_ScreenWidth - Wk1Right) - 831, A_ScreenHeight - (A_ScreenHeight - Wk1Bottom) - 495, 831, 495
cycle = 3
return
}
if cycle = 3 ; small window without borders, bottom-right of primary monitor
{
WinSet, Style, -0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , A_ScreenWidth - (A_ScreenWidth - Wk1Right) - 831, A_ScreenHeight - (A_ScreenHeight - Wk1Bottom) - 467, 831, 467
cycle = 4
return
}
if cycle = 4 ; virtual full-screen on secondary monitor
{
WinSet, Style, -0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , Mon2Left, Mon2Top, Mon2W, Mon2H
cycle = 5
return
}
}
Else ; only provides modes for the primary monitor
{
if cycle in 1,4,5
{
WinSet, Style, -0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , 0, 0, A_ScreenWidth, A_ScreenHeight
WinActivate, ahk_pid %WMCPID%
cycle = 2
return
}
if cycle = 2
{
WinSet, Style, +0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , A_ScreenWidth - (A_ScreenWidth - Wk1Right) - 831, A_ScreenHeight - (A_ScreenHeight - Wk1Bottom) - 495, 831, 495
cycle = 3
return
}
if cycle = 3
{
WinSet, Style, -0xC40000, ahk_pid %WMCPID%
WinMove, ahk_pid %WMCPID%, , A_ScreenWidth - (A_ScreenWidth - Wk1Right) - 831, A_ScreenHeight - (A_ScreenHeight - Wk1Bottom) - 467, 831, 467
cycle = 4
return
}
}
return
; Mutes Windows Media Center independently using Vista's Volume Mixer
#IfWinExist, ahk_class eHome Render Window
sc120:: ; scancode for the Mute key
Process, Exist, SndVol.exe
SndVolPID = %ErrorLevel%
If SndVolPID = 0
{
Run, SndVol.exe, , , SndVolPID
Sleep, 120
}
;ControlSend, ToolbarWindow326, {Space}, SndVol.exe ; Toggles the mute control for Media Center
ControlFocus, Mute for Windows Media Center, ahk_pid %SndVolPID%
ControlSend, Mute for Windows Media Center, {Space}, ahk_pid %SndVolPID%
;MsgBox, %ErrorLevel%
return
/*
The following subroutines hide the cursor (placing it in the bottom left corner of the primary monitor)
when it idles over the Media Center window for ~5 seconds, and then returns it to the previous coordinates when the
user begins to move the mouse again.
*/
MouseHideOn:
SetTimer, WaitForMouseIdle, On
return
MouseHideOff:
SetTimer, WaitForMouseIdle, Off
SetTimer, WaitForMouseMove, Off
DllCall("SetCursorPos", int, PosX1, int, PosY1) ; A DllCall is more reliable than MouseMove in multi-monitor setups
return
WaitForMouseIdle:
if A_TimeIdle > 5000
{
MouseGetPos, PosX1, PosY1
WinGetPos, WMCx, WMCy, WMCw, WMCh, ahk_pid %WMCPID%
if ((PosX1 > WMCx and PosX1 < WMCx + WMCw) and (PosY1 > WMCy and PosY1 < WMCy + WMCh)) ; Checks if cursor is positioned over the window
{
DllCall("SetCursorPos", int, 0, int, A_ScreenHeight) ; Places cursor in bottom-left corner of primary monitor
MouseGetPos, PosX2, PosY2
SetTimer, WaitForMouseIdle, Off
SetTimer, WaitForMouseMove, On
}
}
return
WaitForMouseMove:
MouseGetPos, PosX3, PosY3
if (PosX3 <> PosX2 or PosY3 <> PosY2)
{
DllCall("SetCursorPos", int, PosX1, int, PosY1) ; Returns cursor to its previous position
SetTimer, WaitForMouseMove, Off
SetTimer, WaitForMouseIdle, On
}
return
The Windows 7 code doesn't seem to be able to actually make the virtual full screen to actually go full screen... neither my main display or my secondary display will show the video full screen... Has anyone else had this problem, and has anyone found a solution?