AutoHotkey Community

It is currently May 27th, 2012, 1:27 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: March 7th, 2009, 1:47 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
COMPATIBILITY: AutoHotkey 1.0.48.05 (AHK Basic)

As the title says. This has been a longstanding annoying issue for me.
Having a dual-view setup (2 x 15" CRT monitors) and watching a fullscreen movie on my second monitor, the primary one was always staring at me, almost screaming: "I'm useless, shut me down!" But couldn't do that since at times I needed to pause video and run some app (subtitle sync, etc).

I thought about sending a blank message to that monitor, but it wouldn't work; both monitors would blank out at the same time. So yesterday I finally gathered my guts and put up this ugly but working code. What it does is simple: detect the monitor with fullscreen video and blank the other one by showing a fullscreen black GUI.

It will immediately disable the blank when the player is not in fullscreen anymore or is not the active window (say, we clicked the blank screen).

The script was initially created for GOMPlayer but later on I put the relevant info into variables so they can easily be changed to the player of your choice. I believe it can even work for fullscreen games, but I haven't tested under those circumstances.

Please test the script and provide feedback. Enjoy!
Code:
PClass = ahk_class GomPlayer1.x   ; replace with your player's class
PText = GomVideo            ; replace with your player window's text
; *****************************************
Gui, -0xC00000 +0x8000000
Gui, Color, Black

start:
WinWaitActive, %PClass%, %PText%
Gui, +AlwaysOnTop
WinGetPos, plX, plY, plW, plH, %PClass%,,,
SysGet, mon, 80   ; get monitor count
Loop, %mon%
   {
   SysGet, scr%A_Index%, Monitor, %A_Index%
   coordX := scr%A_Index%Left - plX
   coordY := scr%A_Index%Top - plY
   coordW := plX + plW - scr%A_Index%Right
   coordH := plH - plY - scr%A_Index%Bottom
   if (coordX = coordY = coordW = coordH) && coordX >= 0
      {
      Loop, %mon%
         {
         scL := scr%A_Index%Left
         scW := scr%A_Index%Right - scr%A_Index%Left
         scH := scr%A_Index%Bottom - scr%A_Index%Top
         if scL - plX < 0
            Gui, Show, x%scL% y0 w%scW% h%scH%
         }
      break
      }
   }
WinActivate, %PClass%
Sleep, 1
WinWaitNotActive, %PClass%, %PText%
Gui, -AlwaysOnTop
Gui, Hide
goto start


P.S. I know that start: <-> goto start can be replaced with a loop, thus offering the possibility to exit the script through a hotkey, but I didn't fiddle much with the script once I got it working, especially being ill at the moment. However, any improvement ideas are welcome.

P.P.S. It's only been tested under Win98SE since I got no other multi-monitor environment at hand. I'd love to hear from Win2000/XP/Vista/7 users.

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon 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