AutoHotkey Community

It is currently May 27th, 2012, 1:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: October 19th, 2009, 4:43 am 
Offline

Joined: November 9th, 2008, 7:48 pm
Posts: 25
Try adding this under the CheckForResChange line:

Code:
IfGreater, A_TimeIdle, 10000
   if cycle in 1,4,5
      send {shift} ; prevents screensaver in virtual full-screen modes


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2010, 6:48 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
Blahman wrote:
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2010, 8:08 pm 
Offline

Joined: November 9th, 2008, 7:48 pm
Posts: 25
I think Windows 7 changed some things that are too obscure for me to figure out. However The Maxifier works very well for this purpose. I suggest you give it a try!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2010, 8:17 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
Blahman wrote:
I think Windows 7 changed some things that are too obscure for me to figure out. However The Maxifier works very well for this purpose. I suggest you give it a try!


Thank you for the advice...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 7:13 am 
Offline

Joined: October 5th, 2008, 9:28 pm
Posts: 2
this script looks great, but I seem to be having some trouble with it. When I mute Media Center it still mutes system volume.

that's the only feature I'm really looking for. Is it possible to pull that functionality out of the rest of the script (have a hotkey to just mute WMC)? Also, is it possible to have that functionality without the volume mixer open? (or at least is there a way to hide the volume mixer, even if it is open?)

THANKS!

Legatic


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 7:34 am 
Offline

Joined: November 9th, 2008, 7:48 pm
Posts: 25
legatic wrote:
this script looks great, but I seem to be having some trouble with it. When I mute Media Center it still mutes system volume.

that's the only feature I'm really looking for. Is it possible to pull that functionality out of the rest of the script (have a hotkey to just mute WMC)? Also, is it possible to have that functionality without the volume mixer open? (or at least is there a way to hide the volume mixer, even if it is open?)

THANKS!

Legatic


This is the best I can do, unfortunately AFAIK MS does not expose the Volume Mixer functions to COM or anything.

Code:
#Persistent
#SingleInstance, Force
SetDefaultMouseSpeed, 0
CoordMode, Mouse, Screen

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
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%
Gosub, MouseHideOff
Goto WaitForWMC
return

; Mutes Windows Media Center independently using the 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 7:31 am 
Offline

Joined: February 28th, 2010, 7:23 am
Posts: 1
Hi,

I just discovered this forum and read this thread. I use Vista with Media Center and I would like to have the features showed in your script but have no idea how to use this script? Would you have a clue for me please?

Thanks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo and 11 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