Valeria Basov
Valeria Basov

Reputation: 11

Sendkeys in UFT 14.51

I need to enter the combination of alt + enter in UFT14.51. I've searched all day for the solution, but I have yet to find a viable solution. :(

Maybe someone knows some magic way to do it?

Here's what I tried: %enter, TE_ALT+TE_ENTER and a few other other combinations like that but to no avail. :(

Upvotes: 1

Views: 847

Answers (4)

Pooja Kulkarni
Pooja Kulkarni

Reputation: 11

Try this code which I use for such kind of combination of keypress events in UFT:

Dim altEnter
Set altEnter = CreateObject("Mercury.DeviceReplay")

altEnter.Keydown 56
altEnter.PressKey 28
altEnter.Keyup 56

altEnter = Nothing

Upvotes: 1

RichEdwards
RichEdwards

Reputation: 3753

UFT has reserved variables for this. You can type modifier key combinations with lines such as micAltDwn & micReturn & micAltUP

The one thing that normally catches me out with this is if its micAltDown or micAltDwn - I'm sure it's the latter but if one doesn't work try the other.

Have a look here for a simple example: https://admhelp.microfocus.com/uft/en/15.0-15.0.1/UFT_Help/Content/User_Guide/Run_Close_App_Program.htm?Highlight=micAltDown

Beyond that google "micAltDwn" and you'll find loads of references to these commands.

Finally, depending on the type of application you're testing, if you continue to struggle it's sometimes useful to do these commands through the standard windows object.

Upvotes: 1

Pranav
Pranav

Reputation: 445

You may try DeviceReplay method

Set mydp = CreateObject("mercury.devicereplay")
mydp.Keydown 56

You can search more on this and use the way you want to, this is to get you started.

Upvotes: 1

Bill Hileman
Bill Hileman

Reputation: 2836

Here's how I send a tab character in my VB 6.0 application. I'll leave it up to you do figure out what the key codes are that you need to send.

' Declares and constants for SendTab sub

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
                                              ByVal bScan As Byte, _
                                              ByVal dwFlags As Long, _
                                              ByVal dwExtraInfo As Long)

Private Const VK_TAB = &H9
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2

Sub SendTab()

10      On Error GoTo SendTab_Error

20      keybd_event VK_TAB, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0

30      keybd_event VK_TAB, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0

40      On Error GoTo 0
50      Exit Sub

SendTab_Error:

60      LogErr "Error " & Err.Number & " (" & Err.Description & ") " & _
               IIf(Erl <> 0, "on line " & CStr(Erl) & " of", "in") & _
               " procedure SendTab of Module mMisc"

End Sub

Upvotes: 0

Related Questions