Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Netflix Silverlight Screen Saver Disabler


  • Please log in to reply
7 replies to this topic
Lafncow
  • Guests
  • Last active:
  • Joined: --
This turns the screen saver off when you watch a Netflix streaming movie, then turns it back on when you're done. Fall asleep while watching? No prob, it bumps the screen saver back on after 2.5 hours! Does exactly what MS should have done in the first place! ;)
Should work with any browser.

Pretty simple stuff, lifted the real goods from SKAN (thank you!) ( http://www.autohotke... ... 7049#67049 )

Enjoy!

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Menu, Tray, Icon, User32.dll, 7
Loop
{
WinWaitActive, Netflix: Netflix Movie Viewer
{
	Gosub, Netfix
}

WinWaitNotActive, Netflix: Netflix Movie Viewer
{
	Gosub, ScreenSaveActivate
}
}

Netfix:
Menu, Tray, Icon, User32.dll, 2
TrayTip, Netfix, Screen Saver Disabled`, Enjoy The Show!, 10, 2
DllCall("SystemParametersInfo", Int,17, Int,0, UInt,NULL, Int,2) ;disable screensaver
SetTimer, CheckScreenSaveActive, 999
SetTimer, ScreenSaveActivate, -9000000 ;run only once
Return

CheckScreenSaveActive:
DllCall("SystemParametersInfo", Int,16, UInt,NULL, "UInt *",SSACTIVE, Int,0) ;check
If SSACTIVE
{
   DllCall("SystemParametersInfo", Int,17, Int,0, UInt,NULL, Int,2) ;disable
}
Return

ScreenSaveActivate:
Menu, Tray, Icon, User32.dll, 7
SetTimer, CheckScreenSaveActive, OFF
SetTimer, ScreenSaveActivate, OFF
DllCall("SystemParametersInfo", Int,17, Int,1, UInt,NULL, Int,2) ;enable
TrayTip, Netxfix, Screen Saver Enabled!, 10, 1
Return

OnExit, ExitSub

ExitSub:
Gosub, ScreenSaveActivate
ExitApp


TheIrishThug
  • Members
  • 419 posts
  • Last active: Jan 18 2012 02:51 PM
  • Joined: 19 Mar 2006
The way you wrote it, you are going to do the Netflix many many times while you are watching the movie. I added a variable to save the state so there is much less excess work. I also used a timer instead of a never ending loop, again it means less work (and I think it looks cleaner). I made the sleep timer a variable so that it is easier to change if need be. If you do have the screen saver activated by the sleep timer, you will need to reset the state with the hotkey when you wake up.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

windowsState := 0
sleepDelay := 150 ; mins
Menu, Tray, Icon, user32.dll, 7
SetTimer, CheckWindowsState, 1000
OnExit, ExitSub

;reset the window state after the sleep timer hits.
^#R::windowsState := 0

CheckWindowsState:
If (!windowsState && WinActive("Netflix: Netflix Movie Viewer"))
{
	windowsState := 1
	Menu, Tray, Icon, user32.dll, 2
	TrayTip, Netfix, Screen Saver Disabled`, Enjoy The Show!, 10, 2
	DllCall("SystemParametersInfo", Int,17, Int,0, UInt,NULL, Int,2) ;disable screensaver
	SetTimer, ScreenSaveActivate, % -sleepDelay * 60*1000 ;run only once
}
Else If (windowsState && !WinActive("Netflix: Netflix Movie Viewer"))
{
	windowsState := 0
	SetTimer, ScreenSaveActivate, -1 ; run sub and turn off the timer
}
Return

ScreenSaveActivate:
Menu, Tray, Icon, user32.dll, 7
DllCall("SystemParametersInfo", Int,17, Int,1, UInt,NULL, Int,2) ;enable screensaver
TrayTip, Netxfix, Screen Saver Enabled!, 10, 1
Return

ExitSub:
Gosub, ScreenSaveActivate
ExitApp


Lafncow
  • Guests
  • Last active:
  • Joined: --
Nice! Thank you, much cleaner. I had originally tried a similar approach but couldnt get it right so fell back on the dumb loop. While we're talking about things I did wrong... I wrote this in Win 7, however the user32.dll icon #7 doesnt exist in XP. Here's your rewrite plus the icon fix for XP. Cheers.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

windowsState := 0
sleepDelay := 150 ; mins
Menu, Tray, Icon, SHELL32.dll, 44
SetTimer, CheckWindowsState, 1000
OnExit, ExitSub

;reset the window state after the sleep timer hits.
^#R::windowsState := 0

CheckWindowsState:
If (!windowsState && WinActive("Netflix: Netflix Movie Viewer"))
{
   windowsState := 1
   Menu, Tray, Icon, user32.dll, 2
   TrayTip, Netfix, Screen Saver Disabled`, Enjoy The Show!, 10, 2
   DllCall("SystemParametersInfo", Int,17, Int,0, UInt,NULL, Int,2) ;disable screensaver
   SetTimer, ScreenSaveActivate, % -sleepDelay * 60*1000 ;run only once
}
Else If (windowsState && !WinActive("Netflix: Netflix Movie Viewer"))
{
   windowsState := 0
   SetTimer, ScreenSaveActivate, -1 ; run sub and turn off the timer
}
Return

ScreenSaveActivate:
Menu, Tray, Icon, SHELL32.dll, 44
DllCall("SystemParametersInfo", Int,17, Int,1, UInt,NULL, Int,2) ;enable screensaver
TrayTip, Netxfix, Screen Saver Enabled!, 10, 1
Return

ExitSub:
Gosub, ScreenSaveActivate
ExitApp


Lafncow
  • Members
  • 30 posts
  • Last active: Jan 31 2011 12:43 AM
  • Joined: 13 May 2009
I hadnt tested it yet, having done so now I think you need #Persistent in there to keep the script from ending (and dropping the timers). Also, I added the timer to timeout and made it just give the message box, that trips the checkwindowstate and lets your screensaver activate without being a totally annoyance on the off chance that you're still watching :) .
I think this is a keeper, anyone? Again big thanks to TheIrishThug for making this much more sensible & tidy.

Update: Tested in XP & Windows 7; success!
Solved previous issues of not detecting netflix's fullscreen mode and of not preventing monitor power down/sleep/standby mode. The fix for the 2nd issue comes from here. The fix for the first issue is admittedly still noob-ish since it simply looks for a "AGFullScreenWinClass" window concurrent with the netflix window and I doubt that ahk_class is unique to netflix. Unfortunately the fullscreen window is titleless. I'm certain there's a way to grab the unique ID of the AGFullScreenWinClass window opened by netflix, but I left it as is for the sake of simplicity & performance (ok, and a bit of laziness too) ...still it seems "false positives" would be very rare.
Anyway, enjoy!

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
ES_CONTINUOUS := 0x80000000
ES_DISPLAY_REQUIRED := 0x00000002
windowsState := 0
sleepDelay := 150 ; mins
Menu, Tray, Icon, SHELL32.dll, 44
SetTimer, CheckWindowsState, 1000
OnExit, ExitSub

CheckWindowsState:
If ((!windowsState && WinActive("Netflix: Netflix Movie Viewer")) || (!windowsState && WinExist("Netflix: Netflix Movie Viewer") && WinActive("ahk_class AGFullScreenWinClass")))
{
   windowsState := 1
   Menu, Tray, Icon, user32.dll, 2
   TrayTip, Netfix, Screen Saver Disabled`, Enjoy The Show!, 10, 2
   DllCall("SystemParametersInfo", Int,17, Int,0, UInt,NULL, Int,2) ;disable screensaver
   DllCall("SetThreadExecutionState", UInt, ES_CONTINUOUS + ES_DISPLAY_REQUIRED) ;prevent sleep
   SetTimer, NetflixTimeOut, % -sleepDelay * 60*1000 ;run only once
}
Else If ((windowsState && !WinActive("Netflix: Netflix Movie Viewer")) || (windowsState && !WinExist("Netflix: Netflix Movie Viewer")))
{
   SetTimer, ScreenSaveActivate, -1 ; run sub and turn off the timer
}
Return

ScreenSaveActivate:
Menu, Tray, Icon, SHELL32.dll, 44
TrayTip, Netfix, Screen Saver Enabled!, 10, 1
DllCall("SystemParametersInfo", Int,17, Int,1, UInt,NULL, Int,2) ;enable screensaver
DllCall("SetThreadExecutionState", UInt, ES_CONTINUOUS) ;enable sleep
SetTimer, NetflixTimeOut, OFF
windowsState := 0
Return

NetflixTimeOut:
MsgBox, Zzzzzzzz...
Return

ExitSub:
Gosub, ScreenSaveActivate
ExitApp


-tr
  • Guests
  • Last active:
  • Joined: --
Forgive me if this is a dumb question but what do we do with the script?

Valiant
  • Guests
  • Last active:
  • Joined: --

Forgive me if this is a dumb question but what do we do with the script?


I would also like to ask the dumb question. :?:

SheridanZhoy
  • Members
  • 1 posts
  • Last active: Jan 30 2013 04:10 AM
  • Joined: 30 Jan 2013

Forgive me if this is a dumb question but what do we do with the script?

I know this thread is quite old, but it's best not to leave these questions unanswered.

 

This is an AutoHotkey script. You will need to install AutoHotkey (http://l.autohotkey....y_L_Install.exe), copy the above script to a text editor, and save as *.ahk to run the script.



Linkz57
  • Members
  • 1 posts
  • Last active: May 31 2015 05:21 PM
  • Joined: 15 Jul 2014

I know this thread is even older, but I found this from Google, so odds are future folk might find it too.
 
My problem was twofold: Netflix and Amazon Prime. I've replaced the four instances of "Netflix: Netflix Movie Viewer" with "Microsoft Silverlight". I have contributed nothing else. All of the work has been done by much more talented people, namely Lafncow and TheIrishThug. Big thanks to both of you. This slightly altered version works with Amazon Prime Instant Streaming. Because of the super generic "Microsoft Silverlight" check, it'll probably also work on other things, probably even when you don't want it to.
 
The following code has been tested on Windows Server 2012r2 (essentially Win 8.1) running Silverlight 64-bit version 5.1.30214.0 inside of Firefox 30.0

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
ES_CONTINUOUS := 0x80000000
ES_DISPLAY_REQUIRED := 0x00000002
windowsState := 0
sleepDelay := 150 ; mins
Menu, Tray, Icon, SHELL32.dll, 44
SetTimer, CheckWindowsState, 1000
OnExit, ExitSub

CheckWindowsState:
If ((!windowsState && WinActive("Microsoft Silverlight")) || (!windowsState && WinExist("Microsoft Silverlight") && WinActive("ahk_class AGFullScreenWinClass")))
{
   windowsState := 1
   Menu, Tray, Icon, user32.dll, 2
   TrayTip, Netfix, Screen Saver Disabled`, Enjoy The Show!, 10, 2
   DllCall("SystemParametersInfo", Int,17, Int,0, UInt,NULL, Int,2) ;disable screensaver
   DllCall("SetThreadExecutionState", UInt, ES_CONTINUOUS + ES_DISPLAY_REQUIRED) ;prevent sleep
   SetTimer, NetflixTimeOut, % -sleepDelay * 60*1000 ;run only once
}
Else If ((windowsState && !WinActive("Microsoft Silverlight")) || (windowsState && !WinExist("Microsoft Silverlight")))
{
   SetTimer, ScreenSaveActivate, -1 ; run sub and turn off the timer
}
Return

ScreenSaveActivate:
Menu, Tray, Icon, SHELL32.dll, 44
TrayTip, Netfix, Screen Saver Enabled!, 10, 1
DllCall("SystemParametersInfo", Int,17, Int,1, UInt,NULL, Int,2) ;enable screensaver
DllCall("SetThreadExecutionState", UInt, ES_CONTINUOUS) ;enable sleep
SetTimer, NetflixTimeOut, OFF
windowsState := 0
Return

NetflixTimeOut:
MsgBox, Zzzzzzzz...
Return

ExitSub:
Gosub, ScreenSaveActivate
ExitApp