Skip to main content


Showing posts from 2013

Control the text file pointer

We could have faced a problem like getting back the reading location of a opened text file to re-read or re-search the file from beginning ...
We don't have a right approach to do this in VBScript using FileSystemObject without close and reopening the file. But we could do using STREAM object without reopen ...

Dim myFileStream
Set myFileStream = CreateObject("ADODB.Stream")
myFileStream.CharSet = "UTF-8"
myFileStream.LineSeparator = 13

msgbox myFileStream.ReadText(-2) 'Returns first line

myFileStream.Position = 0
msgbox myFileStream.ReadText(-2) 'returns first line again as expected

posted from Bloggeroid

Convert Image Formats

You could face situations like changing the format of the image file or reduce the file size by changing the formats. Here is the way to get it done in simple way.

Function ConvertImage(strFromFile, strToFile)Dim oImage, oFileImage, oImageFormats, oFSO, strToExtn Set oFSO =CreateObject("Scripting.FileSystemObject")Set oImage = DotNetFactory.CreateInstance("System.Drawing.Image")Set oFileImage = oImage.FromFile(strFromFile)Set oImageFormats = DotNetFactory.CreateInstance("System.Drawing.Imaging.ImageFormat","System.Drawing",Nothing) strToExtn = oFSO.GetExtensionName(strToFile)SelectCaseUCase(Trim(strToExtn))Case"JPEG" oFileImage.Save strToFile, oImageFormats.Jpeg Case"JPG" oFileImage.Save strToFile, oImageFormats.Jpeg Case"BMP" oFileImage.Save strToFile, oImageFormats.Bmp Case"PNG" oFileImage.Save strToFile, oImageFormats.Png Case"GIF" oFileImage.Save strToFile, oImageFo…

Change IE Browser ZOOM settings

Lot of UI automation testers could have faced this problem as we could change the zoom settings while operating manually for our convenience and forgot to reset to 100%.
But our QTP and some other related tools would operate the browser perfectly if browser zoom is 100%. So wee need to change the zoom before start to run the scripts. Its better to have a code snippet in our framework to change this zoom setting right?
Here we go...

1. We can simply change the Registry values before Invoking IE
Function ChangeRegistry Dim objShell Set objShell = CreateObject("WScript.Shell")  objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor", "100000", "REG_DWORD" Set objShell = Nothing EndFunction This option is very useful. But in real time, lot of customers could have restricted write access to windows registry. So we can try other options.

2. Use IE COM object and Change Settings
Function ChangeIEZoom Dim intZoomLevel, objIE  intZoo…