文章来源:http://blog.csdn.net/zzxxbb112/archive/2009/12/18/5030265.aspx
Google Earth相信大家都非常熟悉了,也经常会使用它,但是大家有没有想过来自动化Google Earth呢,今天我们就来使用QTP通过调用Google Earth的API来自动化Google Earth。在自动化Google Earth之前有几个必要条件需要达成,以下是ADVANCEDQTP上提供的脚本。大家可以试着跑一下,挺有意思的。
安装QTP
Web + ActiveX 插件加载
必须安装Google核心插件:http://code.google.com/intl/zh-CN/apis/earth/
熟悉Google Earth API
此Demo只适合浏览器中嵌入式的Google Earth
此Demo将改变视图类型并定位在纽约的时代广场
Const URL = "http://earth-api-samples.googlecode.com/svn/trunk/demos/kmlplayground/index.html"
Const SW_MAXIMIZED = 3
' *****************关闭所有窗口和打开并跳转URL ***********************
SystemUtil.CloseProcessByName "iexplore.exe"
SystemUtil.Run "iexplore.exe", URL, "", "open", SW_MAXIMIZED
Browser("CreationTime:=0").Page("index:=0").Sync
Set objActiveX = Browser("CreationTime:=0").Page("index:=0")._
ActiveX("progid:=GEPluginCoClass.GEPluginCoClass.1.0", "location:=0").Object
' ****************设置变量的值***********************
ALTITUDE_ABSOLUTE = objActiveX.ALTITUDE_ABSOLUTE
VISIBILITY_SHOW = objActiveX.VISIBILITY_SHOW
ALTITUDE_RELATIVE_TO_GROUND = objActiveX.ALTITUDE_RELATIVE_TO_GROUND
MAP_TYPE_EARTH = objActiveX.MAP_TYPE_EARTH
MAP_TYPE_SKY = objActiveX.MAP_TYPE_SKY
SPEED_TELEPORT = objActiveX.SPEED_TELEPORT
wait 2
' ***************切换到天空视图 *****************
Set geOptions = objActiveX.getOptions()
Call geOptions.setMapType( MAP_TYPE_SKY )
wait 5
' ******************切换地球视图 *******************
Call geOptions.setMapType( MAP_TYPE_EARTH )
' Setting to Minimum zoom at max speed
geOptions.setFlyToSpeed( SPEED_TELEPORT )
Set kmlLookAt = objActiveX.getView().copyAsLookAt( ALTITUDE_ABSOLUTE )
kmlLookAt.setRange(50000000)
objActiveX.getView().setAbstractView(kmlLookAt)
wait 2
' ******************增加虚拟控件 *********************
geOptions.setGridVisibility( true )
geOptions.setStatusBarVisibility(true)
geOptions.setScaleLegendVisibility( true )
geOptions.setMouseNavigationEnabled( true )
geOptions.setOverviewMapVisibility( true )
' *******************检索导航控制 *******************
Set geNavigationControl = objActiveX.getNavigationControl()
geNavigationControl.setVisibility( VISIBILITY_SHOW )
Set geView = objActiveX.getView()
Set kmlLookAt = geView.copyAsLookAt( ALTITUDE_RELATIVE_TO_GROUND )
' ******************** 设置一些参数 *******************
geOptions.setFlyToSpeed(0.5)
kmlLookAt.setTilt(0)
kmlLookAt.setHeading(0)
' Times Square, New York, NY
kmlLookAt.setLatitude( 40.7594 )
kmlLookAt.setLongitude( -73.985 )
' setting new values
objActiveX.getView().setAbstractView(kmlLookAt)
'*******************放大 ******************
For i = 1 to 17
kmlLookAt.setRange(kmlLookAt.getRange() * 0.5)
objActiveX.getView().setAbstractView(kmlLookAt)
Wait 1
Next
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zzxxbb112/archive/2009/12/18/5030265.aspx