1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

keyboard shotcuts to send commands to a TCC tab?

Discussion in 'Support' started by electrotype, May 14, 2010.

  1. electrotype

    Joined:
    May 5, 2010
    Messages:
    9
    Likes Received:
    0
    I'm new to Take Command and I'm learning it...

    Is it possible to make a keyboard key send a command to a TCC tab? In fact, I would like the ESC key to send "cls" + [enter]. Is it possible?

    I saw KEYSTACK and Key Mapping Directives but I'm not sure this is what I'm looking for.
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    This is the sort of thing that keystroke aliases are for:

    Code:
    alias @@f5=cls
    Unfortunately, the ESC key already has a function assigned; it clears the current command line. If you want to use it for CLS instead, you'll have to remove default mapping:

    Code:
    alias @@esc=cls
    option //normalkey=esc
    
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    | ---Quote (Originally by electrotype)---
    || I'm new to Take Command and I'm learning it...
    ||
    || Is it possible to make a keyboard key send a command to a TCC tab?
    || In fact, I would like the ESC key to send "cls" + [enter]. Is it
    || possible?
    ||
    || I saw KEYSTACK and Key Mapping Directives but I'm not sure this is
    || what I'm looking for.
    | ---End Quote---
    | This is the sort of thing that keystroke aliases are for:
    |
    |
    | Code:
    | ---------
    | alias @@f5=cls
    | ---------
    | Unfortunately, the ESC key already has a function assigned; it
    | clears the current command line. If you want to use it for CLS
    | instead, you'll have to remove default mapping:
    |
    |
    | Code:
    | ---------
    | alias @@esc=cls
    | option //normalkey=esc
    | ---------

    One more point. The method Charles described works in either one of the
    situations below:

    1/ TCC runs stand-alone in its own window, and the window has focus when you
    press the selected key, and TCC is waiting for keyboard input at the command
    prompt; OR

    2/ TCC runs in a TCMD tab, TCMD has focus, the intended TCC tab is currently
    active, and TCC is waiting for keyboard input at the command prompt when you
    press the selected key.

    In other words, the keystroke must be delivered by Windows to TCMD, and by
    TCMD to TCC, or directly by Windows to TCC, AND TCC must be ready to accept
    and process it. Note:

    1/ there is no mechanism for Windows to deliver a keystroke to any window
    other than the currently active one, i.e., the one which has focus

    2/ there is no mechanism for TCMD to deliver a keystroke to any tab other
    than the currently active one

    3/ if TCC is not waiting for a keystroke, a keystroke delivered to TCC is
    not acted upon until TCC is ready to receive it, and some commands will
    delete keystrokes waiting to be processed.

    There are mechanisms in Windows to activate a specific window by
    keystrokes. These keystrokes are intercepted by Windows no matter what
    program has focus, and activate the desired window, but are not delivered to
    the program running in that window. The alt-tab keystroke changes the focus
    to the next window. If a window was created using a hotkey to execute a
    desktop shortcut, under most circumstances the same hotkey will activate
    that window (though on rare occasion the hotkey will execute the shortcut
    instead). On my own systems I combine the alt-cntl-shift modifiers with
    normal keys as shortcut hotkeys and window activators, because keystrokes
    including that combination of modifiers are always intercepted by Windows,
    so they cannot be used by applications, and are thus unique.
    --
    HTH, Steve
     
  4. electrotype

    Joined:
    May 5, 2010
    Messages:
    9
    Likes Received:
    0
    Thanks to both of you, it works great!
     
  5. electrotype

    Joined:
    May 5, 2010
    Messages:
    9
    Likes Received:
    0
    Welll.. It works great when I type those commands in a TCC tab directly, but I'm unable to make them loaded automatically, from a .ini file. This is the first time I create a .ini file... Any help?

    I created a TCMD.INI in the TCMD install directory. I tried this as the content:

    Code:
    alias @@esc=CLS /S 
    option //normalkey=esc
    
    Code:
    ALIAS @@esc=CLS /S 
    OPTION //normalkey=esc
    
    Code:
    esc=CLS /S 
    //normalkey=esc
    
    Code:
    [4NT]
    alias=@@esc=CLS /S 
    option //normalkey=esc
    
    Code:
    [alias]
    esc=CLS /S 
    [option]
    normalkey=esc
    
    It always results in "invalid item name" or nothing at all occures.

    What do I do wrong?
     
  6. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    Look at tcstart.btm instead of tcmd.ini

    Sent from Cookie's iPhone
    Jim Cook

    On May 15, 2010, at 3:38, electrotype <> wrote:


     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Aliases, environment variables and variable functions can only be
    defined or modified by TCC commands ALIAS, SET, and FUNCTION, respectively.
    The can be deleted (undefined) by the same commands using an empty string
    after the equal sign "=", or more simply by the respecting "UNxxx" commands.
    That's one of the fundamental issues with all of your attempts.
    All directives (applicable to a specific version of TCMD / TCC) are
    always "set", i.e., if the relevant SECTIONs of your .INI file do not assign
    values to them explicitly, they receive a DEFAULT value. The primary way to
    modify these values is by using the OPTION pull-down menu in TCMD, or the
    DIALOG mode of the OPTION command in TCC, which modify, or (if necessary)
    create the appropriate SECTION and DIRECTIVE entries in the SAME .INI file
    which was used to start the current instance of TCMD or TCC, and are used in
    all future invocations of the program that are started without explicit
    filespecifation of the .INI file to be used. TCC directives can be modified
    for the current instance of TCC only (and inherited by such instances that
    are create either by PIPING or by the START command without using an
    explicit filespecifiation of the .INI file) using the OPTION command as
    described in help topic "option.htm".
    Which .INI file the current instance of TCC used is availabe as the
    value of the _ININAME internal variable. You can display it using the
    command "echo %_ininame". This is the file that the dialog mode of of the
    OPTION command would modify. If your TCC instance is running in a TCMD tab,
    this .INI file is not necessarily the same as the .INI file which was used
    when you started TCMD (e.g. if you used TCMD's OPTION dialog for it to
    automatically create a TCC TAB with a command line which specifies a .INI
    file). If your TCC tab was started in the default manner, TCMD's OPTION
    pull-down menu allows you to modify the TCC options.

    The TCC commands [UN]ALIAS, [UN]FUNCION, OPTION and [UN]SET allow you to
    manipulate more than one entry at a time, using a file of definitions. The
    definition syntax at the command line is different from the syntax in a
    definition file. Each line in a definition file specifies a single item, and
    is essentially in the format "name=value", and all values are used exactly
    as entered (e.g. if the line contains a percent sign % followed by the name
    of a variable it is not expanded to be the current value of the variable, it
    is just placed in value AS WRITTEN). I believe that SECTION headers are
    ignored in directive files loaded by the OPTION command (using OPTION
    @file).

    To manipulate the .INI file which started the current instance of TCC
    your best method is to use the @INIREAD function to determine whether or not
    it changes the default, and the @INIWRITE function to modify it for future
    TCC instances:

    echo Directive ANSI=%@iniread[%_ininame,4NT,ANSI]
    echo %@iniwrite[%_ininame,4NT,ANSI,yes]
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,856
    Likes Received:
    83
    Those belong in your TCSTART.BTM file, not your TCMD.INI.

    Rex Conn
    JP Software
     
  9. electrotype

    Joined:
    May 5, 2010
    Messages:
    9
    Likes Received:
    0
    Thanks for all the replies, it's fully working now!
     

Share This Page