• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how can I reliably query the correct terminal window?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how can I reliably query the correct terminal window?


  • Subject: Re: how can I reliably query the correct terminal window?
  • From: Skeeve <email@hidden>
  • Date: Wed, 03 Dec 2008 21:51:15 +0100

Mark J. Reed schrieb:
You could use some other property that's not likely to change. If you don't move the window, for instance, you could use "frame".
Unfortunately I don't know of any property that's unlikely to change. If you publish a script, you'd never know what people do with it.

Let's see the properties available:
   name (string) : the title of the window
   custom title (string) : the custom title for the window
      gets changed by the commands I execute

   cursor color (string) : the cursor color for the window
   background color (string) : the background color for the window
   normal text color (string) : the normal text color for the window
   bold text color (string) : the bold text color for the window
      can be changed by the command executed

   index (integer) : the number of the window
      get's changed if user selects an other terminal window

bounds (bounding rectangle) : the boundary rectangle for the window, relative to the upper left corner of the screen
position (point) : the upper left coordinates of the window, relative to the upper left corner of the screen
origin (list) : the lower left coordinates of the window, relative to the lower left corner of the screen
frame (list) : the origin and size of the window
size (list) : the width and height of the window
number of rows (integer) : the number of rows in the window
number of columns (integer) : the number of columns in the window
these properties get changed when the user moves the window or resizes it.
If (by accident) another window is moved atop of this, we might get the wrong window.


frontmost (boolean) : Is the window in front of the other Terminal windows?
miniaturized (boolean) : Is the window miniaturized?
zoomed (boolean) : Is the window zoomed?
won't help.


But! I found a way that seems at least somehow reliable:

tell application "Terminal"
   -- first generate a unique id
   set uuid to do shell script "uuidgen"

   -- then put it into a new window (my window 1 now)
   do script "# This window's id: " & uuid

   -- wait for the id to appear in the window
   repeat until history of window 1 contains uuid
       delay 1
   end repeat

   -- wait as long as the id is in window 1
   -- get another terminal window in front to leave this loop
   repeat while history of window 1 contains uuid
       delay 1
   end repeat

   -- now proove that you can find your window
   -- by setting it frontmost
   set frontmost of first window whose history contains uuid to true

end tell


This works as long as the text coming into the window does not exceed the size of the scrollback buffer, which seems sufficient for me.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden
References: 
 >how can I reliably query the correct terminal window? (From: Skeeve <email@hidden>)
 >Re: how can I reliably query the correct terminal window? (From: "Mark J. Reed" <email@hidden>)
 >Re: how can I reliably query the correct terminal window? (From: Skeeve <email@hidden>)
 >Re: how can I reliably query the correct terminal window? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: how can I reliably query the correct terminal window?
  • Next by Date: Re: how can I reliably query the correct terminal window?
  • Previous by thread: Re: how can I reliably query the correct terminal window?
  • Next by thread: Re: how can I reliably query the correct terminal window?
  • Index(es):
    • Date
    • Thread