我在工作时在 Windows 7 机器上安装了双显示器。我想知道如何(如果可能的话)设置热角来启动屏幕保护程序或使显示器进入睡眠状态?
答案1
实际上,Windows 屏幕保护程序做过具有此功能(至少是作为 Plus!包的一部分包含的功能,老前辈应该记得):
的确,一个非常有用的 bug将为 Plus! 屏幕保护程序指定的热点角设为全局设置,该设置同样适用于非 Plus! 屏幕保护程序!
现在在 Windows 中获取类似功能的最简单方法可能是使用 AutoIT 应用程序(来源可用),毫不奇怪,热点角除了启动屏幕保护程序之外,它还可以做其他一些有趣的事情:
答案2
这是我编写的 hotcorners 应用程序,希望你喜欢!我也在 github 上发布了源代码。
详细信息请参阅: https://sites.google.com/site/bytecar/home/hotcornersapp
快乐黑客!
答案3
如果有人感兴趣的话,这是我的快速 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()
答案4
我使用——并且我推荐使用——AutoIT 的 HotCorners(或 Mr Lekrem Yelsew 的变体,HotCorners 2)。它不完全是“Screener”(旧版 Mac OS),但它可以完成它应该做的事情,并且“在要求时退出”(即,从由其中一个“角落”设置的状态恢复工作没有任何延迟)。
苯并噻嗪