10

I have a dual monitor setup on my Windows 7 box at work. I'd like to know how (if possible) I can set a hot corner to start the screensaver or put the display to sleep?

12

Actually, Windows screensavers did have this feature (at least those included as part of the Plus! pack, which old-timers should remember):

1

Indeed, a really useful bug made the hot corners specified for Plus! screensavers a global setting that applied to non-Plus! screensavers as well!

The easiest way to get similar functionality in Windows now might be to use an AutoIT app (source available) called, not surprisingly, Hot Corners. It can also do various other interesting things besides launching the screensaver:

2

1
  • This doesn't seem to work on Windows 10, for the record. – Giacomo Lacava Jan 17 '18 at 22:53
3

Here is a hotcorners app that I wrote, hope you enjoy it! I have also released the source on github.

Details can be found on: https://sites.google.com/site/bytecar/home/hotcornersapp

Happy Hacking!

2
  • Unlike the accepted answer, this works fine with Windows 10 and multiple monitors too. Great job! For the record, I noticed that the last avalable build does not include a feature (monitor sleep) that was merged in Github, any chance you could update that? Thanks for the app again. – Giacomo Lacava Jan 17 '18 at 23:05
  • There are two outstanding issues, 1) Accidentally activating hotcorners while ingame 2) building merged sleep code (there seem to be some issues), Will work on these two and release by Jan 30th. – bytecar Jan 19 '18 at 3:41
2

Here's my quickie PowerShell version of this if anybody is interested (shameless blog post plug) (or GitHub)

this code watches for mouse in certain position (currently lower right corner) and then triggers Win32 monitor power-off API... it displays a task tray icon as a visible running indicator along with a context menu to end execution

unfortunately i'm too green to post screenshots... for now please refer to the github link for robust info

# Source: http://www.powershellmagazine.com/2013/07/18/pstip-how-to-switch-off-display-with-powershell/

# Turn display off by calling WindowsAPI.

# SendMessage(HWND_BROADCAST,WM_SYSCOMMAND, SC_MONITORPOWER, POWER_OFF)
# HWND_BROADCAST  0xffff
# WM_SYSCOMMAND   0x0112
# SC_MONITORPOWER 0xf170
# POWER_OFF       0x0002

Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;

namespace Utilities {
   public static class Display
   {
      [DllImport("user32.dll", CharSet = CharSet.Auto)]
      private static extern IntPtr SendMessage(
         IntPtr hWnd,
         UInt32 Msg,
         IntPtr wParam,
         IntPtr lParam
      );

      public static void PowerOff ()
      {
         SendMessage(
            (IntPtr)0xffff, // HWND_BROADCAST
            0x0112,         // WM_SYSCOMMAND
            (IntPtr)0xf170, // SC_MONITORPOWER
            (IntPtr)0x0002  // POWER_OFF
         );
      }
   }
}
'

Add-Type -AssemblyName System.Windows.Forms

$notifyIcon = New-Object System.Windows.Forms.NotifyIcon
$notifyIcon.Icon = New-Object System.Drawing.Icon "$(Split-Path -parent $PSCommandPath)\icon.ico"
$notifyIcon.Text = "Hot Corners"

$notifyIcon.add_MouseDown( { 
  if ($script:contextMenu.Visible) { $script:contextMenu.Hide(); return }
  if ($_.Button -ne [System.Windows.Forms.MouseButtons]::Left) {return}

  #from: http://stackoverflow.com/questions/21076156/how-would-one-attach-a-contextmenustrip-to-a-notifyicon
  #nugget: ContextMenu.Show() yields a known popup positioning bug... this trick leverages notifyIcons private method that properly handles positioning
  [System.Windows.Forms.NotifyIcon].GetMethod("ShowContextMenu", [System.Reflection.BindingFlags] "NonPublic, Instance").Invoke($script:notifyIcon, $null)
})

$contextMenu = New-Object System.Windows.Forms.ContextMenuStrip
$contextMenu.ShowImageMargin = $false
$notifyIcon.ContextMenuStrip = $contextMenu
$contextMenu.Items.Add( "E&xit", $null, { $notifyIcon.Visible = $false; [System.Windows.Forms.Application]::Exit() } ) | Out-Null
$contextMenu.Show(); $contextMenu.Hide() #just to initialize the window handle to give to $timer.SynchronizingObject below

$timer = New-Object System.Timers.Timer
$timer.Interval = 500
$timer.add_Elapsed({
  $mouse = [System.Windows.Forms.Cursor]::Position
  $bounds = [System.Windows.Forms.Screen]::FromPoint($mouse).Bounds #thank you! - http://stackoverflow.com/questions/26402955/finding-monitor-screen-on-which-mouse-pointer-is-present

  <#    __  __              _          __  __            __              ____
       / / / /__  ________ ( )_____   / /_/ /_  ___     / /_  ___  ___  / __/
      / /_/ / _ \/ ___/ _ \|// ___/  / __/ __ \/ _ \   / __ \/ _ \/ _ \/ /_  
     / __  /  __/ /  /  __/ (__  )  / /_/ / / /  __/  / /_/ /  __/  __/ __/  
    /_/ /_/\___/_/   \___/ /____/   \__/_/ /_/\___/  /_.___/\___/\___/_/     #>
  # currently set to trigger at lower right corner... season to your own taste (e.g. upper left = 0,0)
  if ($mouse.X-$bounds.X -gt $bounds.Width-10 -and $mouse.Y -gt $bounds.Height-10) { [Utilities.Display]::PowerOff() }

  #run the ps1 from command line to see this output
  #debug: Write-Host "x: $($mouse.X), y:$($mouse.Y), width: $($bounds.Width), height: $($bounds.Height), sleep: $($mouse.X-$bounds.X -gt $bounds.Width-10 -and $mouse.Y -gt $bounds.Height-10)"
})

#frugally reusing $contextMenu vs firing up another blank form, not really necessary but i was curious if it'd work... the notify icon itself does not implement InvokeRequired
#see this for why SynchronizingObject is necessary: http://stackoverflow.com/questions/15505812/why-dont-add-eventname-work-with-timer
$timer.SynchronizingObject = $contextMenu

$timer.start()
$notifyIcon.Visible = $true
[System.Windows.Forms.Application]::Run()
0
0

I use -- and I recommend using -- AutoIT's HotCorners (or Mr Lekrem Yelsew's variation, HotCorners 2). It's not quite "Screener" (legacy Mac OS), but it does what it's supposed to, and "exits when asked" (ie, there's no delay in getting back to business from a state set by one of the 'corners.')

BZT

1
  • 1
    Thanks for the info. If you could please include links to the programs you are talking about, that would be greatly appreciated. – CyberSkull Apr 10 '13 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.