Micro Focus QTP (UFT) Forums

Full Version: How to copy the content of a variable to clipboard - QTP 10
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I am very new to QTP and is trying to automate some part of my testing.

I have some piece of code where am trying to copy one particular file (contents) to text area in my application.

Following is what i have achieved till now.

Code:
Function readTextFromFile(pathToFile)
   Set fso = createObject("Scripting.FileSystemObject")
   If fso.FileExists(pathToFile) = True Then
                   Set f = fso.OpenTextFile(pathToFile, 1)
                   readTextFromFile = f.ReadAll
                   f.Close
   End If
End Function
text = readTextFromFile("Path of file")

After this i wanted to copy the content of "text" to clipboard so that i can use pasting it to my app text area, which hopefully by the following code.

Code:
SwfWindow("MyApplication").SwfEditor("xmlTextBox").Type micCtrlDwn + "v" + micCtrlUp

Your advices will be much helpful for me to proceed.

Thanks in advance . .

Regards
Code:
Set clipboard = createobject("mercury.clipboard")
clipboard.Clear
clipboard.SetText(text)
Thanks...Smile it worked Smile