sotwocold
V2EX  ›  Windows

PowerShell 脚本使用浏览网页的方式测试电池电量

  •  
  •   sotwocold · Jun 30, 2015 · 3196 views
    This topic created in 3997 days ago, the information mentioned may be changed or developed.

    概念:
    http://blog.laptopmag.com/improving-tests

    Battery Life
    The Laptop Mag battery test replicates continuous web surfing over Wi-Fi until the battery is completely drained. Starting with a full battery, a notebook/tablet/smartphone runs a script that visits 50 popular web sites in a loop, pausing for 30 seconds on each, then closing and reopening the native browser with the next page. The settings are tweaked to prevent the device from entering standby mode or going into hibernation.

    脚本

    $times = Read-Host "输入循环次数"
    [String]$website1 = Read-Host "输入一个网页"
    [String]$website2 = Read-Host "输入一个网页"
    [String]$website3 = Read-Host "输入一个网页"
    [String]$website4 = Read-Host "输入一个网页"
    [String]$website5 = Read-Host "输入一个网页"

    For loop

    For ($i=0;$i –lt $times;$i++) {
    #do something

    & 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' -k $website1
    sleep 10
    [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
    [System.Windows.Forms.SendKeys]::SendWait("{PGDN}")
    stop-process -processname iexplore
    
    & 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' -k $website2
    sleep 10
    [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
    [System.Windows.Forms.SendKeys]::SendWait("{PGDN}")
    stop-process -processname iexplore
    
    & 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' -k $website3
    sleep 10
    [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
    [System.Windows.Forms.SendKeys]::SendWait("{PGDN}")
    stop-process -processname iexplore
    
    & 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' -k $website4
    sleep 10
    [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
    [System.Windows.Forms.SendKeys]::SendWait("{PGDN}")
    stop-process -processname iexplore
    
    & 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' -k $website5
    sleep 10
    [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
    [System.Windows.Forms.SendKeys]::SendWait("{PGDN}")
    stop-process -processname iexplore
    

    }

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1029 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:31 · PVG 06:31 · LAX 15:31 · JFK 18:31
    ♥ Do have faith in what you're doing.