Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-10-2019, 11:46 PM
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, 325 views)

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

Tags
keymap , script , securecrt


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:35 PM.