Monday, April 30, 2012

How to copy content to Clipboard

We can use clipboard using two ways.
One is using Mercury.Clipboard.
Second one is using DotNetFactory.


Using Mercury.Clipboard:
'Creates an instance of Mercury.Clipboard
set objCB=createobject("Mercury.Clipboard")
'Here i am clearing already existing content in clipboard
objCB.Clear()
'Copying some text into Clipboard
objCB.SetText("Hello Uday")
'Retrieving the content from Clipboard
print objCB.GetText

Using DotNetFactory:
'Creates an instance of DotNetFactory Computer Object
Set objDFComputer=DotNetFactory("Microsoft.VisualBasic.Devices.Computer","Microsoft.VisualBasic")
'Here i am clearing already existing content in clipboard
Set objCB=objDFComputer.ClipBoard
objCB.clear()
'Copying some text into Clipboard
objCB.SetText("Hello Uday")
'Retrieving the content from Clipboard
print objCB.GetText

Sunday, April 29, 2012

"Setting" utility object to access registry values

We can obtain and configure all the QTP configurable parameters(all parameters in MicTest) using "Setting" utility object. Ex: BrowserType, DefaultLoadTime etc...
For Ex: If you want to retrieve the default location of saving your tests, which exists in HKLM\Software\Mercury Interactive\QuickTest Professional\MicTest\TestsDirectory, you can use below line of code:
Setting
print Setting("TestsDirectory")

You can also use Setting.Item to retrieve the value of the parameter. For the above, you can also use like:
print Setting.Item("TestsDirectory")

If you want to access a parameter exists in folders, then you can use
Setting("")("Child1")("Child2)("PropertyName")

Here is the Ex. to access the Add-In Manager name for Visual Basic.
print Setting("AddIn Manager")("VisualBasic")("Name")