Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[QTP]Keyboard control + mouse click
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
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.
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
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
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting background color of an object on mouse over Surya 2 3,951 06-27-2018, 08:51 PM
Last Post: vensas3181
  KeyBoard Events ravi.gajul 4 16,186 07-19-2017, 08:49 PM
Last Post: sathish_win@outlook.com
  How to get the links which appears on mouse hover of parent link rajendra649 9 35,695 03-10-2017, 06:35 PM
Last Post: satish00k
  how to use keyboard "Space' using qtp Naresh 2 3,192 06-11-2015, 06:30 PM
Last Post: venkatesh9032
  Automate BMC Control M applications using QTP Saranyaciet2 0 2,851 05-22-2015, 09:43 AM
Last Post: Saranyaciet2

Forum Jump:


Users browsing this thread: 2 Guest(s)