在CRT屏幕上获取某个具体位置的文本(转)
2013-12-11 11:46
387 查看
可以使用Screen 对象的Get() or Get2()方法去获取屏幕上的数据.
1 Get() 函数包含四个参数.文本第一个字符所在的行号,列号.最后个字符所在的行号与列号.可以通过选择相应的文本来查看文字所处的行号与列号.
以下就可获取相应的值.
nFreeMem = crt.Screen.Get (5,36,5,41)
把数据写放到文本中
Writing data to a file using the VBScript FileSystemObject can typically be accomplished usingthe following general steps: 1) Get a reference to the FileSystemObject : Set objFSO = CreateObject( "Scripting.FileSystemObject" ) 2) Use the FileSystemObject reference to retrieve a reference to a TextStream objectassociated with the text file to which the data is to be written. Const ForWriting = 2 Const ForAppending = 8 ' Create a new file (or overwrite an existing one)Set objStream = objFSO.OpenTextFile( _ "C:\Temp\MyDataFile.txt", _ ForWriting, _ True) ' Append to an existing file (create if it doesn't exist)Set objStream = objFSO.OpenTextFile( _ "C:\Temp\MyDataFile.txt", _ ForAppending , _ True)3) Write the data to the file using the TextStream object's Write or WriteLine methods. The WriteLine method automatically appends EOL characters to the end of the datasupplied to the method. objStream.Write "This data is written " objStream.Write "as one single line." Or: objStream.WriteLine "This data is written " objStream.WriteLine "as two separate lines." Note that you can write multiple lines using either method by manually inserting CRLFsequences as needed, for example:bjStream.Write "This is line one." & vbcrlf & _ "This is line two." & vbcrlf & _ "This is line three." & vbcrlf & _ "This is line four." & vbcrlfOr:
objStream.WriteLine "This is line one." & vbcrlf & _ "This is line two." & vbcrlf & _ "This is line three." & vbcrlf & _ "This is line four."
4) When you have completed writing data to the file, close the file: objStream.Close
EXAMPLE:获取CPU数据并将其写入到文件中# $language = "VBScript" # $interface = "1.0" Sub Main () For x = 1 To 10000crt.sleep 300000usrCpu = crt.Screen.Get(2,7,2,9)sysCpu = crt.Screen.Get (2,15,2,18) idleCpu =crt.Screen.get(2,35,2,37)
Dim fso, f1Set fso = CreateObject("Scripting.FileSystemObject")Set f1 = fso.OpenTextFile("E:\TestFile.txt", 8,True)f1.writeline("usr:" & usrCpu & " sysCpu:" & sysCpu & " idleCpu" & idleCpu)f1.close
Next
end Sub
相关文章推荐
- Silverlight如何获取控件的屏幕坐标位置
- iOS开发——定位获取经纬度坐标,并反编码获得地理位置信息(具体地址,国家、省、市等)
- Unity3d 获取屏幕中心位置
- UITextView、UITextField获取选中文本的位置
- IOS获取当前地理位置文本
- 基于JavaScript实现根据手机定位获取当前具体位置(X省X市X县X街道X号)
- Android获取view在屏幕中的位置
- 获取cell在屏幕中的位置
- Android 获取View在屏幕中的位置
- Android获取点击屏幕的位置坐标
- Android - 小功能 - 获取view在屏幕中的位置 .
- js获取div相对屏幕的坐标位置
- js获取窗口相对于屏幕左边和上边的位置坐标
- activity中获取view的宽高以及所在屏幕中的位置
- 使用Java HttpClient访问淘宝Ip查询接口获取具体位置信息
- EditText设置/隐藏光标位置、选中文本和获取/清除焦点
- c#获取光标在屏幕中位置
- 基于JavaScript实现根据手机定位获取当前具体位置(X省X市X县X街道X号)
- ahjesus 获取当前方法被调用执行的具体位置,包括命名空间和方法