0

I use Teraterm for my terminal program. My issue is I cannot make my script run only when I am in the teraterm program. Is there a way to make it pop into teraterm if I am in a different app?

The script works great please share it to anyone who uses teraterm.

We always use the same server ip that shows up in the window title it contains 10.155.3.8. That text is always in the title.

How do I make it execute only in teraterm. I know this is an incredibly simple question but I have spend days looking around any help would be greatly appreciated.

If you have any basic tutorial sites I would greatly appreciate it. I am a programming neophyte.

::ttwa:: ; change teraterm window name to current device or state.
SetTitleMatchMode, 2     ;// allow partial window title matches
#IfWinActive, 156.99.121.173,  156.99.121.173

send !e
sleep 10
send s
send {enter 100}
sleep 100
Send {click 3}
send !s
sleep 10
Send w
sleep 10
send %clipboard%
sleep 100
;send {backspace}
sleep 10
send {enter}
send !e s {enter}
send {enter 10}
Clipboard :=
return
1
  • Is there a way to autohotkey recognize either teraterm or putty. Commented Sep 2, 2015 at 4:57

2 Answers 2

1

There are several methods:

  1. assign a hotkey which you would press to initiate the script:

    ^+F1::
    .... send stuff
    ....
    return
    
  2. wait for the teraterm window to appear (WinWait) or become active (WinWaitActive):

    winwait, teraterm ; change to the actual window qualifications
    .... send stuff
    ....
    return
    
  3. run teraterm from your script, so you'll run the script icon instead of running teraterm directly:

    run teraterm ; change to the actual path
    winwait, teraterm ; change to the actual window qualifications
    .... send stuff
    ....
    return
    
Sign up to request clarification or add additional context in comments.

3 Comments

SetTitleMatchMode, 2 #IfWinActive, Tera Term ::srtg:: ;show run tunnel-group shpix send sh run tunnel-group {space 3} #IfWinActive return
is there a way to go a gosub a ttrw: SetTitleMatchMode, 2 ; ttrw lable for to only run in tera term #IfWinActive Tera Term
Please clarify your question.
1

Well. To me it looks like you have the answer already in your script.

From the Docs here: #IfWinActive

Creates context-sensitive hotkeys and hotstrings. Such hotkeys perform a different action (or none at all) depending on the type of window that is active or exists.

You simply have your script executing that requirement, out of order in which in needs to be.

SetTitleMatchMode, 2
#ifWinActive, 156.99.121.173,  156.99.121.173 ;Assuming this is correct
::ttwa:: ; change teraterm window name to current device or state.
send !e
sleep 10
send s
send {enter 100}
sleep 100
Send {click 3}
send !s
sleep 10
Send w
sleep 10
send %clipboard%
sleep 100
;send {backspace}
sleep 10
send {enter}
send !e s {enter}
send {enter 10}
Clipboard :=
return

As for recommendations on furthering your understanding of AutoHotkey, I strongly suggest starting with the official Tutorial.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.