cancel
Showing results for 
Search instead for 
Did you mean: 

Press keyboard letter + mouse click

SOLVED
Occasional Contributor

Press keyboard letter + mouse click

Hi TestComplete Community 🙂

 

my question is:

Is it possible to hold a keyboard button and due this click the left mouse button?

In my example I need to press "p" and while hat, the left mouse button has to be clicked.

 

I know with the function Click() it is possible to press a mouse button while STRG/SHIFT/ALT is hold.

But I don't need a control key, I need just a letter like "p".

 

Is that possible in any way?

 

Thanks in advance and best regards,

Klaus from Germany

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Press keyboard letter + mouse click

I've tried that already but it doesn't work.

Consider LLPlayer object then.

Something like:

LLPlayer.KeyDown(112, 500); // check if 112 is correct code for 'p'

LLPlayer.MouseDown(MK_LBUTTON, Sys.Desktop.MouseX, Sys.Desktop.MouseY, 500);

LLPlayer.MouseUp(MK_LBUTTON, Sys.Desktop.MouseX, Sys.Desktop.MouseY, 500);

LLPlayer.KeyUp(112, 500); // check if 112 is correct code for 'p'

 

If the above does not help either, then I have no better idea at the moment but to ask Support via the https://support.smartbear.com/message/?prod=TestComplete form.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

6 REPLIES 6
Community Hero

Re: Press keyboard letter + mouse click

Hi Klaus,

 

I would recommend https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-sys-deskto... help topic.

Try something like:

<obj>.Keys("[Hold]p");

<obj>.Click();

<obj>.Keys("[Release]");

 

Does it work?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Occasional Contributor

Re: Press keyboard letter + mouse click

Hi Alex,

 

thank you for your answer!

I've tried that already but it doesn't work. (I've tried it now a second time!)

The click will be executed and the button will be pressed too I think, but it does not happen what I expect.

 

greetings

Klaus

Community Hero

Re: Press keyboard letter + mouse click

@TestOfficer Try recording a keyword test and performing the action that you want and then you can see how TestComplete codes the action.

Community Hero

Re: Press keyboard letter + mouse click

I've tried that already but it doesn't work.

Consider LLPlayer object then.

Something like:

LLPlayer.KeyDown(112, 500); // check if 112 is correct code for 'p'

LLPlayer.MouseDown(MK_LBUTTON, Sys.Desktop.MouseX, Sys.Desktop.MouseY, 500);

LLPlayer.MouseUp(MK_LBUTTON, Sys.Desktop.MouseX, Sys.Desktop.MouseY, 500);

LLPlayer.KeyUp(112, 500); // check if 112 is correct code for 'p'

 

If the above does not help either, then I have no better idea at the moment but to ask Support via the https://support.smartbear.com/message/?prod=TestComplete form.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Occasional Contributor

Re: Press keyboard letter + mouse click

Hi Alex,

 

I was able to use your suggestion with the LLPlayer successfully. The correct code for "p" is 80, so I can perfectly recreate the manual process and simulate it in automation.

 

Thank you very much and also many thanks for all other answers 🙂

 

Greetings

Klaus

Community Hero

Re: Press keyboard letter + mouse click

Hi Klaus,

 

Great! Thank you for the confirmation. I never had the need for the keys input like yours, so now I know that this is possible from test code.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors