Forum Discussion

lhuang5's avatar
lhuang5
Occasional Contributor
11 years ago

How to simulate Left Ctrl key pressed?

Hello,



We need to keep Ctrl and Left-Ctrl key pressed in our application in order to open two dialogs which are using different technology.



Use this way for Ctrl key pressed 

Sys.Desktop.KeyDown(VK_CONTROL); // Press Ctrl

//Open operation.

Sys.Desktop.KeyUp(VK_CONTROL);   // Release Ctrl



Our engineers are using [X163] as Left-Ctrl key's virtual-key code. This virtual-ley code seems not to be supported in TestComplete.



Wonder whether this is the correct way using KeyDown and KeyUp. And how can we simulate the Left-Ctrl key pressed.



Thanks

Liping



  • Hi Liping,



    I believe that LLPlayer object (see TC help) with Win32API.VK_LCONTROL and Win32API.VK_RCONTROL constants should work for you.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Liping,



    I believe that LLPlayer object (see TC help) with Win32API.VK_LCONTROL and Win32API.VK_RCONTROL constants should work for you.
  • lhuang5's avatar
    lhuang5
    Occasional Contributor
    Sorry for some wrong information in submitted post.



    My concern is that we can only press Ctrl key. Wonder how to simulate RightCtrl and LeftCtrl seperately.



    Thanks again.



    Liping
    • fazlook's avatar
      fazlook
      Frequent Contributor

      Something like this-->  (I do right click here)

       

      grid.ClickR(((grid.ScreenLeft + grid.Width) / 2), ((grid.ScreenTop + grid.Height) / 2)) where Grid is your Object.