12-15-2010, 03:15 AM
Just to make sure you know, SendKeys will not work unless the window you want to send the keystrokes to is active (maybe use Window("hwnd:=" & hWnd).Activate or some other method of activating the target window). Same for Mercury.DeviceReplay, but here is the method to do it with that object (VK_MENU is Alt):
More info: Device Replay in QTP/UFT
More info: Device Replay in QTP/UFT
Code:
Const VK_CONTROL = 29
Const VK_MENU = 56
Const VK_P = 25
Set deviceReplay = CreateObject("Mercury.DeviceReplay")
deviceReplay.KeyDown VK_CONTROL
deviceReplay.KeyDown VK_MENU
deviceReplay.PressKey VK_P
deviceReplay.KeyUp VK_MENU
deviceReplay.KeyUp VK_CONTROL