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

2015-06-30 11:46:22 +08:00
 sotwocold

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

}

2360 次点击
所在节点    Windows
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/202119

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX