Windows OS的电源选项或注册表中的屏幕唤醒设置?

时间:2019-02-25 12:43:17

标签: windows powershell registry screen

有什么方法可以在指定时间后唤醒屏幕吗?我找到了一个可以启用或禁用或仅重要唤醒时间的选项。有什么方法可以指定屏幕唤醒的时间。enter image description here

任何帮助请。如果有任何机会通过Powershell或其他脚本编写也可以。

{{powercfg.exe -change -monitor-timeout-dc 1
 powercfg.exe -change -monitor-timeout-ac 1

像这样,我想通过powershell进行任何更改。

1 个答案:

答案 0 :(得分:0)

Powershell脚本可在特定时间唤醒监视器。在Windows 10上进行了测试

$Signature = @"
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll")]
public static extern void mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 dwData, UIntPtr dwExtraInfo);
"@

Try {
$ShowWindowAsync = Add-Type -MemberDefinition $Signature -Name "Win32ShowWindowAsync" -Namespace Win32Functions -PassThru -ErrorAction Ignore }
Catch { }

$MONITOR_ON = -1;
$MONITOR_OFF = 2;
$MONITOR_STANBY = 1;

[datetime]$WakeUpTime = "02-26-2019 09:40:00 PM" # Set your Wakeup time MM/dd/yyyy hh:mm:ss"

[System.Int64]$MOUSEEVENTF_MOVE = 0x0001;

[System.IntPtr]$HWND_BROADCAST = New-Object System.IntPtr(0xffff)
[System.UInt32]$WM_SYSCOMMAND = 0x0112
[System.IntPtr]$SC_MONITORPOWER = New-Object System.IntPtr(0xF170)

$ShowWindowAsync::SendMessage($HWND_BROADCAST, $WM_SYSCOMMAND, $SC_MONITORPOWER, [System.IntPtr]$MONITOR_OFF);

$Wait = $true

While($Wait)
{
    If((Get-Date) -ge $WakeUpTime)
    {
        $ShowWindowAsync::mouse_event($MOUSEEVENTF_MOVE, 0, 1, 0, [System.UIntPtr]::Zero);
        $wait = $false
    }
}