我在Windows 7机器上安装了双显示器。我想知道如何(如果可能)设置一个热角来启动屏幕保护程序或使显示器进入睡眠状态?
我在Windows 7机器上安装了双显示器。我想知道如何(如果可能)设置一个热角来启动屏幕保护程序或使显示器进入睡眠状态?
Answers:
实际上,Windows屏幕保护程序确实具有此功能(至少那些作为Plus!包的一部分包含的功能,旧用户应该记住):
确实,一个非常有用的错误使Plus指定了热点!屏幕保护程序适用于非Plus的全局设置!屏保也一样!
现在,在Windows中获得类似功能的最简单方法可能是使用一个名为Hot Corners的AutoIT应用程序(可提供源)。除了启动屏幕保护程序,它还可以做其他有趣的事情:
这是我写的hotcorners应用程序,希望您喜欢!我还在github上发布了源代码。
可以在以下位置找到详细信息:https : //sites.google.com/site/bytecar/home/hotcornersapp
快乐黑客!
如果有人对此感兴趣,这是我的quickie PowerShell版本(无耻博客帖子插件)(或GitHub)
该代码监视鼠标在特定位置(当前位于右下角),然后触发Win32监视器关闭API ...它显示任务栏图标作为可见的运行指示器以及上下文菜单以结束执行
不幸的是,我太绿了,无法发布屏幕截图...现在请参阅github链接以获取可靠的信息
# 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()
我使用-并且建议使用-AutoIT的HotCorners(或Lekrem Yelsew先生的版本HotCorners 2)。它不是完全“ Screener”(传统的Mac OS),但它可以实现预期的功能,并“在被询问时退出”(即,从“角落”之一设置的状态恢复正常运行没有延迟)。
百事通