ELIZA / STARWARS ( TELNET )

Post your working scripts, libraries and tools for AHK v1.1 and older
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

ELIZA / STARWARS ( TELNET )

05 Mar 2015, 03:05

Telnet.exe telehack.com / send to DOS example
( modified 20180517 for win10 4K )
copy telnet.exe to C:\windows\sytem32 ( if not exist )


https://technet.microsoft.com/pt-pt/lib ... s.10).aspx
http://telehack.com/telehack.html
http://en.wikipedia.org/wiki/Joseph_Weizenbaum

Eliza, Morse , Cow , Basic

Code: Select all

;modified=20180517   win10 4K
;------- Send to DOS telehack MORSE ELIZA BASIC etc ----
;=================================================
;- telnet.exe in folder C:\Windows\system32
;- https://technet.microsoft.com/pt-pt/library/cc787407(v=ws.10).aspx
;- http://telehack.com/telehack.html

;- telnet telehack.com 
;- ELIZA /BASIC
;- help /all

SetKeyDelay,20,20
wa:=A_screenwidth
ha:=A_screenHeight
GW :=(wa*50)/100    ;- width
GH :=(ha*95)/100    ;- height

;- telnet is in C:\windows\sytem32
telnet1a=%a_windir%\system32\telnet.exe

;- or 
;Telnet1=%A_ScriptDir%\..\..\Programs_SA\telnet\telnet.exe
;loop,%Telnet1%                                                ;- create shortpath
;   telnet1a= %A_loopFileShortPath%

DosCommand=%telnet1a% telehack.com  

e4x=
(Ltrim Join&
mode con lines=4096 cols=180
color 0A
%doscommand%
)

Run, %COMSPEC% /k %e4x%,,,pid1           ;- start DOS and send commands
WinWait, ahk_pid %pid1%                  ;
WinWaitActive, ahk_pid %PID1%            ; 
WinMove,ahk_pid %PID1%,,1,1,%gw%,%gh%    ;- DOS at left 
sleep,500
gosub,telehack
return
;--------------------

;--------------------
telehack:
sleep,1000
controlsend,,cowsay /cow /joke Hello %a_username% (use ESC-button to quit or CTR+C to break)`r,ahk_pid %pid1%
sleep,4000
controlsend,,morse SOS Hello %a_username%`r,ahk_pid %pid1%
sleep,2000
controlsend,,ELIZA`r,ahk_pid %pid1%
sleep,4000
controlsend,,Hi my name is %a_username%`r,ahk_pid %pid1%
sleep,5000
controlsend,,My problem is I like autohotkey`r,ahk_pid %pid1%
sleep,5000
controlsend,,^c`r,ahk_pid %pid1%
sleep,2000
controlsend,,basic`r,ahk_pid %pid1%
sleep,2000
controlsend,,a=100:c=(a*3):print "Result=";c`r,ahk_pid %pid1%
sleep,2000
controlsend,,print"Use button ESC to quit"`r,ahk_pid %pid1%
return
;---------------------

esc::
controlsend,,q`r,ahk_pid %pid1%
sleep,1000
controlsend,,cowsay /cow /dead Good bye %a_username% now you quit Telnet & DOS`r,ahk_pid %pid1%
sleep,4000
controlsend,,quit`n,ahk_pid %pid1%
sleep,500
controlsend,,%a_space%exit`n,ahk_pid %pid1%
sleep,500
Process, Close, %pid1%
Process, WaitClose, %pid1%
process,close,telnet.exe
ExitApp
;========= END script ==================
Telehack news from 1985

Code: Select all

;- telnet telehack.com 
;- read news example from 1985
;- help /all
;- towel.blinkenlights.nl  only for starwars ascii-game


SetKeyDelay,20,20
wa:=A_screenwidth
ha:=A_screenHeight
GW :=(wa*50)/100    ;- width
GH :=(ha*95)/100    ;- height

;- telnet is in C:\windows\sytem32
telnet1a=%a_windir%\system32\telnet.exe

;- or 
;Telnet1=%A_ScriptDir%\..\..\Programs_SA\telnet\telnet.exe
;loop,%Telnet1%                                                ;- create shortpath
;   telnet1a= %A_loopFileShortPath%

DosCommand=%telnet1a% telehack.com  

e4x=
(Ltrim Join&
mode con lines=4096 cols=180
color 0A
%doscommand%
)

Run, %COMSPEC% /k %e4x%,,,pid1           ;- start DOS and send commands
WinWait, ahk_pid %pid1%                  ;
WinWaitActive, ahk_pid %PID1%            ; 
WinMove,ahk_pid %PID1%,,1,1,%gw%,%gh%    ;- DOS at left 
sleep,500
gosub,telehack
return
;--------------------
telehack:
sleep,1500
controlsend,,%a_space%cowsay /cow /joke Hello %a_username% (use ESC-button to quit or CTR+C to break)`r,ahk_pid %pid1%
sleep,4000
controlsend,,usenet`r,ahk_pid %pid1%
sleep,3000
controlsend,,r 2A3B8`r,ahk_pid %pid1%
return
;---------------------

esc::
controlsend,,q`r,ahk_pid %pid1%
sleep,500
controlsend,,cowsay /cow /dead Good bye %a_username% now you quit Telnet & DOS`r,ahk_pid %pid1%
sleep,4000
controlsend,,quit`r,ahk_pid %pid1%
sleep,500
controlsend,,%a_space%exit`r,ahk_pid %pid1%
sleep,500
Process, Close, %pid1%
Process, WaitClose, %pid1%
process,close,telnet.exe
ExitApp
;========= END script ==================
send EMAIL with telnet.exe

Code: Select all

MODIFIED=20091224
scriptname=Telnet_Email.ahk

; how to send an email with telnet.exe
; put telnet.exe in C:\WINDOWS\system32

;https://technet.microsoft.com/pt-pt/library/cc787407(v=ws.10).aspx
;
;

;===========================================
/*
check first follow =
-SMTP         (my own mail.bluewin.ch in switzerland )
-POP          (my own  pop.bluewin.ch  or
                      mail.bluewin.ch works also )

-Dos command  (telnet mail.bluewin.ch 25 in this case)
-from
-to
*/

;====== modify these variables =============
smtp1=mail.bluewin.ch
pop1 =pop.bluewin.ch
name1=garry1234
ext1 =bluewin.ch

ccc=This is Testline1`nThis is TestLine2`n
;===========================================


SetBatchLines -1
AutoTrim Off

initext=%A_scriptdir%\telnet_ini.ini
ifnotexist,%initext%
  {
  transform,E,chr,64
  fromemail=%name1%%E%%ext1%
  toemail  =%name1%%E%%ext1%
  SMTP     =%smtp1%
  subject  =Test01

  Iniwrite,%fromemail%  ,%initext% ,From   ,KEY1
  Iniwrite,%toemail%    ,%initext% ,To     ,KEY1
  Iniwrite,%SMTP%       ,%initext% ,SMTP   ,KEY1
  Iniwrite,%subject%    ,%initext% ,subject,KEY1
  }


;------------------------------------------------
IniRead, From    , %initext% , From    , Key1
IniRead, To      , %initext% , To      , Key1
IniRead, SMTP    , %initext% , SMTP    , Key1
IniRead, Subject , %initext% , Subject , Key1
;DosCommand=telnet %SMTP% 25
;------------------------------------------------

SetKeyDelay,10,10,
SendMode, Input

DetectHiddenWindows On
Gui,2:Font,,FixedSys

Gui,2:Add,Text,    x5   y10                 , FROM
Gui,2:Add,Edit,    x90  y10  w150 h20 vVAR1 , %from%

Gui,2:Add,Text,    x5   y35                 , TO
Gui,2:Add,Edit,    x90  y35  w150 h20 vVAR2 , %TO%

Gui,2:Add,Text,    x5   y60                 , SMTP
Gui,2:Add,Edit,    x90  y60  w150 h20 vVAR3 , %SMTP%

Gui,2:Add,Text,    x5   y85                 , Subject
Gui,2:Add,Edit,    x90  y85  w350 h20 vVAR4 , %subject%

Gui,2:Add,Button,  x310  y10  w90  h25  gStart1 ,START

Gui,2:Add,Edit,    x10  y140 w580 h150 vTEXT1,%ccc%

Gui,2:Add,Edit,    x10  y330 w580 h220 vLines1 readonly,

Gui,2:Show, x0 y0 h560  w600 ,TELNET SendToDOS
GuiControl,2:Focus,VAR2
return
;-------------------------------------------------

Start1:
gui,2:submit,nohide
;--- set last settings ------------------
IniWrite, %VAR1% , %initext%, From    , KEY1
IniWrite, %VAR2% , %initext%, To      , KEY1
IniWrite, %VAR3% , %initext%, SMTP    , KEY1
IniWrite, %VAR4% , %initext%, Subject , KEY1
;---------------------------------------------


/*   for test
v=%A_ScriptDir%\..\..\Programs_SA\
setworkingdir,%v%
run,%comspec% /k cd     ; see pathx where you are
exitapp
*/

;-- Telnet in C:\WINDOWS\system32 or otherwise :
;Telnet1=%A_ScriptDir%\..\..\Programs_SA\telnet.exe
;loop,%Telnet1%                                                ;- create shortpath
;   SP1= %A_loopFileShortPath%

F1=%A_now%_telnet.txt
DosCommand=telnet -f %F1% %var3% 25
;---------------------------------------------

TEXT1=%text1%`nXXXXX
GuiControl,2:Text,Lines1,

V1=helo %pop1% 
V2=mail from:%var1%
V3=rcpt to:%var2%
V4=data
V5=subject:%var4%
V6=
V9=
V10=.
V11=quit


Run %ComSpec% /k %DosCommand%,,,PID1         ;open a DOS window
;Run %ComSpec% /k %DosCommand%,,hide,PID1         ;open a DOS window
WinWait %ComSpec% ahk_pid %PID1%
WinActivate ahk_pid %PID1%

   sleep,3000
   gosub,readF1

   ControlSend,,%V1%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V2%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V3%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V4%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V5%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V6%{enter},ahk_pid %PID1%
   gosub,readF1


   StringSplit, L, text1, `n
   Loop,
      {
      A:= L%A_Index%
      if A=XXXXX
        break
      ControlSend,,%A%{enter},ahk_pid %PID1%
      sleep,500
      }

   ;--------- close telnet ---------------
   A3:
   ControlSend,,%V9%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V10%{enter},ahk_pid %PID1%
   gosub,readF1

   ControlSend,,%V11%{enter},ahk_pid %PID1%
   gosub,readF1

;GuiControl,2:Text,Lines1,TELNET Finished
;run,%A_scriptdir%\%F1%
return
;-----------------------------------------

ReadF1:
sleep,1500
GuiControl,2:Text,Lines1,
Fileread,F1content,%F1%
GuiControl,2:Text,Lines1,%F1content%
return



2Guiclose:
process,close,%PID1%
exitapp

esc::
process,close,%PID1%
exitapp
;=================================================
Last edited by garry on 17 May 2018, 15:54, edited 3 times in total.
TSSS
Posts: 4
Joined: 15 May 2018, 09:44

Re: ELIZA / STARWARS ( TELNET )

16 May 2018, 17:49

quick question... what is this?
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: ELIZA / STARWARS ( TELNET )

17 May 2018, 09:56

above example used telnet.exe and show how to send commands to a DOS window
https://technet.microsoft.com/pt-pt/lib ... s.10).aspx

above Telehack :
Telehack is a text-based simulation of an early version of the Internet.
Telehack is a virtual museum that allows one to see what the Internet was like in the 1980s, when young hackers were browsing through different bulletin board systems and shell accounts.
http://telehack.com/telehack.html
https://en.wikipedia.org/wiki/Telehack

Code: Select all

run,http://telehack.com/
return

example what happens > telnet telehack.com / send to DOS

Code: Select all

;- telnet.exe in folder C:\Windows\system32
;- https://technet.microsoft.com/pt-pt/library/cc787407(v=ws.10).aspx
;- http://telehack.com/telehack.html
;- https://en.wikipedia.org/wiki/Telehack
;========================================================================

Connected to TELEHACK port 25

It is 6:04 am on Thursday, May 17, 2018 in Mountain View, California, USA.
There are 30 local users. There are 26637 hosts on the network.

  Type HELP for a detailed command list.
  Type NEWUSER to create an account.

May the command line live forever.

Command, one of the following:
  2048        ?           a2          advent      areacode    basic
  bf          cal         calc        ching       clear       clock
  cowsay      date        echo        eliza       factor      figlet
  finger      fnord       geoip       help        hosts       ipaddr
  joke        login       mac         md5         morse       newuser
  notes       octopus     phoon       pig         ping        primes
  privacy     qr          rain        rand        rfc         rig
  roll        rot13       sleep       starwars    traceroute  units
  uptime      usenet      users       uumap       uupath      uuplot
  weather     when        zipcode     zork        zrun

.cowsay /cow /joke Hello GARRY (use ESC-button to quit or CTRC to break)
 _______________________________________________________
< Hello GARRY (use ESC-button to quit or CTRC to break) >
 -------------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
.morse SOS Hello GARRY
... --- ...  .... . .-.. .-.. ---  --. .- .-. .-. -.--
.ELIZA
HELLO, I AM ELIZA.

Hi my name is GARRY

HI. WHAT SEEMS TO BE YOUR PROBLEM?

My problem is I like autohotkey

WILL YOU EVER TELL ME WHAT YOU REALLY WISH FOR?

^C
.
.basic
Dartmouth DTSS TeleBASIC (c) 1964,1966,1969,1970,1971,1979
>a=100:c=(a*3):print "Result=";c
Result= 300
>print"Use button ESC to quit"
Use button ESC to quit
>quit

.cowsay /cow /dead Good bye GARRY now you quit Telnet & DOS
 __________________________________________
< Good bye GARRY now you quit Telnet & DOS >
 ------------------------------------------
        \   ^__^
         \  (xx)\_______
            (__)\       )\/\
             U  ||----w |
                ||     ||
.qu

Verbindung zu Host verloren.

D:\>
elmo
Posts: 113
Joined: 09 Oct 2013, 09:08

Re: ELIZA / STARWARS ( TELNET )

24 Jul 2018, 10:33

@garry

This is quite interesting, thank you for posting.

I downloaded it, enabled telnet.exe, and set telnet1a=%a_windir%\system32\telnet.exe.

Is it intended to run as-is ?

Thanks.
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: ELIZA / STARWARS ( TELNET )

25 Jul 2018, 02:20

telnet.exe was earlier ( XP ) in > %a_windir%\system32\telnet.exe
but can also put to a_scriptdir or somewhere

Code: Select all

;- telnet is in C:\windows\sytem32    (XP)
;telnet1a=%a_windir%\system32\telnet.exe

;- or 
;Telnet1=%A_ScriptDir%\..\..\Programs_SA\telnet\telnet.exe
telnet1=%A_ScriptDir%\telnet.exe
loop,%Telnet1%                                                ;- create shortpath
   telnet1a= %A_loopFileShortPath%

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: burque505 and 50 guests