Description
The GlobalConfiguration object provides methods for accessing global configuration through scripting.
Syntax
GlobalConfiguration Object Properties and Methods
|
|
|
|
|
Description
Returns the global configuration.
Remarks
This configuration will not be saveable to a new name.
VBScript
Syntax
Set objectvarname = object.Config
Example
Set config = crt.Config
Python
Syntax
objectvarname = object.Config
Example
config = crt.Config
Description
Gets the value of the specified option.
Remarks
OptionName is a string parameter that is the name of the option as seen in the global configuration .ini file (Global.ini), which corresponds to the configuration option being retrieved. Note that option names in the .ini file are not always identical to the labels found in the Global Options dialog. This method returns the value of the specified option. If the option is a string type (S), a string is returned. If the option is a multi-string (Z), an array of strings is returned. If the option is a DWORD (D), an integer is returned.
VBScript
Syntax
varname = object.GetOption(OptionName)
Example
' In the following example, the "Show confirm disconnect
' dialog" option in the General category of the Global
' Options dialog is disabled if enabled:
bConfirmDisconnect = crt.Config.GetOption("Show Confirm Disconnect Dialog")
If bConfirmDisconnect Then
crt.Config.SetOption "Show Confirm Disconnect Dialog", False
End If
' In the following example, the "Reuse disconnected tabs"
' option in the "Terminal / Tabs/Tiling" category of the Global
' Options dialog is disabled if enabled:
bReuseDisconnTab = crt.Config.GetOption("Reuse Disconnected Tabs")
If bReuseDisconnTab Then
crt.Config.SetOption "Reuse Disconnected Tabs", False
End If
' In the following example, the "Show status indicators as
' ..." option in the "Terminal / Tabs/Tiling" category of
' the Global Options dialog is checked to see what is
' presently configured (note that Background Colors is not
' availableon Mac/Linux).
nTabStyle = crt.Config.GetOption("Status Indicator Style")
Select Case cInt(nTabStyle)
Case 0
crt.Dialog.MessageBox("Status indicators for tabs = Default Icons")
Case 1
crt.Dialog.MessageBox("Status indicators for tabs = Background Colors")
Case 2
crt.Dialog.MessageBox("Status indicators for tabs = Color Rectangles")
End Select
Python
Syntax
varname = object.GetOption(OptionName)
Example
# In the following example the GUI option 'When a session is
# renamed/moved, update sessions that use it as a firewall'
# in the General category of the Global Options dialog is
# disabled if enabled:
if crt.Config.GetOption("Update Dependent Session Firewalls"):
crt.Config.SetOption("Update Dependent Session Firewalls", False)
# In the following example the GUI option 'Connect to
# multiple sessions sequentially' in the Terminal / Advanced
# category of the Global Options dialog is enabled if
# disabled:
if not crt.Config.GetOption("Serialize Connections"):
crt.Config.SetOption("Serialize Connections", True)
# In the following example the GUI option 'Paste on
# middle/right button' in the Terminal category of the
# Global Options is checked for current state:
strRight = crt.Config.GetOption("Paste On Right Button")
strMiddle = crt.Config.GetOption("Paste On Middle Button")
if strRight == 0 and strMiddle == 0:
crt.Dialog.MessageBox("Paste on middle/right button option disabled")
elif strRight == 1:
crt.Dialog.MessageBox("Paste on right button option enabled")
elif strMiddle == 1:
crt.Dialog.MessageBox("Paste on middle button option enabled")
Description
Saves the configuration.
VBScript
Syntax
object.Save
Python
Syntax
object.Save()
Description
Sets the specified option to the specified value.
Remarks
OptionName is a string parameter that is the name of the option as seen in the global configuration .ini file (Global.ini), which corresponds to the configuration option being changed. Note that option names in the .ini file are not always identical to the labels found in the Global Options dialog. Value is the value to set the option to. If the option is a string type (S), a string should be specified for the value. If the option is a multi-string (Z), an array of strings should be specified for the value. If the option is a DWORD (D), the value should be numeric. If there is an error this method will display a error message box. If the errors are not being displayed, the error message can be retrieved by using crt.GetLastErrorMessage.
VBScript
Syntax
object.SetOption OptionName, Value
Example
' In the following example, the config option for "Maximum
' columns" in the "Terminal / Appearance" category of
' the Global Options dialog is changed to user specified
' value.
nCurMaxCols = crt.Config.GetOption("Max Columns")
nNewMaxCols = crt.Dialog.Prompt("Current columns value is: " & _
nCurMaxCols & "." & vbcrlf & _
"Specify new value (from 132 to 32000).")
If nNewMaxCols = "" Then
crt.Dialog.MessageBox "No changes made."
End If
If nNewMaxCols < 132 or nNewMaxCols > 32000 Then
crt.Dialog.MessageBox "Invalid value specified. No changes made."
Else
crt.Config.SetOption "Max Columns", nNewMaxCols
crt.Dialog.MessageBox "Changing Max Columns requires a quit/restart of SecureCRT."
End If
' In the following example, the config option for "Hex
' view buffer" in the "Terminal / Appearance" category of
' the Global Options dialog is changed to user specified
' value.
nCurHexBuffer = crt.Config.GetOption("Hex View Buffer")
nNewHexBuffer = crt.Dialog.Prompt("Current hex view buffer value is: " & _
CInt(nCurHexBuffer) & "." & vbcrlf & _
"Specify new value (from 132 to 32000).")
If nNewHexBuffer = "" Then
crt.Dialog.MessageBox "No changes made."
End If
If nNewHexBuffer < 132 or nNewHexBuffer > 32000 Then
crt.Dialog.MessageBox "Invalid value specified. No changes made."
Else
crt.Config.SetOption "Hex View Buffer", nNewHexBuffer
End If
Python
Syntax
object.SetOption(OptionName, Value)
Example
# In the following example, the config option for "Initially
# send commands to" in the 'Terminal / Advanced' category of
# the Global Options dialog is changed, if necessary.
#Initial Send Commands To Value
#0 = Active; 1 = All Session; 2 = Visible
nInitSendCmdState = crt.Config.GetOption("Initial Send Commands To Value")
strBegText = "Currently Initial Command Window Send To functionaliy is configured as "
strEndText = ".\r\nWhat state would you like?\r\n" + \
"\t0 = Active Session\r\n" + \
"\t1 = All Sessions\r\n" + \
"\t2 = Visible Sessions\r\n\r\n" + \
"(Since this is an 'initial state' config option, you will need \r\n" + \
"to quit/restart SecureCRT to see the new value reflected.)"
if nInitSendCmdState == 0:
strCurrState = "Active Session"
elif nInitSendCmdState == 1:
strCurrState = "All Sessions"
elif nInitSendCmdState == 2:
strCurrState = "Visible Sessions"
nResponse = crt.Dialog.Prompt(strBegText + strCurrState + strEndText,
"Set Command Window Send To Functionality")
if nResponse == "" or int(nResponse) < 0 or int(nResponse) > 2:
crt.Dialog.MessageBox("No changes made due to invalid data or same value entered.")
nResponse = nInitSendCmdState
if int(nResponse) != nInitSendCmdState:
crt.Config.SetOption("Initial Send Commands To Value", int(nResponse))
# In the following example, the config option for "Show
# connect bar" in the 'General' category of the
# Global Options dialog is changed, if necessary.
nInitState = crt.Config.GetOption("Show Connect Bar")
if nInitState == 1:
crt.Config.SetOption("Show Connect Bar", 0)
# In the following example, the config option for "Show
# button bar on ..." in the 'Terminal / Appearance'
# category of the Global Options dialog is changed,
# if necessary.
nInitState = crt.Config.GetOption("Button Bar Location")
if nInitState == 0:
crt.Config.SetOption("Button Bar Location", 1)
# In the following example, the config option for "Custom
# menu and toolbar file" in the 'Terminal / Advanced' category
# of the Global Options dialog is changed, if necessary.
BUTTON_YESNO = 4 # Yes and No buttons
BUTTON_YESNOCANCEL = 3 # Yes, No, and Cancel buttons
IDCANCEL = 2 # Cancel button clicked
IDYES = 6 # Yes button clicked
IDNO = 7 # No button clicked
strCurrMenuToolbar = crt.Config.GetOption("Menu Toolbar File V2")
if strCurrMenuToolbar == "":
nResponse = crt.Dialog.MessageBox("Currently no custom menu file is configured.\r\n" +
"\r\nDo you want to specify a custom menu file?\r\n",
"Change Menu Toolbar File?",
BUTTON_YESNO)
else:
nResponse = crt.Dialog.MessageBox("Current Menu File: " + strCurrMenuToolbar +
"\r\nDo you want to specify a new file?\r\n"
"\tYes\t- Specify new menu file\r\n"
"\tCancel\t- Clear current file\r\n"
"\tNo\t- No changes",
"Change Menu Toolbar File?",
BUTTON_YESNOCANCEL)
if nResponse == 6:
strNewMenuToolbar = crt.Dialog.FileOpenDialog(title="Please select a menu file", filter="Menu Files (*.mnu)|*.mnu||")
if strNewMenuToolbar == "":
crt.Dialog.MessageBox("Cancel pressed or no file selected. No changes made.")
else:
crt.Config.SetOption("Menu Toolbar File V2", strNewMenuToolbar)
elif nResponse == 2:
crt.Config.SetOption("Menu Toolbar File V2", "")
else:
crt.Dialog.MessageBox("No changes made.")