Advertisement
Hafixie93

All terminal.applescript

Dec 8th, 2020
2,729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. beritahu aplikasi "Terminal"
  2.     get name -- application r/o
  3.     -- "Terminal"
  4.     get version --  r/o
  5.     -- "1.5.1"
  6.     get frontmost -- r/o
  7.     -- false
  8.     --activate
  9.     --get every window       -- application contains windows
  10.     get front window -- window noun: A Terminal window
  11.     -- get window 1
  12.     -- window id 285
  13.     copy result to W1
  14.     get name of W1
  15.     -- "Terminal — mksh — ttyp1 — 80x14 — 1"
  16.     get index of W1
  17.     -- 1
  18.     get bounds of W1
  19.     -- "Terminal — mksh — ttyp1 — 80x14 — 1"  --
  20.     get has close box of W1 -- window r/o GUI properties
  21.     -- true
  22.     get has title bar of W1
  23.     -- false
  24.     get floating of W1
  25.     -- false
  26.     get miniaturizable of W1
  27.     -- true
  28.     get miniaturized of W1 -- r/w
  29.     -- false
  30.     copy result to save_result
  31.     repeat with Bounce in {true, false, true, false, true, false}
  32.         set miniaturized of W1 to Bounce
  33.     end repeat
  34.     -- that works
  35.     tell application "Script Editor" to activate
  36.     -- was tired of doing that myself
  37.     set miniaturized of W1 to save_result
  38.     get modal of W1 -- r/o GUI property
  39.     -- false
  40.     get resizable of W1
  41.     -- true
  42.     get visible of W1 -- does this mean part of a Hidden Application?
  43.     -- true
  44.     get zoomable of W1
  45.     -- true
  46.     get zoomed of W1
  47.     copy result to save_result
  48.     repeat with StrobeZoom in {true, false, true, false, true, false}
  49.         --get (a reference to zoomed of W1)
  50.         --copy StrobeZoom to result
  51.         --copy StrobeZoom to zoomed of W1
  52.         -- Terminal get an error:NSArgumentWrongScriptError
  53.         -- an app not accepting copy to syntax is typical.
  54.         set zoomed of W1 to StrobeZoom
  55.         delay 0.5
  56.     end repeat
  57.     -- that works
  58.     set zoomed of W1 to save_result
  59.     get position of W1 -- ................ What you should think!
  60.     -- {119, 543}
  61.     copy result to save_result
  62.     tell application "Terminal" to activate -- I want to see this
  63.     repeat with X in {0, 20, 40, 80, 120, 200, 240}
  64.         copy {} to P -- need to make a point {  X, Y  }
  65.         set P to P & X
  66.         set P to P & (back item of save_result)
  67.         set position of W1 to P
  68.         delay 0.6
  69.     end repeat
  70.     set position of W1 to save_result
  71.     get origin of W1 -- lower left corridinates,relative to L.L. of screen
  72.     -- { 240, 192 }
  73.     copy result to save_result
  74.     repeat with Y in {100, 500, 250, 120, 10, 500}
  75.         copy {} to P -- make a point again
  76.         set P to P & (item 1 of save_result)
  77.         set P to P & Y
  78.         set origin of W1 to P
  79.         delay 0.7
  80.     end repeat
  81.     set origin of W1 to save_result
  82.     get size of W1 -- the width and height of the window
  83.     -- { 863, 364 }
  84.     copy result to save_result
  85.     repeat with W in {800, 400, 1000, 200, 900}
  86.         repeat with H in {300, 600, 400, 200, 500}
  87.             copy {1, 2} to S -- make A Size a 2 item list
  88.             set item 1 of S to W
  89.             set item -1 of S to H
  90.             set size of W1 to S -- don't forget to set Window, Dan!
  91.             delay 0.77
  92.         end repeat
  93.     end repeat -- awesome! if a demo maybe stop here
  94.     set size of W1 to save_result
  95.     get frame of W1 -- the ORIGIN and SIZE of WINDOW
  96.     -- {330, 194, 863, 364}
  97.     --  ......................... Researcher to Teacher:
  98.     -- .......................... Find the confused student, quickly
  99.     copy result to save_result
  100.     repeat with F in {{300, 100, 700, 400}, ¬
  101.         {200, 200, 400, 400}, ¬
  102.         {800, 800, 364, 863}, ¬
  103.         {1, 1, 800, 360}, ¬
  104.         {1000, 1000, 500, 500}}
  105.         --That's  COMMA OPTION ENTER 'CEPT LAST LINE
  106.         set frame of W1 to F
  107.         delay 0.55
  108.     end repeat
  109.     set frame of W1 to save_result
  110.     get title displays device name of W1 -- is the ttyp in the title ?
  111.     -- true
  112.     copy result to save_result
  113.     set title displays device name of W1 to false
  114.     set title to name of W1
  115.     --- "Terminal — mksh — 80x14 — 1"
  116.     -- remember it's called the name
  117.     set title displays device name of W1 to save_result
  118.     get title displays shell path of W1 -- is the shellname or path there?
  119.     -- true
  120.     copy result to save_result
  121.     -- get window 1     don't need this, just checking, it's the same
  122.     -- window id 285 of application "Terminal"
  123.     set title displays shell path of W1 to not save_result
  124.     delay 0.8 -- 2.5 cleary, saw update
  125.     set title displays shell path of W1 to save_result
  126.     get title displays window size of W1 -- title has window size r/w!
  127.     -- true
  128.     get title displays file name of W1 -- title has filename  boolean r/w!
  129.     -- false
  130.     copy result to save_result
  131.     set title displays file name of W1 to true
  132.     set title2 to name of W1
  133.     delay 0.5 -- 2.5
  134.     set title displays file name of W1 to save_result
  135.     get title2
  136.     -- "Terminal — mksh — ttyp1 — 80x14 — ~/Library/Application Support/Terminal/Steel14V.term — 1"
  137.     -- so filename is gettable after a fashion
  138.     -- so one could copy,and, perhaps modify to add new keybindings,
  139.     -- font, etc.
  140.     set title displays file name of W1 to save_result
  141.     get title displays custom title of W1 -- title has prefix string
  142.     -- true
  143.     get custom title of W1
  144.     -- "Terminal"
  145.     copy result to save_result
  146.     set custom title of W1 to "XXXXXXXXXXXXXXXXXXXX"
  147.     delay 1.8
  148.     set custom title of W1 to save_result
  149.     get contents of W1 -- r/o  visible contents of window as string
  150.     copy result to buffer
  151.     -- returning window id instead, not the string
  152.     -- window id 285
  153.     -- NO WORK, maybe try with osascript?
  154.     -- write buffer to POSIX file "/tmp/TerminalAll.contents"
  155.     -- converted to below or similiar on Compile
  156.     -- write buffer to file "Hard Disk:private:tmp:TerminalAll.contents"
  157.     --
  158.    
  159.     -- write buffer to file POSIX file "/tmp/TerminalAll.contents"
  160.     -- need to touch the file, in order to create it, this way
  161.     get history of W1 -- contents of window history plus on screen r/o
  162.     -- copy result to buffer -- copy here created an issue
  163.     set buffer to history of W1
  164.     --open for access POSIX file "/tmp/TerminalAll.history" write permission yes
  165.     --open for access POSIX file "/tmp/TerminalAll.history" write permission yes
  166.     -- converted to line below on Compile
  167.     open for access POSIX file "/tmp/TerminalAll.history" write permission yes
  168.     copy result to fileno
  169.     write buffer to fileno as string
  170.     close access fileno
  171.     -- then in Terminal, cd /tmp
  172.     -- pbcopy < TerminalAll.history
  173.     get number of rows of W1 -- number of rows in this Terminal window
  174.     copy result to save_result
  175.     repeat result - 1 times
  176.         get (number of rows of W1) - 1
  177.         set number of rows of W1 to result
  178.         delay 0.65
  179.     end repeat
  180.     -- rows less than 4  ** will not do ** and window becomes unusable!
  181.     set number of rows of W1 to save_result
  182.     get number of columns of W1 -- number of columns in this window
  183.     copy result to save_result
  184.     repeat with C from 120 to 20 by -5
  185.         set number of columns of W1 to C
  186.         delay 0.25
  187.     end repeat
  188.     -- won't strink less than about 10 columns
  189.     -- stays typeable, but with to 2 by -1, only 2 characters
  190.     -- show on any given line, rest blank
  191.     set number of columns of W1 to save_result
  192.     get cursor color of W1 -- dictionary claims string
  193.     -- {-19531, -19531, -19531}
  194.     get cursor color of W1 as string
  195.     -- "-19531-19531-19531"
  196.     get cursor color of W1 as list
  197.     -- {-19531, -19531, -19531}
  198.     get normal text color of W1
  199.     -- {-6424, -6424, -6424}
  200.     -- swap text and backgroupd, obviously!
  201.     copy normal text color of W1 to save_result
  202.     set normal text color of W1 to (background color of W1)
  203.     set background color of W1 to save_result
  204.     delay 1.5
  205.     set background color of W1 to normal text color of W1
  206.     set normal text color of W1 to save_result
  207.     delay 1.5
  208.     get bold text color of W1
  209.     -- from webcolor.scpt
  210.     -- copy {65535, 65535, 65535} to default_color -- snow
  211.     -- choose color default_color
  212.     -- don't need those 3 lines above
  213.     copy result to rgb_list
  214.     copy item 1 of rgb_list to red
  215.     copy item 2 of rgb_list to green
  216.     copy item 3 of rgb_list to blue
  217.     -- web format is 8 bit per color value, apple
  218.     -- is returning 16 bit values, divide by 256
  219.     -- solves this -- and rounding down!
  220.     copy (round (red / 256) rounding down) to red
  221.     copy (round (green / 256) rounding down) to green
  222.     copy (round (blue / 256) rounding down) to blue
  223.    
  224.     -- convert to hex, no way to do this natively
  225.     -- so call printf
  226.     do shell script "printf %X%X%X " & space & red ¬
  227.         & space & green & space & blue
  228.     copy "#" & result as text to pastethis
  229.     set the clipboard to pastethis
  230.     -- "#191919"
  231.     set cmdstring to "tput clear"
  232.     -- tell W1 to do shell script cmdstring in window 1
  233.     --do shell script cmdstring in (window 1 of application "Terminal")
  234.     -- It's not working with in parameter!!!
  235.     set RR to a reference to window 1 of application "Terminal"
  236.     -- do shell script cmdstring in RR
  237.     get busy of W1 --- is the window busy running a process r/o
  238.     -- false
  239.     get processes of W1 -- list of currently running r/o
  240.     -- {"login", "mksh"}
  241.     get busy of W1
  242.     -- false -- sleep 200 -- but that's built in
  243.     -- true  -- gdd delay=100 if=/dev/zero of=/dev/null bs=4k
  244.     get processes of W1
  245.     -- {"login", "mksh", "gdd"}
  246.     get busy of W1
  247.     -- false -- bg of gdd
  248.     get processes of W1
  249.     -- {"login", "mksh", "gdd"} -- gdd is bg running
  250.     get busy of W1
  251.     -- false    -- bg is running
  252.     get frontmost of W1 --is this window in front of other Terminal windows
  253.     -- true
  254.     copy result to save_result
  255.     repeat with TF in {true, false, true, false, true, false}
  256.         set frontmost of W1 to TF
  257.         delay 0.5
  258.     end repeat
  259.     set frontmost of W1 to save_result
  260.     run -- run Terminal
  261.     -- quit -- quit Terminal
  262.     count windows -- return number of windows -- integer
  263.     -- 2
  264. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement