Export programs and functions with TI-Graph Link 89.


In [ ]:
# Needs done once.
!pip install PyUserInput

In [4]:
from time import sleep

In [5]:
from pymouse import PyMouse
from pykeyboard import PyKeyboard

m = PyMouse()
k = PyKeyboard()

In [7]:
# Run this cell and you have 2 seconds to move the
# mouse to where TI-GRAPH LINK 89 appears on the screen.
sleep(2)
graphlink_pos=m.position()
graphlink_pos


Out[7]:
(1891, 1042)

In [17]:
def activate_tigraphlink(graphlink_pos=graphlink_pos):
    m.click(graphlink_pos[0], graphlink_pos[1])
    m.click(graphlink_pos[0], graphlink_pos[1])
    sleep(0.5)

In [28]:
# Open the nth file in the current directory.
def open_file(n=0):
    activate_tigraphlink()
    k.tap_key(k.alt_key)
    k.tap_key("f")
    k.tap_key("o")
    sleep(1)
    k.tap_key(k.tab_key)
    for _ in range(n+1):
        k.tap_key(k.down_key)
        sleep(0.1)
    k.tap_key(k.enter_key)
open_file()

In [29]:
open_file(1)

In [30]:
open_file(10)

In [25]:
# Export the file as a plain text file.
def export_file():
    activate_tigraphlink()
    k.tap_key(k.alt_key)
    sleep(0.2)
    k.tap_key("t")
    sleep(0.2)
    k.tap_key("e")
    sleep(0.2)
    k.tap_key(k.down_key)
    sleep(0.2)
    k.tap_key(k.enter_key)
    sleep(0.2)
    k.tap_key(k.enter_key)
    sleep(0.2)
    k.tap_key(k.escape_key)    
    sleep(0.2)
    k.tap_key(k.escape_key)
export_file()

In [26]:
def close_file():
    activate_tigraphlink()
    k.tap_key(k.alt_key)
    sleep(0.2)
    k.tap_key("f")
    sleep(0.2)
    k.tap_key("c")
    sleep(0.2)
    k.tap_key("n")
close_file()

In [22]:
# All together
open_file()

export_file()

close_file()

In [31]:
# How many files do we need to export
!ls me572/*89* | wc


     20      20     417

In [33]:
!ls me575/*89* | wc


     10      10     206

In [35]:
!ls stat514/*89* | wc


      7       7     192

In [36]:
for n in range(7):
    open_file(n)
    export_file()
    close_file()