Beruflich Dokumente
Kultur Dokumente
#$interface = "1.0"
# ColorSchemeAutoRotation.py
# Last Modified: 5 Sep 2013
#
# Description:
# This script will automatically rotate to the next Color Scheme
# each time a connection is made with the current session.
# For example (in a default SecureCRT configuration), if the
# color scheme for the current session is currently set to
# "Black / Cyan", the color scheme will automatically be
# set to "Floral White / Dark Cyan". The next time the
# session is used for making a connection, the color
# scheme will change from "Floral White / Dark Cyan" to
# "White / Black", and so on each time the session is used
# to connect.
#
# Although it is suggested that you use this script as a logon script
# you can also choose to create a button to run the script manually
# (for example if you don't like the current color scheme and want to
# manually rotate to the next one). For information on creating a
# button to run this script, read through the button bar tip online:
# http://www.vandyke.com/support/tips/buttonbar.html
#
# ... or view the Button Bar video on the VanDyke Software YouTube
# channel:
# https://www.youtube.com/VandykeSoftware
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsgBox = crt.Dialog.MessageBox
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def main():
# Make our global variables available to us in this routine
global bColorsLoadedFromConfig
global g_cColorSchemes
global g_cSchemeIndices
strConfigPath = ""
if sys.platform.startswith('darwin'):
# Load configuration folder from user "defaults" on
# Mac OS X:
from Foundation import CFPreferencesCopyAppValue
strConfigPath = CFPreferencesCopyAppValue(
"Config Path",
"com.vandyke.SecureCRT")
# Now let's iterate through all the color scheme names and populate
# two dictionaries (hash tables) one indexed by scheme name, the
# other by index of appearance (so that rotating is easier -- by
# knowing where we are currently, it will be easier to find out the
# next one in line):
nIndex = 0
for strColorSchemeName in regexp.findall(strColorSchemeData):
if not strColorSchemeName in g_cColorSchemes:
g_cColorSchemes[strColorSchemeName] = nIndex
g_cSchemeIndices[nIndex] = strColorSchemeName
if not bColorsLoadedFromConfig:
bColorsLoadedFromConfig = True
nIndex += 1
else:
MsgBox("Unable to locate Color Schemes.ini file in config path: " +
strConfigPath)
return
else:
# Unable to read existing color schemes from the Color Schemes.ini file
MsgBox(
"Error: Unable to determine location of current configuration " +
"path in order to load existing color schemes.\r\n\r\n" +
"You're probably running SecureCRT with a configuration folder " +
"that exists where SecureCRT.exe lives, or you're running with " +
"the /F <special_path_to_config_folder> option, and we can't " +
"cope with that in SecureCRT yet.\r\n\r\n" +
"Script is unable to proceed further.")
return
# Get a reference to the current script tab so that we can be "tab safe"
objCurTab = crt.GetScriptTab()
main()