Micro Focus QTP (UFT) Forums
[QTP]Keyboard control + mouse click - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: [QTP]Keyboard control + mouse click (/Thread-QTP-Keyboard-control-mouse-click)



[QTP]Keyboard control + mouse click - lucieclaire - 12-17-2012

Hi every one,

i have got stuck by trying to make multi-selection of webelements. Sad I want to combinate "control button" from the keyboard and "left click" from the mouse. See the code below :

Quote:Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
'Select my First webelement
Browser("browser").Page("page").WebElement("mywebelement").Click
wait 2
WshShell.SendKeys ("^")
'Select my second webelement
Browser("browser").Page("page").WebElement("mySecondwebel").Click
Thanks for your help.

Lucie.


RE: [QTP]Keyboard control + mouse click - udayanem - 12-17-2012

You can perform the left click operation means clicking on the enter button.

So, try below:
Code:
Set o_WScript=createobject("WScript.Shell")
o_WScript.SendKeys "^+~"

^ is for Ctrl
~ is for Enter.

I hope it helps.

Regards,
Uday


RE: [QTP]Keyboard control + mouse click - lucieclaire - 12-18-2012

Hi, thanks for your reply. I found one solution work for me

Code:
Dim MyWebelement
Dim hwnd, DeviceReplay
Dim GetX, GetY

'I catch handler of IE where i will apply CTRL command
hwnd =Browser("D2_").GetROProperty("hwnd")
'I use library "Mercury.DeviceReplay" and Left Click of a mouse
Set DeviceReplay = CreateObject("Mercury.DeviceReplay")

'Command Ctrl Down on the IE
window("hwnd:=" & hwnd).type micCtrlDwn
'I get my Webelement
Set MyWebelement = Browser("browser").Page("page").WebElement("mywebelement")
'Found the position X and Y for my element i want to select
GetX = MyWebelement.GetROProperty("abs_x")
GetY = MyWebelement.GetROProperty("abs_y")
'Simulate de left click on this position (= mywebElement position)
DeviceReplay.MouseClick GetX,GetY, LEFT_MOUSE_BUTTON
wait 1
'Commnd Ctrl Up
window("hwnd:=" & hwnd).type micCtrlUp
'RAZ
Set DeviceReplay = Nothing

I hope this will help others persons ShyBig Grin
Lucie.

Someone now of to close this thread as "resolved" ? thanks Smile

Lucie.