Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Screen Off - Dim v1.1


  • Please log in to reply
5 replies to this topic
evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
An update of my old script to manage the screen/monitor in a similar way to a screensaver:

; SCREEN OFF - DIM
;
; - Automatically dims the screen after 5 mins (default - see "Idle_Time_Before_Dimming")
; - Alt+B toggles dimming the background - useful if watching a video and don't want to make it fullscreen.
; - Ctrl+Alt+Z - turns the screen off (requires left click/Spacebar/Esc/or several seconds of mouse movement to break)


DOWNLOAD LINK


Credit to SlimlinE for his Nice But Dim! script which inspired these additions.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
I have made a few small changes to your code. This is my first post here. I have made it so that you can keep it running All the time without consuming too many resources. I have gotten rid of the long Sleep.

Thank you for this nice script!

#NoTrayIcon
Return

CheckMouseMoved:
   MouseGetPos, xMouseNow, yMouseNow
   If ( ( xMouseNow != xMouse ) or ( yMouseNow != yMouse ) )
      {
      xMouseChange := ( xMouseNow - xMouse ) * ( xMouseNow - xMouse ) ;squared to always be positive values
      yMouseChange := ( yMouseNow - yMouse ) * ( yMouseNow - yMouse )
      If ( ( xMouseChange > 100 ) or ( yMouseChange > 100 ) ) ;sqrt of 100 = 10 pixels of movement
         {
         Gosub, AbortPrompt
         }
      If ( KeepItOn != 1 )
         {
            GoSub, TurnMonitorOff
            SetTimer, CheckMouseMoved, 500
         }
      }
Return



TurnMonitorOff:
   SendMessage, 0x112, 0xF170, 2,, Program Manager  ; Turn Monitor Off
   MouseGetPos, xMouse, yMouse
   MouseGetPos, xMouseNow, yMouseNow
Return



AbortPrompt:
   KeepItOn = 0
   MsgBox,, ABORT?, Press OK to keep screen on:, 5
      IfMsgBox, OK
         {
            KeepItOn = 1
            SetTimer, CheckMouseMoved, Off
         }
Return 

^!z::
   Gosub, AbortPrompt
   SetTimer, CheckMouseMoved, 500
   Gosub, TurnMonitorOff
Return

^+!z::
   ExitApp


evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Edit: Replaced with new version above.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Posted a completely reworked version in the 1st post with a couple of additions - it was one of those scripts that I used several times a day on my laptop to save the screen from a bit of wear and tear, so was long overdue a reworking considering it was one of my first scripts.

Smurth
  • Members
  • 120 posts
  • Last active: Feb 23 2014 09:58 PM
  • Joined: 13 Dec 2006
To turn off monitor, it would be most "in the right way" to broadcast the message to all the windows, like this:
SendMessage, 0x112, 0xF170, 2,,ahk_id 0xFFFF
This way, people using alternative shell can use it, too.

bengo
  • Guests
  • Last active:
  • Joined: --
diming of the background doesn't work, it only freeze.