Send a combination of keys - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: Send a combination of keys (/Thread-Send-a-combination-of-keys) |
Send a combination of keys - PrabhatN - 12-09-2010 Hi All, I need to press "Ctrl + Alt + P" at a time to enable an edit box and I wrote the code below but it didn't work. Code: Set WShell = CreateObject("WScript.Shell") I tried even few more combinations but without success. Can anybody come up with a solution? RE: Send a combination of keys - umashekar07 - 12-10-2010 Hi, it will work properly I need to press "Ctrl + Alt + P" at a time to enable an edit box and I wrote the code below but it didn't work. [quote]Set WShell = CreateObject("WScript.Shell") WShell.SendKeys "^%p" RE: Send a combination of keys - PrabhatN - 12-13-2010 It did not work either. RE: Send a combination of keys - cdesserich - 12-15-2010 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 Code: Const VK_CONTROL = 29 RE: Send a combination of keys - PrabhatN - 12-16-2010 Thanks man..It works perfect. RE: Send a combination of keys - NevadaMike - 01-19-2011 This does work REALLY well! Thanks for sharing it. Just curious...is "VK_" just preference or does it have a purpose? RE: Send a combination of keys - cdesserich - 01-20-2011 It stands for "Virtual Key." The actual enumerations in .NET are named that way. In VBScript, it's just easier to define the constants in the script than try to figure a way to get the values from the .NET framework. RE: Send a combination of keys - NevadaMike - 01-20-2011 Ah, thank you for the clarification. I've had to head into QTP without a VB background. I did do some programming (long before VB was created) and have been scripting in Second Life, so the logic behind it all is familiar, but I was unaware of the conventions. Thanks again. |