??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品久久网午夜,久久影视综合亚洲,亚洲国产精品不卡在线电影http://www.tkk7.com/joan/category/32987.htmlUは张で QQ:774199038 zh-cnFri, 20 Aug 2010 02:13:13 GMTFri, 20 Aug 2010 02:13:13 GMT60自动化测试中如何利用WMI http://www.tkk7.com/joan/articles/329360.htmljoanjoanThu, 19 Aug 2010 06:34:00 GMThttp://www.tkk7.com/joan/articles/329360.htmlhttp://www.tkk7.com/joan/comments/329360.htmlhttp://www.tkk7.com/joan/articles/329360.html#Feedback0http://www.tkk7.com/joan/comments/commentRss/329360.htmlhttp://www.tkk7.com/joan/services/trackbacks/329360.htmlWindows理规范Q是用户理本地和远E计机的一U模型。通过它可以访问、配|、管理和监视几乎所有的 Windows 资源。WMI的语法十分简单,基本上常见的命名I间、对象等用几乎一模一栗它对应的是Windows里的WMI服务QwinmgmtQ?

  WMI实际是由两部分组成:(x)CIM库和W(xu)MI脚本对象库。在具体使用q程中,我们是通过WMI脚本对象库去讉KCIM库,理托管的资源。也是_(d)在我们编写脚本的q程大致可以分ؓ(f)q么几步Q?/p>

  1Q创建WMI对象脚本库的指针实例Q?/p>

  2Q调用其实例的方法,q接到CIM库,q指明需要访问的资源的逻辑位置Q?/p>

  3Q获得托资源也是cȝ实例的集合;

  4Q枚丑֮例,完成工作

  WMI的命名空间共?6个,不过我们常用的只有两个:(x)

  1Qroot\cimv2  在这个命名空间里包括?jin)绝大多C计算机、操作系l相兌的类?/p>

  2Qroot\default  理注册表的c?/p>

  l出两个实例参考:(x)

  在日志报告中记录机器的地址Q?/p>

 

Public Function GetIP()
 '获取机器的IP
  ComputerName="."
  Dim objWMIService,colItems,objItem,objAddress
 Set ōbjWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
  Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
 For Each objItem in colItems
     For Each objAddress in objItem.IPAddress
         If objAddress <> "" Then
           GetIP = objAddress
           Exit Function
         End If
     Next
  Next
End Function

  如何在判断进E是否存在:(x)

Function ProcessExist(processName)
  For each Process in GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_process")
   If Process.Name = processName Then
     ProcessExist = True
     Exit Function
  End If
 Next
 ProcessExist = False
End Function

joan 2010-08-19 14:34 发表评论
]]>
遍历个h?sh)脑盘符信息脚?qtp) 原创http://www.tkk7.com/joan/articles/320136.htmljoanjoanWed, 05 May 2010 09:18:00 GMThttp://www.tkk7.com/joan/articles/320136.htmlhttp://www.tkk7.com/joan/comments/320136.htmlhttp://www.tkk7.com/joan/articles/320136.html#Feedback0http://www.tkk7.com/joan/comments/commentRss/320136.htmlhttp://www.tkk7.com/joan/services/trackbacks/320136.html

'Company: ××××
'''''''''''''''''''''''''''''''''''''''''''''''''''''

'自我学习(fn)pd

'Author: joan ''
'Product: Test
'Date: 2010.5.5

'''''''''''''''''''''''''''''''''''''''''''''''''''''


Function dirvesmsg
      msg = "驱动器名Uͼ(x)" & objDrive.DriveLetter & "   "
      msg =msg & "文gpȝ的类型:(x)" & objDrive.FileSystem &"  "
      msg = msg & "驱动器d量:(x)" & int(objDrive.TotalSize/(1024*1024*1024)) & "G "
      msg = msg & "剩余I间总量Q? & int(objDrive.FreeSpace/(1024*1024*1024)) & "G  "
      msgbox msg  '
End Function

 

' 创徏FileSystemObject对象
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 创徏Drives集合Qƈ赋值给colDrives
Set colDrives = objFSO.Drives
' 遍历Drives集合

For Each objDrive in colDrives
'判断驱动器是否已准备?br />  If objDrive.IsReady Then
      dirvesmsg  ' 调用  Function
  End If
Next
reporter.ReportEvent  micDone ,"遍历Drives集合",msg

详细内容原文我的QQ blog



joan 2010-05-05 17:18 发表评论
]]>
qtp 视频收藏http://www.tkk7.com/joan/articles/318524.htmljoanjoanFri, 16 Apr 2010 07:11:00 GMThttp://www.tkk7.com/joan/articles/318524.htmlhttp://www.tkk7.com/joan/comments/318524.htmlhttp://www.tkk7.com/joan/articles/318524.html#Feedback0http://www.tkk7.com/joan/comments/commentRss/318524.htmlhttp://www.tkk7.com/joan/services/trackbacks/318524.html 

1. 布作品QQTP培训pd - 1QTP的概q?br /> 在线观看Q?http://www.boobooke.com/v/bbk3207
视频下蝲Q?http://www.boobooke.com/v/bbk3207.zip
2. 布作品QQTP培训pd - 2
讲解?jin)QTP的测试规?br /> 在线观看Q?http://www.boobooke.com/v/bbk3302
视频下蝲Q?http://www.boobooke.com/v/bbk3302.zip
3. 布作品QQTP培训pd - 3
l箋(hu)介绍QTP的测试规?br /> 在线观看Q?http://www.boobooke.com/v/bbk3303
视频下蝲Q?http://www.boobooke.com/v/bbk3303.zip
4. 布作品QQTP培训pd - 4
QTP录制之前的注意要?br /> 在线观看Q?http://www.boobooke.com/v/bbk3307
视频下蝲Q?http://www.boobooke.com/v/bbk3307.zip
5. 布作品QQTP培训pd - 5
介绍QTP录制和回?br /> 在线观看Q?http://www.boobooke.com/v/bbk3308
视频下蝲Q?http://www.boobooke.com/v/bbk3308.zip
6. 布作品QQTP培训pd - 6
介绍QTP的对象库
在线观看Q?http://www.boobooke.com/v/bbk3309
视频下蝲Q?http://www.boobooke.com/v/bbk3309.zip
7. 布作品QQTP培训pd - 7
l箋(hu)介绍QTP的对象库
在线观看Q?http://www.boobooke.com/v/bbk3310
视频下蝲Q?http://www.boobooke.com/v/bbk3310.zip
8. 布作品QQTP培训pd - 8
介绍QTP的同步点
在线观看Q?http://www.boobooke.com/v/bbk3311
视频下蝲Q?http://www.boobooke.com/v/bbk3311.zip
9. 布作品QQTP培训pd - 9
介绍QTP的检查点
在线观看Q?http://www.boobooke.com/v/bbk3312
视频下蝲Q?http://www.boobooke.com/v/bbk3312.zip
10. 布作品QQTP培训pd - 10
l箋(hu)介绍QTP的检查点
在线观看Q?http://www.boobooke.com/v/bbk3313
视频下蝲Q?http://www.boobooke.com/v/bbk3313.zip



joan 2010-04-16 15:11 发表评论
]]>
谈Scripting.FileSystemObject对象http://www.tkk7.com/joan/articles/302720.htmljoanjoanTue, 17 Nov 2009 08:32:00 GMThttp://www.tkk7.com/joan/articles/302720.htmlhttp://www.tkk7.com/joan/comments/302720.htmlhttp://www.tkk7.com/joan/articles/302720.html#Feedback0http://www.tkk7.com/joan/comments/commentRss/302720.htmlhttp://www.tkk7.com/joan/services/trackbacks/302720.html谈Scripting.FileSystemObject对象
FileSystemObject对象提供对计机文gpȝ的访问,它允许我们在代码内操作文本文件、文件夹?qing)驱动器。它是脚本运行期库提供的对象之一Q对于服务器ASP面内的VBScript和JScript都有效。如果页面的扩展名ؓ(f).htaQ表C它们是HTA的一部分Q,它也可用在客L(fng)的IE 5中。本节仅讨论在服务器上的ASP脚本如何使用FileSystemObject对象?br />        文本应用E序QHTAQ由指定?#8220;受信ȝ”面l成Q在面?lt;HEAD>D里包含<HTA: APPLICATION>元素。例如:(x)
    <HTA:APPLICATION ID=”objMyApp” APPLICATIONNAME=”myApp”>
q些面可以使用客户端脚本引擎中的一些不常用Ҏ(gu),q些Ҏ(gu)中有FileSystemObject对象和TextStream对象。关于超U文本应用程序的更多信息Q请讉KMicrosoft Workshop|站?br /> 可以使用下面的程序创Z个FileSystemObject对象实例Q?br /> ‘ In VBScript:
Dim objMyFSO
Set objMyFSO = Server.CreateObject(“Scripting.FileSystemObject”)

// In JScript:
var objMyFSO = Server.CreateObject(‘Scripting.FileSystemObject’);

<!-- Server-side with an OBJECT element -->
<OBJECT RUNAT=”SERVER” SCOPE=”PAGE” ID=”objFSO”
              PROGID=”Scripting.FileSystemObject”>
</OBJECT>
在ASP面里,增加一个对于FileSystemObjectcd库的引用是非常有用的。这允许使用它直接定义的内置常数Q不用像q去那样用数字等效表辑ּ代替。整个脚本运行期库的cd库可以增加到MASP面中,代码如下Q?br /> <!-- METADATA TYPE=”typelib” FILE=”C:WinNTSystem32scrrun.dll” -->如果你是在另一个目录下安装WindowsQ必ȝ辑FILE的属性倹{?br /> 5.4.1 FileSystemObject对象成员概要
       FileSystemObject对象提供一个属性和一pdҎ(gu)Q可用它们来操纵FileSystemObject对象实现的一些从属对象。这里提供了(jin)全部的内Ҏ(gu)要,然后介绍每一个从属对象?br /> 1Q?nbsp; FileSystemObject的属?br /> FileSystemObject对象只有一个属性,它用于得到当前机器上的所有有效驱动器的列表,如表5-4所C:(x)
?-4  FileSystemObject对象的属性及(qing)说明
??
??

Drivers
q回本地计算机可用的驱动器列表?

2Q?nbsp; FileSystemObject的方?br /> FileSystemObject对象提供?jin)用从属对象的一pdҎ(gu)Q从属对象包括Drive、Folder和File{对象。它也实C(jin)用于TextStream对象的两个方法:(x)CreateTextFile和OpenTextFile。根据所使用的对象的cdQ将Ҏ(gu)划分ZcR?br /> (1)    与驱动器有关的方?br /> 与驱动器有关的方法如?-5所C:(x)
?-5 与驱动器有关的方法及(qing)说明
??
??

DriveExists(drivespec)
如果在drivespec中指定的驱动器存在,则返回TrueQ否则返回False。drivespec参数可以是一个驱动器字母Q或者是文g、文件夹的完整绝对\?

GetDrive(drivespec)
q回drivespec指定的驱动器所对应的Drive对象。drivespec可以包含冒号、\径分隔符或者是|络׃n名,卻I(x)“C”?#8220;C:”?#8220;C:”?#8220;\machinesharename”

GetDriveName(drivespec)
用字W串q回drivespec指定的驱动器的名U。drivespec参数必须是文件或文g夹的l对路径Q或者仅仅是驱动器字母,例如Q?#8220;c:”?#8220;c”

(2)    与文件夹有关的方?br /> 与文件夹有关的方法如?-6所C:(x)
?-6  与文件夹有关的方法及(qing)说明
??
??

BuildPath(path,name)
在已有的路径path上增d字ؓ(f)name的文件或文g夹,如果需要,则增添\径分隔符’’

CopyFolder(source,destination,overwrite)
从指定的源文件夹sourceQ可以包含通配W)(j)中复制一个或多个文g夹到指定的目标文件夹destinationQ包含了(jin)源文件夹中的所有文件。如果source包含通配W或destination末尾是\径分隔符(‘’)Q那么认为destination是要攄源文件夹的拷贝的文g夏V否则的话,认ؓ(f)destination是要创徏的新文g夹的路径名。如果destination文g夹已l存在且overwrite参数讄为FalseQ将产生错误Q缺省的overwrite参数是True

CreateFolder(foldername)
创徏一个\径名为foldername的文件夹。如果foldername已经存在生错?

DeleteFolder(folderspec,force)
删除由folderspec指定的一个或多个文g夹(可以在\径的最后部分包含通过配符Q及(qing)文g夹中的所有内宏V如果可选的force参数讄为trueQ那么即使文件夹包含的文件具有只d性,也将删除该文件夹。缺省的force参数是False

FolderExist(folderspec)
如果folderspec指定的文件夹存在则返回TrueQ否则返回False。folderspec参数可以包含文g夹的l对或相对\径,或者仅仅是当前文g夹中看到的文件夹?

GetAbsolutePathName(pathspec)
q回明确指定文g夹的路径Q其中要考虑到当前文件夹的\径。例如,如果当前文gҎ(gu)“c:docssales”Q而pathspec?#8220;jan”Q返回的字符?#8220;cocssalesjan”。通配W?#8221;..”?#8221;\”路径操作W都是可以接受的

GetFolder(folderspec)
q回folderspec指定的文件夹对应的Folder对象。folderspec可以是文件夹的相对的或绝对的路径

GetParentFolderName(pathspec)
q回pathspec文g或文件夹的上一U文件夹。不(g)验该文gҎ(gu)否存?

GetSpecialfolder(folderspec)
q回一个特定的Windows文g夹相对应的Folder对象。参数folderspec的允许值是WindowsFolder(0)、SystemFolder(1)和TemporaryFolder(2)

MoveFolder(source,destination)
source指定的一个或多个文g夹移动到destination指定的文件夹。在source里可以包含通配W,但在destination中不行。如果source包含通配W或destination末尾是\径分隔符(‘’)Q则认ؓ(f)destination是要攄源文件夹的文件夹Q否则认为它是一个新文g夹的完整路径和名字。如果目的文件夹destination已经存在则生错?

(3)    与文件有关的Ҏ(gu)
与文件有关的Ҏ(gu)如表5-7所C:(x)
??
??

CopyFile(source,destination,
overwrite)
sourceQ可包含通配W)(j)指定的一个或多个文g复制到指定的目标文g夹destination。如果source包含通配W或destination末尾是\径分隔符(‘’)Q那么认为destination是文件夹。否则认为destinationZ新文件的完全路径和名U。如果目标文件夹已经存在且overwrite参数讄为FalseQ将产生错误。缺省的overwrite参数是True

CreateTextFile(filename,overwrite,
unicode)
用指定的文g名filename在磁盘(sh)创徏一个新的文本文Ӟq返回与其对应的TextStream对象Q如果可选的overwrite参数讄为TrueQ则覆盖同一路径下已有的同名文g。缺省的overwrite参数是False。如果可选的unicode参数讄为TrueQ则该文件的内容存储ؓ(f)Unicode文本Q缺省的unicode参数是False

DeleFile(filespec,force)
删除由filespec指定的一个或多个文gQ可以在路径的最后部分包含通配W)(j)。如果可选的force参数讄为trueQ那么也删除h只读属性的文g。缺省的force参数是False

FileExists(filespec)
如果filespec指定的文件存在则q回TrueQ否则返回False。filespec参数可以包含文g的绝对\径或相对路径Q或者是当前文g夹中的文件名

GetBaseName(filespec)
q回filespec指定的文件的名称Q即包含文g路径但去掉了(jin)文g的扩展名

GetExtensionName(filespec)
q回filespec指定的文件的扩展?

GetFile(filespec)
q回filespec指定的文件所对应的File对象。可以指定文件的相对或绝对\?

GetFileName(pathspec)
q回pathspec指定的文件的路径或文件名Q如果没有文件名p回最后的文g夹名。不(g)查该文g或文件夹是否存在

GetTempName()
q回一个随Z生的文g名,用于完成q算所需的(f)时文件或文g?

MoveFile(source,destination)
source指定的一个或多个源文件移动到destination指定的目的文件夹。在source里可以包含通配W,但destination不行。如果source包含通过配符或destination末尾是\径分隔符(‘’)Q那么认为destination是一文g夏V否则,认ؓ(f)destination是一新文件夹的完整\径和名称。如果目的文件夹已经存在则生错?

OpenTextFile(filename,iomode,create,
    format)
创徏一个名叫做filename的文Ӟ或打开一个现有的名ؓ(f)filename的文Ӟq且q回一个与其相关的TextStream对象。filename参数可以包含l对或相对\径。iomode参数指定?jin)所要求的访问类型。允许的数值是ForReading(1)Q缺省)(j)、ForWriting(2)、ForAppending(8)。当写入或追加到一个不存在的文件时Q如果create参数讄为trueQ就创Z个新文g。缺省的create参数是False。format参数说明Ҏ(gu)件读或写的数据格式。允许数值是QTristatetFalse(0)Q缺省)(j)Q按照ASCII格式打开QTristatetTrue(-1)Q按照Unicode格式打开QTristateDefault(-2)Q用pȝ~省格式打开

       Unicode文g使用两个字节标识每个字符Q取消了(jin)ASCII字符最?56个的限制?/p>

5.4.2 使用驱动?br />        下面是用FileSystemObject对象的简单例子,它用DriveExistsҎ(gu)得到现有的驱动器字母的列表:(x)
       ‘ In VBScript
       Set objFSO = Server.CreateObject(“Scripting.FileSystemObject”)
       For intCode = 65 To 90                ‘ANSI codes for ‘A’ to ‘Z’
              strLetter = Chr(intCode)
              If objFSO.DriveExists(strLetter) Then
                     Response.Write “Found drive “ & strLetter & “:<BR>”
              End If
       Next
       或用JScriptQ?br />        // In Jscript
       var objFSO = Server.CreateObject(‘Scripting.FileSystemObject’);
       for (var intCode = 65; intCode <= 90; intCode++) {    //ANSI codes for ‘A’ to ‘Z’
              strLetter = String.formCharCode(intCode);
              If (objFSO.DriveExists(strLetter))
                     Response.Write (‘Found drive ‘ + strLetter + “:<BR>”);
       }
       q两个程序段的运行结果是相同的,如图5-9所C:(x)


       q一面为driveexists_vb.aspQ由本书的示例文件提供?br /> 1Q?nbsp; Drive对象
正如已经看到的,FileSystemObject对象包含一个属性——DrivesQ它q回一个包括本地计机上所有可用驱动器的集合?br /> Drives集合里的每个条目是一个Drive对象。Drive对象的属性如?-8所C:(x)
?-8  Drive对象的属性及(qing)说明
??
??

AvailableSpave
考虑?jin)帐户定额?或其他限Ӟq回驱动器上对于该用户可用的I间的大?

DriveLetter
q回驱动器的字母

DriveType
q回驱动器的cd。返回值可以是Unknown(0)、Removeable(1)、Fixed(2)、Network(3)、CDRom(4)和RamDisk(5)。然而需要注意的是当前版本的scrrun.dll不支持预定义常数NetworkQ必M用十q制3来代?

FileSystem
q回驱动器文件系l的cd。返回值包?#8220;FAT”?#8220;NTFS”?#8220;CDFS”

FreeSpace
q回驱动器上可用剩余I间的总量

IsReady
q回一个布?yu)(dng)D明驱动器是否已准备好

Path
q回一个由驱动器字母和冒号l成的驱动器路径Q即“C:”

RootFolder
q回代表的驱动器根目录文件夹的Folder对象

SerialNumber
q回一个用于识别磁盘卷的十q制的序列号

ShareName
如果是一个网l驱动器Q返回该驱动器的|络׃n?

TotalSize
q回驱动器的d量(以字节ؓ(f)单位Q?

VolumeName
讑֮或返回本地驱动器卷名

       因此Q通过使用Drives集合里的Drive对象Q可以在服务器上产生一个驱动器列表Q与通过(g)查每个可能的驱动器字母来判别驱动器是否存在的Ҏ(gu)相比Q效率更高。我们也可以得到关于该驱动器的信息。在VBScript里,代码如下Q?br /> ' In VBScript:
' create a FileSystemObject instance
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' create a Drives collection
Set colDrives = objFSO.Drives
' iterate through the Drives collection
For Each objDrive in colDrives

  Response.Write "DriveLetter: <B>" & objDrive.DriveLetter & "</B>   "
  Response.Write "DriveType: <B>" & objDrive.DriveType
  Select Case objDrive.DriveType
    Case 0: Response.Write " - (Unknown)"
    Case 1: Response.Write " - (Removable)"
    Case 2: Response.Write " - (Fixed)"
    Case 3: Response.Write " - (Network)"
    Case 4: Response.Write " - (CDRom)"
    Case 5: Response.Write " - (RamDisk)"
  End Select
  Response.Write "</B>   "

If objDrive.DriveType = 3 Then
    If objDrive.IsReady Then
      Response.Write "Remote drive with ShareName: <B>" & objDrive.ShareName & "</B>"
    Else
Response.Write "Remote drive - <B>IsReady</B> property returned_
<B>False</B><BR>"
    End If
  Else If objDrive.IsReady then
    Response.Write "FileSystem: <B>" & objDrive.FileSystem & "</B>   "
    Response.Write "SerialNumber: <B>" & objDrive.SerialNumber & "</B><BR>"
Response.Write "Local drive with VolumeName: <B>" & _
objDrive.VolumeName & "</B><BR>"
Response.Write "AvailableSpace: <B>" & FormatNumber( _
objDrive.AvailableSpace / 1024, 0) & "</B> KB   "
Response.Write "FreeSpace: <B>" & FormatNumber( _
objDrive.FreeSpace / 1024, 0) & "</B> KB   "
Response.Write "TotalSize: <B>" & FormatNumber(_
objDrive.TotalSize / 1024, 0) & "</B> KB"
  End if 
  Response.Write "<P>"
  End if
Next
       注意Q不能用预定义常数Network比较驱动器的DriveType属性,因ؓ(f)Q至在scrrun.dll的当前版本中Q在cd库中省略?jin)Network常数Q因此不再作为公用的常数使用?br /> 在JScript中,该程序是Q?br /> // In JScript:
// create a FileSystemObject instance
var objFSO = Server.CreateObject('Scripting.FileSystemObject');
// create a Drives collection
var colDrives = new Enumerator(objFSO.Drives);

for (; !colDrives.atEnd(); colDrives.moveNext()) {
  objDrive = colDrives.item();
  Response.Write('DriveLetter: ' + objDrive.DriveLetter + '<BR>');
  Response.Write('DriveType: ' + objDrive.DriveType + '<BR>');

  if (objDrive.DriveType == 3)
    if (objDrive.IsReady)
      Response.Write('Remote drive with ShareName: ' +
                     objDrive.ShareName + '<BR>')
    else
      Response.Write('Remote drive - IsReady property returned False<BR><BR>');
    else if (objDrive.IsReady) {
      Response.Write('Local drive with VolumeName: ' +
                    objDrive.VolumeName + '<BR>');
    Response.Write('FileSystem: ' + objDrive.FileSystem + '<BR>');
    Response.Write('SerialNumber: ' + objDrive.SerialNumber + '<BR>');
    Response.Write('AvailableSpace: ' + objDrive.AvailableSpace + ' bytes<BR>');
    Response.Write('FreeSpace: ' + objDrive.FreeSpace + ' bytes<BR>');
    Response.Write('TotalSize: ' + objDrive.TotalSize + ' bytes<P>');
}
}
       在系l上q行q段E序以前有一点要注意。如果在A驱动器里没有盘Q或CD-ROM驱动器里没有光盘Q将得到一个错误提C:(x)“Disk Not Ready”。除?jin)DriveLetter属性和DriveType属性外Q在使用其他属性和Ҏ(gu)前,通过(g)查每个驱动器的IsReady属性,可以保护该页面?br />        当在服务器上q行以上VBScript代码Ӟq行l果如图5-10所C。这一面为drivescollection_vb.aspQ来自本书提供的CZ文g?/p>

2Q?nbsp; 文gpȝ定位
FileSystemObject的几个方法可用于得到其他对象的引用,因此可以在服务器的文件系l和M|络驱动器中定位。事实上Q在ASP代码里用的所有对象或lg中,除了(jin)ActiveX Data ObjectlgQFileSystemObject对象很可能是最复杂的对象之一?br /> q种复杂性是׃对如何访问文件系l的不同部分Q要求有极高的灵zL。例如,可以从FileSystemObject向下通过使用各种从属对象定位一个文件。其q程是从Drives集合开始,C个Drive对象Q再到驱动器的根Folder对象Q然后到子Folder对象Q再到文件夹的Files集合Q最后到集合内的File对象?br /> 另外Q如果已知要讉K的驱动器、文件夹或文件。可以直接对其用GetDrive、GetFolder、GetSpecialFolder和GetFileҎ(gu)。图5-11有助于理解所有文件系l定位相关的lg、对象、方法和属性之间的关系?/p>

1Q?nbsp; Folder对象
Driver对象的RootFolder属性返回一个Folder对象Q通过该对象可讉Kq个驱动器内的所有的内容。可以用这个Folder对象的属性和Ҏ(gu)遍历驱动器上的目录,q得到该文g夹和其他文g夹的属性?br /> (1)    Folder对象的属?br /> Folder对象提供一l属性,可用q些属性得到关于当前文件夹的更多信息,也可以改变该文g夹的名称。其属性及(qing)说明如表5-9所C:(x)
?-9  Folder 对象的属性及(qing)说明
??
??

Attributes
q回文g夹的属性。可以是下列g的一个或其组合:(x)Normal(0)、ReadOnly(1)、Hidden(2)、System(4)、Volume(名称)(8)、DirectoryQ文件夹Q?16)、Archive(32)、Alias(64)和Compressed(128)。例如,一个隐藏的只读文gQAttributes的gؓ(f)3

DateCreated
q回该文件夹的创建日期和旉

DateLastAccessed
q回最后一ơ访问该文g夹的日期和时?

DateLastModified
q回最后一ơ修改该文g夹的日期和时?

Drive
q回该文件夹所在的驱动器的驱动器字?

Files
q回Folder对象包含的Files集合Q表C文g夹内所有的文g

IsRootFolder
q回一个布?yu)(dng)D明该文gҎ(gu)否是当前驱动器的Ҏ(gu)件夹

Name
讑֮或返回文件夹的名?

ParentFolder
q回该文件夹的父文g夹对应的Folder对象

Path
q回文g夹的l对路径Q用相应的长文件名

ShortName
q回DOS风格?.3形式的文件夹?

ShortPath
q回DOS风格?.3形式的文件夹的绝对\?

Size
q回包含在该文g多w所有文件和子文件夹的大?

SubFolers
q回该文件夹内包含的所有子文g夹对应的Folders集合Q包括隐藏文件夹和系l文件夹

Type
如果可能Q返回一个文件夹的说明字W串Q例如,“Recycle Bin”Q?br /> (2)    Folder对象的方?br /> Folder对象提供一l可用于复制、删除和Ud当前文g夹的Ҏ(gu)。这些方法的q行方式与FileSystemObject对象的CopyFolder、DeleFolder和MoveFolderҎ(gu)相同Q但q些Ҏ(gu)不要求source参数Q因为源文g是q个文g夏V这些方法及(qing)说明如表5-10所C:(x)
?-10  Folder对象的方法及(qing)说明
??
??

Copy(destination,overwrite)
这个文件夹?qing)所有的内容复制到destination指定的文件夹。如果destination的末是路径分隔W?‘’)Q那么认为destination是放|拷贝文件夹的一个文件夹。否则认为destination是要创徏的新文g夹的路径和名字。如果目标文件夹已经存在且overwrite参数讄为FalseQ将产生错误Q缺省的overwrite参数是True

Delete(force)
删除文g夹及(qing)里面的所有内宏V如果可选的force参数讄为TrueQ即使文件夹讄为只L含有只读的文Ӟ也将删除该文件夹。缺省的force是False

Move(destination)
文件夹?qing)里面所有的内容Ud到destination指定的文件夹。如果destination的末是路径分隔W?‘’)Q那么认为destination是放|移动文件夹的一个文件夹。否则认为destination是一个新的文件夹的\径和名字。如果目标文件夹已经存在Q则出错

CreateTextFile
(filename,overwrite,unicode)
用指定的文g名在文g夹内创徏一个新的文本文Ӟq且q回一个相应的TextStream对象。如果可选的overwrite参数讄为TrueQ将覆盖M已有的同名文件。缺省的overwrite参数是False。如果可选的unicode参数讄为TrueQ文件的内容存储ؓ(f)unicode文本。缺省的unicode是False

       在文件夹之间可以使用当前文g夹的ParentFolder属性,q回到父目录。当到达一个文件夹Ӟ如果IsRootFolder属性是TrueQ就停下来。离开驱动器的根目录,沿目录树(wi)向下Q可遍历或访问在Folders集合Q由当前文g夹的SubFolders属性返回)(j)内的指定文g夏V?br />        下列E序遍历?jin)驱动器C根目录内的所有文件夹Qƈ昄各个文g夹的有关信息?br />        VBScriptE序如下Q?br />        'In VBScript:
' Create a FileSystemObject instance
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Get a reference to drive C
Set objDriveC = objFSO.GetDrive("C:")
' Get a reference to the root folder
Set objRoot = objDriveC.RootFolder
' Get a reference to the SubFolders collection
Set objFolders = objRoot.SubFolders
' Get a reference to the first folder in the SubFolders collection
For Each objFolder In objFolders
  Set objFolder1 = objFolders.Item((objFolder.Name))
  Exit For
Next
' Iterate through all the files in this folder
For Each objFile in objFolder1.Files
  Response.Write "Name: " & objFile.Name & "   "
  Response.Write "ShortName: " & objFile.ShortName & "   "
  Response.Write "Size: " & objFile.Size & " bytes    "
  Response.Write "Type: " & objFile.Type & "<BR>"
  Response.Write "Path: " & objFile.Path & "   "
  Response.Write "ShortPath: " & objFile.ShortPath & "<BR>"
  Response.Write "Created: " & objFile.DateCreated & "   "
  Response.Write "LastModified: " & objFile.DateLastModified & "<P>"
Next
JScriptE序如下Q?br /> //In JScript:
// Create a FileSystemObject instance
var objFSO = Server.CreateObject('Scripting.FileSystemObject');
// Get a reference to drive C
var objDriveC = objFSO.GetDrive('C:');
// Get a reference to the root folder
var objRoot = objDriveC.RootFolder;
// Get a reference to the first folder in the SubFolders collection
var colAllFolders = new Enumerator(objRoot.SubFolders);
var objFolder1 = colAllFolders.item();
// Get a reference to the Files collection for this folder
var colFiles = new Enumerator(objFolder1.Files);

// Iterate through all the files in this collection
for (; !colFiles.atEnd(); colFiles.moveNext()) {
  objFile = colFiles.item()
  Response.Write('Name: ' + objFile.Name + '   ');
  Response.Write('ShortName: ' + objFile.ShortName + '   ');
  Response.Write('Size: ' + objFile.Size + ' bytes    ');
  Response.Write('Type: ' + objFile.Type + '<BR>');
  Response.Write('Path: ' + objFile.Path + '   ');
  Response.Write('ShortPath: ' + objFile.ShortPath + '<BR>');
  Response.Write('Created: ' + objFile.DateCreated + '   ');
  Response.Write('Accessed: ' + objFile.DateLastAccessed + '   ');
  Response.Write('Modified: ' + objFile.DateLastModified + '<P>');
}
该VBScriptE序在服务器上运行时的结果如?-12所C。该面为folderscollection_vb.aspQ来自本书提供的CZ文g?/p>

(3)    使用Ҏ(gu)文g?br /> GetSpecialFolder是FileSystemObject对象的方法之一Q它q回计算Z三个“Ҏ(gu)文g?#8221;对应的Folder对象Q?br /> · WindowsFolderQ?Windows%目录Q缺省ؓ(f)WinNTQ或WindowsQ在非NT/2000计算ZQ目录?br /> · SystemFolderQ?System%目录Q缺省ؓ(f)WinNTSystem32Q或WindowsSystemQ在非NT/2000计算ZQ目录?br /> · TemporaryFolderQ?Temp%目录Q缺省ؓ(f)WinNTTempQ或WindowsTempQ在非NT/2000计算ZQ目录?br /> 为得到对Ҏ(gu)文g夹的引用Q我们提供相应的预定义常C为GetSpecialFolderҎ(gu)的参敎ͼ(x)
' In VBScript:
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetSpecialFolder(WindowsFolder)
Response.Write "GetSpecialFolder(WindowsFolder) returned:<BR>"
Response.Write "Path: " & objFolder.Path & "<BR>"
Response.Write "Type: " & objFolder.Type & "<P>"

Set objFolder = objFSO.GetSpecialFolder(SystemFolder)
Response.Write "GetSpecialFolder(SystemFolder) returned:<BR>"
Response.Write "Path: " & objFolder.Path & "<BR>"
Response.Write "Type: " & objFolder.Type & "<P>"

Set objFolder = objFSO.GetSpecialFolder(TemporaryFolder)
Response.Write "GetSpecialFolder(TemporaryFolder) returned:<BR>"
Response.Write "Path: " & objFolder.Path & "<BR>"
Response.Write "Type: " & objFolder.Type & "<P>"
或用JScriptQ?br /> // In JScript:
var objFSO = Server.CreateObject('Scripting.FileSystemObject');

var objFolder = objFSO.GetSpecialFolder(WindowsFolder);
Response.Write('GetSpecialFolder(WindowsFolder) returned -  ');
Response.Write('Path: ' + objFolder.Path + '   ');
Response.Write('Type: ' + objFolder.Type + '<BR>');

var objFolder = objFSO.GetSpecialFolder(SystemFolder);
Response.Write('GetSpecialFolder(SystemFolder) returned -  ');
Response.Write('Path: ' + objFolder.Path + '   ');
Response.Write('Type: ' + objFolder.Type + '<BR>');

var objFolder = objFSO.GetSpecialFolder(TemporaryFolder);
Response.Write('GetSpecialFolder(TemporaryFolder) returned -  ');
Response.Write('Path: ' + objFolder.Path + '   ');
Response.Write('Type: ' + objFolder.Type + '<BR>');
该VBScriptE序在服务器上运行时的结果如?-13所C。该面名ؓ(f)specialfolder_vb.aspQ来自本书提供的CZ文g?/p>

2Q?nbsp; File对象
File对象提供?jin)对文g的属性的讉KQ通过它的Ҏ(gu)能够Ҏ(gu)件进行操作。每个Folder对象提供?jin)一个Files集合Q包含文件夹中文件对应的File对象。还可以直接CFileSystemObject对象中通过使用GetFileҎ(gu)得到一个File对象引用?br /> (1)      File对象的属?br /> File对象有一pd的属性,cM于Folder对象的属性,如表5-11所C:(x)
?-11  File对象的属性及(qing)说明
??
??

Attributes
q回文g的属性。可以是下列g的一个或其组合:(x)Normal(0)、ReadOnly(1)、Hidden(2)、System(4)、Volume(名称)(9)、Directory(文g?(16)、Archive(32)、Alias(64)和Compressed(128)

DateCreated
q回该文件夹的创建日期和旉

DateLastAccessed
q回最后一ơ访问该文g的日期和旉

DateLastModified
q回最后一ơ修改该文g的日期和旉

Drive
q回该文件所在的驱动器的Drive对象

Name
讑֮或返回文件的名字

ParentFolder
q回该文件的父文件夹的Folder对象

Path
q回文g的绝对\径,可用长文g?

ShortName
q回DOS风格?.3形式的文件名

ShortPath
q回DOS风格?.3形式的文件绝对\?

Size
q回该文件的大小Q字节)(j)

Type
如果可能Q返回一个文件类型的说明字符Ԍ例如Q?#8220;Text Document”表示.txt文gQ?

       (2)  File对象的方?br />        同样cM于Folder对象QFile对象的方法允许复制、删除以?qing)移动文件。它也有一个用文本流打开文g的方法。File对象的方法及(qing)说明如表5-12所C:(x)
?-12  File对象的方法及(qing)说明
??
??

Copy(destination,overwrite)
这个文件复制到destination指定的文件夹。如果destination的末是路径分隔W?‘’)Q那么认为destination是放|拷贝文件的文g夏V否则认为destination是要创徏的新文g的\径和名字。如果目标文件已l存在且overwrite参数讄为FalseQ将产生错误Q缺省的overwrite参数是True

Delete(force)
删除q个文g。如果可选的force参数讄为TrueQ即使文件具有只d性也?x)被删除。缺省的force是False

Move(destination)
文件移动到destination指定的文件夹。如果destination的末是路径分隔W?‘’)Q那么认为destination是一文g夏V否则认为destination是一个新的文件的路径和名字。如果目标文件夹已经存在Q则出错

CreateTextFile
(filename,overwrite,unicode)
用指定的文g名创Z个新的文本文Ӟq且q回一个相应的TextStream对象。如果可选的overwrite参数讄为TrueQ将覆盖M已有的同名文件。缺省的overwrite参数是False。如果可选的unicode参数讄为TrueQ文件的内容存储ؓ(f)unicode文本。缺省的unicode是False
OpenAsTextStream
(iomode,format)
打开指定文gq且q回一个TextStream对象Q用于文件的诅R写或追加。iomode参数指定?jin)要求的讉KcdQ允许值是ForReading(1) (~省?、ForWrite(2)、ForAppending(8)。format参数说明?jin)读、写文g的数据格式。允许值是TristateFalse(0)Q缺省)(j)Q说明用ASCII数据格式QTristateTrue(-1)说明用Unicode数据格式QTristateUseDefault(-2)说明使用pȝ~省格式

       因此l定一个File对象后,可以使用ParentFolder属性得到包含该文g的Folder对象的引用,用来在文件系l中D。甚臛_以用Drive属性获得相应的Drive对象的引用,q得到各UFolder对象以及(qing)所包含的File对象?br />        另外Q给定一个Folder对象以及(qing)对应的Files集合后,可以通过遍历该集合检查这一文g夹中的每个文件。还可以使用File对象的各U方法以一定方式处理该文gQ如复制、移动或删除。下面的代码l出?jin)C驱动器的W一个文件夹的文件列表:(x)
       ' In VBScript:
' Create a FileSystemObject instance
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Get a reference to drive C
Set objDriveC = objFSO.GetDrive("C:")
' Get a reference to the root folder
Set objRoot = objDriveC.RootFolder
' Get a reference to the SubFolders collection
Set objFolders = objRoot.SubFolders
' Get a reference to the first folder in the SubFolders collection
For Each objFolder In objFolders
  Set objFolder1 = objFolders.Item((objFolder.Name))
  Exit For
Next
' Iterate through all the files in this folder
For Each objFile in objFolder1.Files
  Response.Write "Name: " & objFile.Name & "   "
  Response.Write "ShortName: " & objFile.ShortName & "   "
  Response.Write "Size: " & objFile.Size & " bytes    "
  Response.Write "Type: " & objFile.Type & "<BR>"
  Response.Write "Path: " & objFile.Path & "   "
  Response.Write "ShortPath: " & objFile.ShortPath & "<BR>"
  Response.Write "Created: " & objFile.DateCreated & "   "
  Response.Write "LastModified: " & objFile.DateLastModified & "<P>"
Next
注意Q不能用数字烦(ch)引来定位Folders或Files集合里的条目Q因此必M用For Each … Next语句遍历该集合直到最初的条目Q然后用该条目的Name属性。也不得不用嵌套的圆括号强q其作ؓ(f)|字符Ԍ(j)传送给该Folders集合的ItemҎ(gu)?br /> 用下面的JScriptE序可完成同L(fng)工作Q?br /> // In JScript:
// Create a FileSystemObject instance
var objFSO = Server.CreateObject('Scripting.FileSystemObject');
// Get a reference to drive C
var objDriveC = objFSO.GetDrive('C:');
// Get a reference to the root folder
var objRoot = objDriveC.RootFolder;
// Get a reference to the first folder in the SubFolders collection
var colAllFolders = new Enumerator(objRoot.SubFolders);
var objFolder1 = colAllFolders.item();
// Get a reference to the Files collection for this folder
var colFiles = new Enumerator(objFolder1.Files);

// Iterate through all the files in this collection
for (; !colFiles.atEnd(); colFiles.moveNext()) {
  objFile = colFiles.item()
  Response.Write('Name: ' + objFile.Name + '   ');
  Response.Write('ShortName: ' + objFile.ShortName + '   ');
  Response.Write('Size: ' + objFile.Size + ' bytes    ');
  Response.Write('Type: ' + objFile.Type + '<BR>');
  Response.Write('Path: ' + objFile.Path + '   ');
  Response.Write('ShortPath: ' + objFile.ShortPath + '<BR>');
  Response.Write('Created: ' + objFile.DateCreated + '   ');
  Response.Write('Accessed: ' + objFile.DateLastAccessed + '   ');
  Response.Write('Modified: ' + objFile.DateLastModified + '<P>');
}
两个E序的结果是相同?br />     在C驱动器上的第一个文件夹可能是CAConfigQ缺省情况下该文件夹是空的。这U情况下Q可先向该文件夹复制一些文Ӟ完成实验以后再删除这些文件?br />

 --------------------------------------------
QTPQFileSystemObject基础知识
 在QTP试中,比较本地的两个文件是不是相同Q需要用VBScript的FileSystemObject对象Q在此作要的概述
一Q基FileSystemObject
1.     创徏 FileSystemObject 对象
Dim fso
Set fso = CreateObject(\"Scripting.FileSystemObject\")
  Scripting 是类型库的名字,?FileSystemObject 则是惌创徏的对象的名字?
  要用 FileSystemObject (FSO) 对象模式来编E,则:(x)使用 CreateObject Ҏ(gu)来创?FileSystemObject 对象?nbsp;
  FSO 对象模式包含?Scripting cd库中Q该库位?Scrrun.dll 文g中。因而,要?FSO 对象模式Q必L Scrrun.dll 攑֜ Web 服务器的适当pȝ目录中?
2.     使用Ҏ(gu)Q?
  讉K现有驱动器、文件和文g?
GetDrive()、GetFolder()、GetFile()、CreateFolder()、CreateFile()、CreateTextFile ()、OpenTextFile()、FolderExists(url)、DeleteFolder(url)、MoveFolder(src,to)、FileExists(url)、CopyFile()、MoveFile()、DeleteFile()?
例如Q?
Dim fso, f1
Set fso = CreateObject(\"Scripting.FileSystemObject\")
Set f1 = fso.GetFile(\"c:\\test.txt\")
3.     讉K属性:(x)
Name、Path、Size、Type、DateLastModifiedQ上一ơ修改的文g旉Q?
二.FSO的一些特D功?
1.        GetSpecialFolder Method q回特定的Windows文g夹的路径:
  Windows安装目录QWindowspȝ目录;Windows临时目录 
  FSO.GetSpecialFolder([0, 1, or 2])  
2.        GetTempName Method q回一个随Z生的文g或者目录名字,用于存储临数?
3.        GetAbsolutePathName Method q回文g夹的l对路径(cM于Server.MapPath)?
比如QFSO.GetAbsolutePathName(\"region\") 返回类g下面的结果:(x)\"c:mydocsmyfolder egion\" 
4.        GetExtensionName Method q回路径中最后部分的扩展?(比如QFSO.GetExtensionName(\"c:docs est.txt\") 返回txt) 
5.        GetBaseName and GetParentFolder Methods q回路径中最后部分的父文件夹 (比如QFSO.GetParentFolder (\"c:docsmydocs\") 返?#8217;docs’) 
6.        Drives Property q回所有本地可用驱动器的集合,用于建立资源览器样的用h口?br />



joan 2009-11-17 16:32 发表评论
]]>
QTP 试PDF 的方?/title><link>http://www.tkk7.com/joan/articles/266546.html</link><dc:creator>joan</dc:creator><author>joan</author><pubDate>Mon, 20 Apr 2009 05:39:00 GMT</pubDate><guid>http://www.tkk7.com/joan/articles/266546.html</guid><wfw:comment>http://www.tkk7.com/joan/comments/266546.html</wfw:comment><comments>http://www.tkk7.com/joan/articles/266546.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/joan/comments/commentRss/266546.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/joan/services/trackbacks/266546.html</trackback:ping><description><![CDATA[<span style="font-family: Comic Sans MS">Adobe的PDF文g是目前通用的文件格式之一Q很多文档都以这U格式来存储。在使用QTPq行自动化测试的q程中,l常要验证PDF文g的内Ҏ(gu)否满求,因此需要访问PDF文g的内部属性。幸好Adobe提供?jin)以COM方式讉KPDF的接口,使得我们可以实现QTP试PDF的自动化q程。下面是一个简单的例子Q用于打开一份PDF文档Q读取PDF文档的页敎ͼ(x)<br /> <br style="font-family: " /> Option Explicit<br /> Dim gApp, gPDDoc, jso<br /> Set gApp = CreateObject("AcroExch.App")<br /> Set gPDDoc = CreateObject("AcroExch.PDDoc")<br />     If gPDDoc.Open("C:\Documents and Settings\joan\桌面\详解与案例剖?pdf") Then<br />         Msgbox gPDDoc.GetNumPages<br />     End If<br /> Set gPDDoc = Nothing : Set gApp = Nothing<br /> 'Adobe Acrobat Professional<br /> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; color: rgb(0,0,0); font-family: '?hu)?; mso-spacerun: 'yes'"> </p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; color: rgb(0,0,0); font-family: '?hu)?; mso-spacerun: 'yes'">Q需要安装Adobe Acrobat Professional Q?/span></p> </span><!--endfragment--></span> <img src ="http://www.tkk7.com/joan/aggbug/266546.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/joan/" target="_blank">joan</a> 2009-04-20 13:39 <a href="http://www.tkk7.com/joan/articles/266546.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QuickTest Plus工P大作用(转蝲Q?/title><link>http://www.tkk7.com/joan/articles/242806.html</link><dc:creator>joan</dc:creator><author>joan</author><pubDate>Wed, 26 Nov 2008 08:20:00 GMT</pubDate><guid>http://www.tkk7.com/joan/articles/242806.html</guid><wfw:comment>http://www.tkk7.com/joan/comments/242806.html</wfw:comment><comments>http://www.tkk7.com/joan/articles/242806.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/joan/comments/commentRss/242806.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/joan/services/trackbacks/242806.html</trackback:ping><description><![CDATA[     摘要: QuickTest Plus工P大作用(转蝲Q?nbsp; <a href='http://www.tkk7.com/joan/articles/242806.html'>阅读全文</a><img src ="http://www.tkk7.com/joan/aggbug/242806.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/joan/" target="_blank">joan</a> 2008-11-26 16:20 <a href="http://www.tkk7.com/joan/articles/242806.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转蝲Q(QTP使用中的一些好的方法)(j)http://www.tkk7.com/joan/articles/217031.htmljoanjoanWed, 23 Jul 2008 14:17:00 GMThttp://www.tkk7.com/joan/articles/217031.htmlhttp://www.tkk7.com/joan/comments/217031.htmlhttp://www.tkk7.com/joan/articles/217031.html#Feedback0http://www.tkk7.com/joan/comments/commentRss/217031.htmlhttp://www.tkk7.com/joan/services/trackbacks/217031.htmlSystemUtil Object Descrīption
An object used to control applications and processes during a run session.
在脚本运行过E中,可用该对象控制应用E序或进E?
Operations
The tables below list the built-in methods and properties that you can use as operations for the SystemUtil object. 下表列出?jin)SystemUtil对象的内建方法与属?
Methods BlockInput Prevents keyboard and mouse input events from reaching applications.
止键盘或鼠标操?
CloseDescendentProcesses Closes all processes opened by QuickTest.
关闭由QuickTest打开的所有进E?
CloseProcessByHwnd Closes a process that is the owner of a window with the specified handle.
Ҏ(gu)H口的句柄找到相应的q程,q关闭该q程.
CloseProcessById Closes a process according to its Process ID (PID).
关闭指定q程PID的进E?
CloseProcessByName Closes a process according to its name.
关闭指定q程名称的进E?
CloseProcessByWndTitle Closes all processes that are owners of windows with the specified title.
关闭指定H口标题的进E?
Run Runs a file or application.
q行文g或应用程?
UnblockInput Re-enables keyboard and mouse input events after a BlockInput statement
was used to block them.
在BlockInput语句止键盘或鼠标之?使用UnblockInput语句可解除对键盘?br /> 鼠标的禁?
BlockInput Method Descrīption
Prevents keyboard and mouse input events from reaching applications.
止键盘或鼠标操?
Syntax object.BlockInput
Argument Descrīption
Object A test object of type SystemUtil.
SystemUtilcd?a onclick="javascript:tagshow(event, '%B2%E2%CA%D4');" href="javascript:;" target="_self">对象.
Return Value
None
Remarks
You can use this method to prevent a run session being accidentally interrupted by someone using the keyboard or mouse on a QuickTest Professional computer.
当电(sh)脑正在运?a name="baidusnap0">QTP脚本?使用BlockInputҎ(gu)可以防止因键盘或鼠标的操作扰?strong style="color: black; background-color: #ffff66">QTP的正常运?
After using this method, keyboard and mouse input is blocked until one of the following occurs:
使用BlockInputҎ(gu)?使用以下Ҏ(gu)可以解除寚w盘或鼠标的禁?
An UnblockInput statement is used
当用了(jin)UnblockInput语句?
A run session ends or is paused for any reason (end of test run, run error, breakpoint, and so forth)
当脚本运行结束或中断(如整个testl束,q行错误,断点{等).
The Ctrl+Alt+Delete key combination is pressed on the keyboard
在键盘(sh)按下Ctrl+Alt+Deletel合键后.
A critical system error occurs
当出C(jin)严重的系l错误时.
Example
Block Keyboard and Mouse Input During a Run Session
下面的例子用BlockInputҎ(gu),?strong style="color: black; background-color: #ffff66">QTP脚本q行q程中禁用了(jin)键盘?qing)鼠?
Sub BlockInput_Example()
SystemUtil.BlockInput
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set
"mercury"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury
Tours").WebEdit("password").SetSecure "4082986e39ea469e70dbf8c5a29429fe138c6efc"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Image("Sign-In").Click 2,
2 、SystemUtil.UnblockInput
End Sub
UnblockInput Method
Descrīption
Re-enables keyboard and mouse input events after a BlockInput statement was used to block them.
在BlockInput语句止键盘或鼠标之?使用UnblockInput语句可解除对键盘或鼠标的止.
Syntax
object.UnblockInput
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
Return Value
None
Remarks
You can use this method to unblock keyboard and mouse input that was earlier blocked using a BlockInput
statement.
如果先前使用?jin)BlockInputҎ(gu)止?jin)键盘?qing)鼠标,使用UnblockInputҎ(gu)可解除禁?
Example
Unblock Keyboard and Mouse Input That Was Previously Blocked
本例在开始用BlockInputҎ(gu)止?jin)键盘?qing)鼠标,后来使用UnblockInputҎ(gu)解除?jin)禁?
Sub UnblockInput_Example()
SystemUtil.BlockInput
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set
"mercury"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury
Tours").WebEdit("password").SetSecure "4082986e39ea469e70dbf8c5a29429fe138c6efc"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Image("Sign-In").Click 2,
2
SystemUtil.UnblockInput
End Sub
CloseDescendentProcesses Method
Descrīption
Closes all processes opened by QuickTest.
关闭由QuickTest打开的所有进E?
Syntax
object.CloseDescendentProcesses
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
Return Value
A Long value. The number of instances of the application that are closed when the statement runs.
一个长整型?被CloseDescendentProcessesҎ(gu)语句关闭的程序实例数.
Remarks
Note: QuickTest initially tries to close the process by sending a WM_CLOSE message to the process window. If
the process is still open after 5 seconds, QuickTest terminates the process.
注意:执行该语句时,QuickTest首先向进E窗口发送一个WM_CLOSE信息,偿试关闭该进E?如果该进E在5U钟后存?br /> 关闭,则QuickTest强制l束q程.
Example
Close All Applications Opened By QuickTest
在本例中:假定在运行程序之?Record and Run对话框自动打开?jin)某个窗?然后通过Run语句打开?jin)一个NotePadH口,
那么该CloseDscendentProcessedҎ(gu)的返回值就p?,因此Message对话框显C的信息应该?2".
Sub CloseDescendentProcesses_Example()
SystemUtil.Run "Notepad.exe"
MsgBox SystemUtil.CloseDescendentProcesses
End Sub
CloseProcessByHwnd Method
Descrīption
Closes a process that is the owner of a window with the specified handle.
Ҏ(gu)H口的句柄找到相应的q程,q关闭该q程.
Syntax
object.CloseProcessByHwnd (hWnd)
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
hWnd Required. An ULong object.
The handle of the window owned by the process you want to close.
Tip: You can retrieve the window handle using the hwnd property. For
example:
Window("MyAppName").GetROProperty("hwnd")
必须.一个ULong对象.
你想要关闭的q程的窗口的句柄.
Tip:你可以通过获取RuntimeH口对象的hwnd属性值来获得句柄信息.例如:
Window("MyAppName").GetRoProperty("hwnd")
Return Value
A Boolean value.
一个Boolean?
True--The specified process was successfully closed.
True――指定的q程已被成功关闭.
False--The specified process was not closed.
False――指定的q程未被关闭.
Remarks
Note: QuickTest initially tries to close the process by sending a WM_CLOSE message to the process window. If
the process is still open after 5 seconds, QuickTest terminates the process.
注意:执行该语句时,QuickTest首先向进E窗口发送一个WM_CLOSE信息,偿试关闭该进E?如果该进E在5U钟后存?br /> 关闭,则QuickTest强制l束q程.
Example
Close the Process that is an Owner of a Window with the Specified Handle
在本例中,首先通过GetroPropertyҎ(gu)获取NotePadH口的句?然后使用CloseProcessByHwndҎ(gu)关闭NotepadE序.
Sub CloseProcessByHwnd_Example()
hWnd = Window("Notepad").GetROProperty("hwnd")
SystemUtil.CloseProcessByHwnd (hWnd)
End Sub
CloseProcessById Method
Descrīption
Closes a process according to its Process ID (PID).
Ҏ(gu)q程的Process ID(PID)关闭q程.
Syntax
object.CloseProcessById (wdProcessId)
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
wdProcessId Required. An ULong object.
The Process ID (PID) of the process you want to close.
Tip: You can find the PID of an application by viewing the value in the
Processes tab of the Windows Task Manager, or you can retrieve the value
using the process id property. For example:
Window("MyAppName").GetROProperty("process id")
必须.一个ULong对象.
你想关闭的进E的PID.
Tip:在Windows的Q务窗口的q程标签可以查看到E序的PID?你也可以?br /> q获取RuntimeH口对象的Process id属性值来获得PID信息.例如:
Window("MyAppName").GetRoProperty("process id")
Return Value
A Boolean value.
一个Boolean?
True--The specified process was successfully closed.
True――指定的q程已被正常关闭.
False--The specified process was not closed.
False――指定的q程未被关闭.
Remarks
Note: QuickTest initially tries to close the process by sending a WM_CLOSE message to the process window. If
the process is still open after 5 seconds, QuickTest terminates the process.
注意:执行该语句时,QuickTest首先向进E窗口发送一个WM_CLOSE信息,偿试关闭该进E?如果该进E在5U钟后存?br /> 关闭,则QuickTest强制l束q程.
Example
Close an Application According to its Process ID
下面的例子通过GetRoPropertyҎ(gu)获取NotepadH口的PID?然后使用CloseProcessByIdҎ(gu)关闭NotepadE序.
Sub CloseProcessById_Example()
PID = Window("Notepad").GetROProperty("process id")
SystemUtil.CloseProcessById (PID)
End Sub
CloseProcessByName Method
Descrīption
Closes a process according to its name.
Syntax
object.CloseProcessByName (bsProcessName)
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
bsProcessName Required. A String value.
The name of the process you want to close.
必须.一个字W串?
你想关闭的进E的名称.
Return Value
A Long value. The number of instances of the application that are closed when the statement runs.
一个Long?所关闭的程序的实例?
Remarks
Note: QuickTest initially tries to close the process by sending a WM_CLOSE message to the process window. If
the process is still open after 5 seconds, QuickTest terminates the process.
注意:执行该语句时,QuickTest首先向进E窗口发送一个WM_CLOSE信息,偿试关闭该进E?如果该进E在5U钟后存?br /> 关闭,则QuickTest强制l束q程.
Example
Close All Instances of a Specified Application
本例通过CloseProcessByNameҎ(gu),关闭所有已打开的Notepad实例.如果当前所有的Notepad实例都是׃面的Run语句打开?则C(j)loseProcessByNameҎ(gu)语句?x)关闭这些实?q且MsgBoxH口昄的数值应?3".
Sub CloseProcessByName_Example()
SystemUtil.Run "Notepad.exe"
SystemUtil.Run "Notepad.exe"
SystemUtil.Run "Notepad.exe"
MsgBox SystemUtil.CloseProcessByName("Notepad.exe")
End Sub
CloseProcessByWndTitle Method
Descrīption
Closes all processes that are owners of windows with the specified title.
关闭指定H口标题的所有进E?
Syntax
object.CloseProcessByWndTitle (bsTitle, [bRegExp])
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
bsTitle Required. A String value.
The title of the window owned by the process you want to close.
必须.一个字W串?
你想关闭的进E的H口的标?
bRegExp Optional. A Boolean value.
Indicates whether the bsTitle argument is treated as a regular
expression. Default = False.
可?一个Boolean?
(g)查BsTitle参数是否是一个正则表辑ּ.默认gؓ(f)False.
Return Value
A Long value. The number of instances of the application that are closed when the statement runs.
一个Long?被语句所关闭的程序的实例?
Remarks
Note: QuickTest initially tries to close the process by sending a WM_CLOSE message to the process window. If
the process is still open after 5 seconds, QuickTest terminates the process.
注意:执行该语句时,QuickTest首先向进E窗口发送一个WM_CLOSE信息,偿试关闭该进E?如果该进E在5U钟后存未关?则QuickTest强制l束q程.
Example
Close All Windows with a Title Containing a Specified String
本例关闭?jin)所有的标题包含?Notepad"字样的顶层窗?因ؓ(f)bRegExp参数gؓ(f)"ture",表示bsTitle值是一个正则表辑ּ.
Sub CloseProcessByWndTitle_Example1()
SystemUtil.CloseProcessByWndTitle "Notepad", True
End Sub
Close All Windows in which the Exact Title Matches a Specified String
本例关闭所有窗口标题(sh)ؓ(f)"Untitled-Notepad"的顶层窗?因ؓ(f)bRegExp参数gؓ(f)"false",表示bsTitle参数值是一个文字串,因此H口标题必须与参数值精匹?
Sub CloseProcessByWndTitle_Example2()
SystemUtil.CloseProcessByWndTitle "Untitled - Notepad"
End Sub
Run Method
Descrīption
Runs a file or application.
q行一个文件或应用E序.
Syntax
object.Run file, [params], [dir], [op], [mode]
Argument Descrīption
object A test object of type SystemUtil.
SystemUtilcd的测试对?
file Required. A String value.
The name of the file you want to run.
必须.一个字W串?
你想要运行的文g的名U?
params Optional. A String value.
If the specified file argument is an executable file, use the params argument to specify
any parameters to be passed to the application.
可?一个字W串?
如果file参数中指定的是一个可执行文g,则可以用params参数来指定该可执行文件的q行参数.
dir Optional. A String value.
The default directory of the application or file.
可?一个字W串?
应用E序或文件的默认目录.
op Optional. A String value. The action to be performed. If this argument is blank ( ""), the
open operation is performed.
The following operations can be specified for the op argument:
可?一个字W串?要被执行的动作.如果该参数gؓ(f)I?""),则默认操作ؓ(f)open操作.
下面是op参数中可以指定的操作:
Operation Descrīption
open
Opens the file specified by the FileName parameter. The file can be an
executable file, a document file, or a folder. Non-executable files are
open in the associated application.
打开file参数中所指定的文?文g有可能是一个可执行文g,一个文档文??br /> 一个文件夹.非可执行文g?x)被相应的应用程序打开.
edit
Launches an editor and opens the document for editing. If the FileName
argument does not specify an editable document file, the statement
fails.
文件在文g~辑器中打开以进行编?如果file参数中指定的文g不可~辑,?br /> 本语句失?
explore
Explores the folder specified by the FileName argument.
打开由file参数中所指定的文件夹.
find
Initiates a search starting from the specified folder path.
在file参数所指定的文件夹中进行搜?
print
Prints the document file specified by the FileName argument. If the
specified file is not a printable document file, the statement fails.
打印在file参数中所指定的文?如果参数中所指定的文档不可打?则语句失?
mode Optional. An Integer value.
Specifies how the application is displayed when it opens. You can specify one of the modes
in the table below.
Default = 1
可?一个Integer? 指定应用E序打开时的昄模式.可以指定以下几种打开模式.默认模式?.
Mode Descrīption
0
Hides the window and activates another window.
隐藏E序H口,Ȁzd外一下窗?
1
Activates and displays the window. If the window is minimized or maximized,
the system restores it to its original size and position. Specify this flag when
displaying the window for the first time.
Ȁzdƈ昄E序H口.如果H口是最大化或最化状?则将它恢复ؓ(f)默认H口大小q放
|于默认位置.
2
Activates the window and displays it as a minimized window.
Ȁzȝ口ƈ最化.
3
Activates the window and displays it as a maximized window.
Ȁzȝ口ƈ最大化.
4
Displays the window in its most recent size and position. The active window
remains active.
按照H口最q一ơ的昄大小?qing)位|显CH口,但不Ȁz该H口.原来zd的窗口仍?br /> 持活动状?
5
Activates the window and displays it in its current size and position.
Ȁzȝ?保持当前的大及(qing)位置不变.
6
Minimizes the specified window and activates the next top-level window in the
Z order.
最化指定的窗?q激zd的下一个top-levelH口(按Z序扑ֈ它的下一下top-level
H口).
7
Displays the window as a minimized window. The active window remains active.
昄H口q最化,但不Ȁz该H口.原来zd的窗口仍保持zd状?
8
Displays the window in its current state. The active window remains active.
昄H口,大小?qing)位|保存(sh)?原来zd的窗口仍保持zd状?
9
Activates and displays the window. If the window is minimized or maximized,
the system restores it to its original size and position. Specify this flag when
restoring a minimized window.
Ȁzdƈ昄H口.如果H口处于最大化或最化状?则将它恢复ؓ(f)原始大小与位|?
10
Sets the show-state based on the state of the program that started the
application.
Return Value
None
Remarks
When specifying a non-executable file, the file opens in the associated application.
当指定的是一个非可执行文件时,文g被相应的应用E序打开.
Note: A SystemUtil.Run statement is automatically added to your test when you run an application from the Start menu or the Run dialog box while recording a test.
注意:在录制脚本的q程?如果你从pȝ?开?菜单?q行"对话框中q行应用E序?SystemUtil.Run语句?x)自动添加到脚本?
Tip: You can also use this method to perform operations on the specified file, similar to the usage of the Windows ShellExecute command.
Tip:你也可以使用本方法对指定的文件进行操?该功能类g使用Windows ShellExecute命o(h).
Example
Open a Text File in the Default Text Application (Notepad)
本例使用RunҎ(gu)打开?jin)一个名为type.txt的文?txtcd文g的默认打开E序是Notpad),然后向文件中输入"happy days"文字,然后使用快捷键保存该文g,然后关闭NotePad应用E序.
Sub CloseDescendentProcesses_Example()
SystemUtil.Run "C:\type.txt", "", "", ""
Window("Text:=type.txt - Notepad").Type "happy days"
Window("Text:=type.txt - Notepad").Type micAltDwn & "F" & micAltUp
Window("Text:=type.txt - Notepad").Type micLShiftDwn & "S" & micLShiftUp
Window("Text:=type.txt - Notepad").Close
End Sub

joan 2008-07-23 22:17 发表评论
]]>
QTP 安装问题结http://www.tkk7.com/joan/articles/joan.htmljoanjoanSun, 13 Jul 2008 03:21:00 GMThttp://www.tkk7.com/joan/articles/joan.htmlhttp://www.tkk7.com/joan/comments/214556.htmlhttp://www.tkk7.com/joan/articles/joan.html#Feedback0http://www.tkk7.com/joan/comments/commentRss/214556.htmlhttp://www.tkk7.com/joan/services/trackbacks/214556.html
   

joan 2008-07-13 11:21 发表评论
]]>
վ֩ģ壺 ëƬȫѹۿ| ޾Һһ| ˾Ʒձվ| þþƷһ| һƷ| ѿAVƬ| Ƶ| 99ƷƵѹۿ| þþþѿaԿ| ڵƵ߹ۿ| ˾Ʒձַ| ɫͼۺվ| ɫͼ.com| ŷպٲ| ɫƷһ| ޾ƷŮþþþþþ| Ƶ| һƵ| ޼ƵͼƬ| ɫվWWW| Ʒ_˳| ڵ߿| www.xxxx.comձ| 岻Ƶ| ѾƵ߹ۿ| ֻˬapp| aëƬƵ| Ʒѿ㽶| ޾Ʒ޿һ| ѧһػƵѴƬƵ| еİjŽŮƵ| ѿƸappһ»ɫ¼| ޻ɫƵ| avۺ߹ۿ| ɫƷaһ| ˾Ʒձվ| Ӱ| ޹Ʒþ| ɫվ| vaƷѹۿ| ͵ľƷ|