V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
jsjcjsjc
V2EX  ›  问与答

win 笔记本有办法只有链接外部显示器,合上才不休眠吗?

  •  
  •   jsjcjsjc · 2023-04-07 22:11:26 +08:00 · 1147 次点击
    这是一个创建于 589 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前的设置是,不管是否连接显示器,合上都不休眠...有办法只有链接外部显示器,合上才不休眠吗?
    9 条回复    2023-04-09 10:45:31 +08:00
    DemianL
        1
    DemianL  
       2023-04-07 22:14:11 +08:00 via Android
    emmm 系统设置里面有个合上盖子的选项 你可以选择什么都不做它就不休眠了...
    FlyPuff
        2
    FlyPuff  
       2023-04-07 22:24:13 +08:00 via Android
    新电脑么?现在的新电脑都是只支持合盖现代(关屏幕)休眠了吧。。
    jsjcjsjc
        3
    jsjcjsjc  
    OP
       2023-04-07 23:34:31 +08:00
    @DemianL 关键是我想考虑链接外部显示器的问题~~
    ysc3839
        4
    ysc3839  
       2023-04-08 01:04:48 +08:00 via Android
    推荐一下自己开发的项目 https://github.com/ysc3839/ProjectionAwake
    ISVStar
        5
    ISVStar  
       2023-04-08 04:00:50 +08:00   ❤️ 1
    我写了一个这样的 PowerShell 脚本,不完全符合你的要求。运行脚本后,忽略下一次合盖睡眠。

    # grab powercfg guids necessary for lid switch action
    # https://docs.microsoft.com/en-us/windows-hardware/customize/power-settings/power-button-and-lid-settings-lid-switch-close-action

    #capture the active scheme GUID
    $activeScheme = cmd /c "powercfg /getactivescheme"
    $regEx = '(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}'
    $asGuid = [regex]::Match($activeScheme,$regEx).Value

    #relative GUIDs for Lid Close settings
    $pwrGuid = '4f971e89-eebd-4455-a8de-9e59040e7347'
    $lidClosedGuid = '5ca83367-6e45-459f-a27b-476b1d01c936'

    # DC Value // On Battery // 0 = do nothing
    cmd /c "powercfg /setdcvalueindex $asGuid $pwrGuid $lidClosedGuid 0"
    # AC Value // While plugged in // 0 = do nothing
    cmd /c "powercfg /setacvalueindex $asGuid $pwrGuid $lidClosedGuid 0"

    #apply settings
    cmd /c "powercfg /s $asGuid"

    echo "You can now close the lid ..."
    $ScreenCount = (Get-CimInstance -Namespace root\wmi -ClassName wmiMonitorID | Measure-Object).Count
    Do
    {
    $ScreenCountRecur = (Get-CimInstance -Namespace root\wmi -ClassName wmiMonitorID | Measure-Object).Count
    Start-Sleep -Seconds 1
    }
    While($ScreenCountRecur -ge $ScreenCount)

    # DC Value // On Battery // 1 = sleep
    cmd /c "powercfg /setdcvalueindex $asGuid $pwrGuid $lidClosedGuid 1"
    # AC Value // While plugged in // 1 = sleep
    cmd /c "powercfg /setacvalueindex $asGuid $pwrGuid $lidClosedGuid 1"
    ISVStar
        6
    ISVStar  
       2023-04-08 04:02:19 +08:00   ❤️ 1
    #capture the active scheme GUID

    $activeScheme = cmd /c "powercfg /getactivescheme"

    $regEx = '(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}'

    $asGuid = [regex]::Match($activeScheme,$regEx).Value



    #relative GUIDs for Lid Close settings

    $pwrGuid = '4f971e89-eebd-4455-a8de-9e59040e7347'

    $lidClosedGuid = '5ca83367-6e45-459f-a27b-476b1d01c936'



    # DC Value // On Battery // 0 = do nothing

    cmd /c "powercfg /setdcvalueindex $asGuid $pwrGuid $lidClosedGuid 0"

    # AC Value // While plugged in // 0 = do nothing

    cmd /c "powercfg /setacvalueindex $asGuid $pwrGuid $lidClosedGuid 0"



    #apply settings

    cmd /c "powercfg /s $asGuid"



    echo "You can now close the lid ..."

    $ScreenCount = (Get-CimInstance -Namespace root\wmi -ClassName wmiMonitorID | Measure-Object).Count

    Do

    {

    $ScreenCountRecur = (Get-CimInstance -Namespace root\wmi -ClassName wmiMonitorID | Measure-Object).Count

    Start-Sleep -Seconds 1

    }

    While($ScreenCountRecur -ge $ScreenCount)



    # DC Value // On Battery // 1 = sleep

    cmd /c "powercfg /setdcvalueindex $asGuid $pwrGuid $lidClosedGuid 1"

    # AC Value // While plugged in // 1 = sleep

    cmd /c "powercfg /setacvalueindex $asGuid $pwrGuid $lidClosedGuid 1"
    jsjcjsjc
        7
    jsjcjsjc  
    OP
       2023-04-08 11:10:15 +08:00
    @ISVStar 感谢大佬哈
    yinmin
        8
    yinmin  
       2023-04-08 17:23:26 +08:00
    换一个思路:笔记本插上电源时,合上电脑不休眠;如果用上电池,合上电脑才休眠。这种场景是不是可以满足你大多数的场景?

    根据插电源来判断,在 windows 设置里可以配置。
    jsjcjsjc
        9
    jsjcjsjc  
    OP
       2023-04-09 10:45:31 +08:00
    @yinmin 目前已经是这么设置的了,感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2207 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 01:35 · PVG 09:35 · LAX 17:35 · JFK 20:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.