Forum Discussion

tim_faron's avatar
tim_faron
Contributor
11 years ago

Alternative to Win32API commands in Script Extension

Is there an alternative to using the following code in a script extension:




Sys.Desktop.MouseDown(Win32API.VK_LBUTTON, X, Y);


Sys.Desktop.MouseUp(Win32API.VK_LBUTTON, X, Y);



When using VK_LBUTTON I am getting the following error:

 

Win32API is undefined 



Thanks
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Tim,



    The Win32API object isn't available in script extensions, so you need to explicitly define the constant:



    var VK_LBUTTON = 1;

    ...



    Sys.Desktop.MouseDown(VK_LBUTTON, X, Y);

    Sys.Desktop.MouseUp(VK_LBUTTON, X, Y);



    You can find the VK_* constant values in this MSDN article:

    Virtual-Key Codes