|
#1
|
||||
|
||||
![]()
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 --------------------------- Code:
crt.Session.Config.SetOption("Keymap v3", new Array("C VK_C DISABLED")); crt.Session.Config.SetOption("Keymap v3", "C VK_C DISABLED"); Code:
--------------------------- SecureCRT --------------------------- CRT Scripting Runtime error Error: The specified value is not valid for 'Keymap v3'. session.ini: Code:
Z:"Keymap v3"=00000001 C VK_C DISABLED 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 } 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 Last edited by seesea; 10-11-2019 at 03:12 AM. |
#2
|
|||
|
|||
SecureCRT version 7.1.3 has not been in active development since December, 2013.
What behavior do you experience if you use the current version of SecureCRT? |
#3
|
||||
|
||||
Hi Allen,
Thank you for your reply, I can't test this in the latest version because we are not allowed to install that in our office's pc. Since the help file is match the version, I think the script in the help should work on this SecureCRT, and I tested the SetOption in vbs, python and js, I found out that js not work only, but it is sure that js script can get the option object, what a pity I don't know how to operate it. Is that js is not recommended and is not supported well in CRT scripting? I prefer to use js because all of the scripts in our department are js, it is a big project to change. Bellow is my test: 1. vbs works: Code:
# $language = "VBScript" # $interface = "1.0" Set objTab = crt.GetScriptTab Set objConfig = objTab.Session.Config objConfig.SetOption "Keymap v3", Array("C VK_C DISABLED") strValue = Join(objConfig.GetOption("Keymap v3"), vbcrlf) crt.Dialog.MessageBox strValue Code:
# $language = "python" # $interface = "1.0" objTab = crt.GetScriptTab() objConfig = objTab.Session.Config arrNewValue = [] arrNewValue.append(" C VK_C DISABLED") objConfig.SetOption("Keymap v3", arrNewValue) arrValue = objConfig.GetOption("Keymap v3") strValue = ''.join(arrValue) crt.Dialog.MessageBox(strValue) Code:
# $language = "JScript" # $interface = "1.0" objTab = crt.GetScriptTab(); objConfig = objTab.Session.Config; // ar = ["C VK_C DISABLED"]; ar = new Array("C VK_C DISABLED"); objConfig.SetOption("Keymap v3", ar); strValue = objConfig.GetOption("Keymap v3").join(", "); crt.Dialog.messageBox(strValue); Code:
--------------------------- SecureCRT --------------------------- CRT Scripting Runtime error Error: The specified value is not valid for 'Keymap v3'. Last edited by seesea; 10-12-2019 at 12:41 AM. |
#4
|
|||
|
|||
Quote:
I will capture a feature request for the ability to support jscript arrays in SecureCRT's scripting API, but since you're not going to be able to upgrade even if this feature becomes available, you're stuck with using VBScript or Python. |
#5
|
||||
|
||||
Hi Allen,
Thank you for your infomation, then I know that I should look for another way to get this function, maybe I can try set the option by loading an ini file or sth else. Thanks again Allen. |
![]() |
Tags |
keymap , script , securecrt |
Thread Tools | |
Display Modes | Rate This Thread |
|
|