View Single Post
  #1  
Old 10-11-2019, 12:46 AM
seesea's Avatar
seesea seesea is offline
Registered User
 
Join Date: Jun 2010
Posts: 20
Question How to set a key map option in script?

Hello,I wanted to set a key map in script, but failed, will anyone can help me? Thank you!
Bellow is the option's screen shot, I'd like to set it in script:


My Securecrt version is: Version 7.1.3 (build 378).

The help file says: If the option is a multi-string (Z), an array of strings should be specified for the value.
I get the property text from an ini file like below:
Code:
---------------------------
Z:"Keymap v3"=00000001
 C	VK_C                	DISABLED
---------------------------
But I failed using both the two codes:
Code:
crt.Session.Config.SetOption("Keymap v3", new Array("C	VK_C                	DISABLED"));
crt.Session.Config.SetOption("Keymap v3", "C	VK_C                	DISABLED");
CRT showed me the error message dialog:
Code:
---------------------------
SecureCRT
---------------------------
CRT Scripting Runtime error

Error: The specified value is not valid for 'Keymap v3'.
I tested the type of the option of which session has the key map value setted, only showed that is an object, not an array:
session.ini:
Code:
Z:"Keymap v3"=00000001
 C	VK_C                	DISABLED
js:
Code:
# $language = "JScript"
# $interface = "1.0"

function alert(strContent, strTitle)
{
    crt.dialog.MessageBox(strContent, strTitle);
}

function main()
{
    alert(crt.Session.Config.GetOption("Keymap v3").toString());                        // [object Object]
    alert(Object.prototype.toString.call(crt.Session.Config.GetOption("Keymap v3")));   // [object Object]
    alert(crt.Session.Config.GetOption("Keymap v3") instanceof Object);                 // False
    alert(crt.Session.Config.GetOption("Keymap v3") instanceof Array);                  // False

    var keys =[];
    testObj=crt.Session.Config.GetOption("Keymap v3");
  for(var i in testObj){
      keys.push(i);
  }
    alert(keys.join("-"));      // "" Empty string
}
When I tested in python, it showed that is a list, but no value:
Code:
# $language = "Python"
# $interface = "1.0"

obj=crt.Session.Config.GetOption("Keymap v3")
crt.Dialog.MessageBox('\n'.join(obj))     // ""
crt.Dialog.MessageBox(type(obj).__name__) // list
Attached Images
File Type: jpg keymap.jpg (32.8 KB, 1290 views)

Last edited by seesea; 10-11-2019 at 04:12 AM.
Reply With Quote