When a variable isn't declared within a function library, you may notice different things: An Environment variable declared within an action can be used by another action, but this statement does not hold true for normal variables (declared via Public, Private, Dim). Any other variable declared in one action cannot be seen in another. Private variables when declared in a function library cannot ...
Custom Search
Wednesday, November 21, 2012
Difference between Mercury DeviceReplay and Sendkeys
The Device Replay feature is used to perform mouse and keyboard actions against screen coordinates that are provided. The Device Replay functions are not automatically recorded, but must be programmed manually in the Expert View.
1. Create the Device Replay Object.
Example:
Set DeviceReplay = CreateObject(“Mercury.DeviceReplay”)
2. Call the desired Device Replay function.
Example:
DeviceReplay.SendString(“Hello, World”)
3. When done with the Device Replay object, release it.
Example:
Set DeviceReplay = Nothing
The functions that can be used with the Device Replay object are (all coodinates are relative to the top left corner of the screen):
Mercury DeviceReplay is a powerful utility to simulate keyboard input and also for simulating mouse clicks and movements. Under Java Add-in, you can find the DeviceReplay property.
We use SendKeys method to send keyboard input/keystrokes to applications that dont have automation interface. We can also send more than one keystroke at a time using Sendkeys method. To send keystrokes x,y and z, you would send the string argument "xyz".
So, the difference between Mercury DeviceReplay and Sendkeys is
SendKeys -> Support only Keyboard Operations
DeviceReplay-> Support Keyboard + Mouse Operations like Drag Drop too.
In addition to that DeviceReplay supports sending multilingual characters and symbols, while sendkeys support limited keyboard operations.
The other operational difference is dependency on QTP software.
Mercury.DeviceReplay :- It comes with QTP as a module, so you need QTP on the system and only from QTP action you can use it.
SendKeys :- It could be used in VBS script to simulate keyboard inputs with native windows shell commands. It has no dependency on QTP as such.
1. Create the Device Replay Object.
Example:
Set DeviceReplay = CreateObject(“Mercury.DeviceReplay”)
2. Call the desired Device Replay function.
Example:
DeviceReplay.SendString(“Hello, World”)
3. When done with the Device Replay object, release it.
Example:
Set DeviceReplay = Nothing
The functions that can be used with the Device Replay object are (all coodinates are relative to the top left corner of the screen):
Mercury DeviceReplay is a powerful utility to simulate keyboard input and also for simulating mouse clicks and movements. Under Java Add-in, you can find the DeviceReplay property.
We use SendKeys method to send keyboard input/keystrokes to applications that dont have automation interface. We can also send more than one keystroke at a time using Sendkeys method. To send keystrokes x,y and z, you would send the string argument "xyz".
So, the difference between Mercury DeviceReplay and Sendkeys is
SendKeys -> Support only Keyboard Operations
DeviceReplay-> Support Keyboard + Mouse Operations like Drag Drop too.
In addition to that DeviceReplay supports sending multilingual characters and symbols, while sendkeys support limited keyboard operations.
The other operational difference is dependency on QTP software.
Mercury.DeviceReplay :- It comes with QTP as a module, so you need QTP on the system and only from QTP action you can use it.
SendKeys :- It could be used in VBS script to simulate keyboard inputs with native windows shell commands. It has no dependency on QTP as such.
work with the DLL's in QTP
'Declare FindWindow method
Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
'Declare SetWindowText method
Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, micString
'Get HWND of the Notepad window
hwnd = Extern.FindWindow("MicrosoftExcel", vbNullString)
if hwnd = 0 then
MsgBox "Notepad window not found"
else
msgbox hwnd
end if
'Change the title of the notepad window
res = Extern.SetWindowText(hwnd, "kuku")
Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
'Declare SetWindowText method
Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, micString
'Get HWND of the Notepad window
hwnd = Extern.FindWindow("MicrosoftExcel", vbNullString)
if hwnd = 0 then
MsgBox "Notepad window not found"
else
msgbox hwnd
end if
'Change the title of the notepad window
res = Extern.SetWindowText(hwnd, "kuku")
set Off for Image capture while execution from QTP options
Rem Using below option to uncheck ImageCapture Option
Set qtpobj=Createobject("Quicktest.application")
qtpobj.Options.Run.ImageCaptureForTestResults= "Never"
Set qtpobj=Nothing
Set qtpobj=Createobject("Quicktest.application")
qtpobj.Options.Run.ImageCaptureForTestResults= "Never"
Set qtpobj=Nothing
To set automatically detect settings On/Off in IE
'Example use of IEautomaticallydetect
IEautomaticallydetect "off"
IEautomaticallydetect "show"
IEautomaticallydetect "on"
IEautomaticallydetect "show"
SUB IEautomaticallydetect (status)
DIM sKey,sValue,binaryVal
Dim oReg
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Const HKCU=&H80000001
sKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections"
sValue = "DefaultConnectionSettings"
oReg.GetBinaryValue HKCU, sKey, sValue, binaryVal
select case lcase(status)
case "on" binaryVal(8) = binaryVal(8) OR 8 'Force Autodetect on
case "off" binaryVal(8) = binaryVal(8) XOR 8 'Force Autodetect off
case "show" print "Automatically detect is set to " & ((binaryVal(8) and 8) = 8)
case else print "Invalid parameter - IEautomaticallydetect on, off or show"
end select
if lcase(status)="on" or lcase(status)="off" then oReg.SetBinaryValue HKCU, sKey, sValue, binaryVal
end sub
IEautomaticallydetect "off"
IEautomaticallydetect "show"
IEautomaticallydetect "on"
IEautomaticallydetect "show"
SUB IEautomaticallydetect (status)
DIM sKey,sValue,binaryVal
Dim oReg
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Const HKCU=&H80000001
sKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections"
sValue = "DefaultConnectionSettings"
oReg.GetBinaryValue HKCU, sKey, sValue, binaryVal
select case lcase(status)
case "on" binaryVal(8) = binaryVal(8) OR 8 'Force Autodetect on
case "off" binaryVal(8) = binaryVal(8) XOR 8 'Force Autodetect off
case "show" print "Automatically detect is set to " & ((binaryVal(8) and 8) = 8)
case else print "Invalid parameter - IEautomaticallydetect on, off or show"
end select
if lcase(status)="on" or lcase(status)="off" then oReg.SetBinaryValue HKCU, sKey, sValue, binaryVal
end sub
Subscribe to:
Posts (Atom)