V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sotwocold
V2EX  ›  Windows

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

  •  
  •   sotwocold · 2015-06-30 11:46:22 +08:00 · 2470 次点击
    这是一个创建于 3469 天前的主题,其中的信息可能已经有所发展或是发生改变。

    概念:
    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
    

    }

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1044 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 19:22 · PVG 03:22 · LAX 11:22 · JFK 14:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.