Forum Discussion

DonQuan's avatar
DonQuan
New Contributor
15 years ago

Script Extensions Runtime Object

Hi experts,



i'm using testcomplete 6.5 and try to create a runtime object which provides me some methods.

i created the description.xml and put this xml together with the script unit in an folder.

in the code completion of testcomplete i can see my runtime object, but when i choose the object it doesnt provide me the methods i included in the xml file.

could somebody help me, why i cant get the methods from my runtime object.




thanks in advance

Quan




my description.xml :





<?xml version="1.0" encoding="UTF-8"?>

<ScriptExtensionGroup Name = "My Extensions">

    <ScriptExtension Name = "WindowsCommands" Author = "Chi Quan Hong" Version = "1.0 test" HomePage = "www.automatedqa.com">

      <Script Name = "WindowsCommands.js">

        <RuntimeObject Name = "WindowsCommand">

  <Method Name = "GMatrix_CallCommand" Routine = "GMatrix_CallCommand">

  </Method>

  <Description>

   Set CheckBox.

  </Description>

   </RuntimeObject>

      </Script>

      <Description>Provides scripting interface to custom windows commands function.</Description>

    </ScriptExtension>

</ScriptExtensionGroup>




my jscript unit WindowsCommands.js:





/* 

 * Window Messages

 */

 var WM_COMMAND           = 0x0111;

 

/*

 * Button Control Messages

 */

var BM_GETCHECK        = 0x00F0;

var BM_SETCHECK        = 0x00F1;

var BST_UNCHECKED      = 0x0000;

var BST_CHECKED        = 0x0001;

var BST_INDETERMINATE  = 0x0002;

var BST_PUSHED         = 0x0004;

var BST_FOCUS          = 0x0008;







function Btn_SetCheck( hWndBtn, nCheck ) 

{

  Win32API.SendMessage(hWndBtn,BM_SETCHECK,nCheck,0 );   




}

function Btn_GetCheck( hWndBtn ) 

{

  return Win32API.SendMessage(hWndBtn,BM_GETCHECK,0,0 );   




}

function GMatrix_CallCommand( nCmdID ) 

{

  var hWnd = NameMapping.System.GMatrix.w_MainFrame.Handle;




  Win32API.PostMessage( hWnd,WM_COMMAND, nCmdID, 0 );

}



2 Replies

  • Hello Chi Quan Hong



    Your Script and XML looked fine so I just copied both and made WindowsCommand.tcx and plugged it it. I am able to see the method GMatrix_CallCommand() in the intellisense. 




    Try reloading your extension.




    Thank you

    Syed

  • Please make sure that the "character encoding" property of the script extension project is set to UTF-8 or ANSI:



    TestComplete help:

    "Script files in script extensions must use the ANSI or UTF-8 character encoding. So, we need to specify the desired encoding for script units included in the project:



    • Right-click the project node in the Project Explorer and select Edit | Properties from the context menu.

    • TestComplete will display the project editor in the Workspace panel and will activate the Properties page of the editor

    • Select the General category in the tree on the left and then specify the desired format -- ANSI or UTF-8 -- in the Character encoding box.

    • Close the project editor."


    Cheers -Klaus