How to select all text using UFT- CTRL+A and CTRL+C method
There may be some instances where you need to copy and paste or select all text using UFT. This can be achieved in many ways but one of the most important ways is to replicate what we do manually. Yes! you guessed it right. By using Ctrl+A and CTrl+C.
QTP or UFT provides an inbuilt object Mercury.Clipboard which can be used to replicate all operations for the clipboard. Here we will create two objects
Example code to select all text using UFT – Ctrl+A Ctrl+C method
Function getText_CtrlA_CtrlC()
Set objClip= CreateObject("Mercury.Clipboard")
Set DeviceReplay = CreateObject("Mercury.DeviceReplay")
objClip.Clear
Const VK_CONTROL = 29
Const VK_A = 30
Const VK_C = 46
DeviceReplay.KeyDown VK_CONTROL
Wait 0,600
DeviceReplay.PressKey VK_A
Wait 0,600
DeviceReplay.KeyUp VK_CONTROL
Wait 0,600
DeviceReplay.KeyDown VK_CONTROL
Wait 0,600
DeviceReplay.PressKey VK_C
Wait 0,600
DeviceReplay.KeyUp VK_CONTROL
Wait 0,600
getText_CtrlA_CtrlC= objClip.GetText
Set objClip= Nothing
Set DeviceReplay= Nothing
End Function
Discover more from Automation script
Subscribe to get the latest posts sent to your email.