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
Solved! Go to Solution.
> 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.
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?
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
@TestOfficer Try recording a keyword test and performing the action that you want and then you can see how TestComplete codes the action.
> 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.
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
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.
Subject | Author | Latest Post |
---|---|---|