• 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: Move and resize the window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move and resize the window


  • Subject: Re: Move and resize the window
  • From: Andrew Oliver <email@hidden>
  • Date: Wed, 10 Mar 2004 09:14:17 -0800

Each time you 'do script' and don't specify a window, Terminal.app will open
a new window for the command:

repeat 3 times
tell application "Terminal"
do script ""
end tell
end repeat

If you want to target a specific window you can do so in any of the normal
AppleScript ways:

tell application "terminal"
do script "blah" in window 1 -- frontmost window
do script "blah" in window 2 -- second window
do script "blah" in window "fred" -- in the window named "fred"
close every window whose frontmost is false -- close all background windows
set position of some window to {100, 100} -- randomly move one window
etc., etc.
end tell

Andrew
:)

On 3/10/04 3:34 AM, "Juguang Xiao" <email@hidden> wrote:

> Thanks Ken, your tips work!
>
> However my question seems not to be answered straightly.
>
> How can I activate/open another instance of Terminal after once there
> are some Terminal windows on? The below one can open one terminal
> window only if there is nothing on before.
>
> ---
> tell application "Terminal"
> activate
> end tell
> -------
> Also, how to identify Terminal windows which are not 'front window'?
>
> Thanks in advance.
>
> Juguang
>
>
>>
>>
>> To open a new Terminal window all you have to do is run a command.
>> You do it like this:
>> ----------
>> tell application "Terminal"
>> do script ""
>> end tell
>> ---------
>>
>> The blank command will just cause a window to open. To run a command
>> instead of just doing nothing you would do something like this:
>> ---------
>> tell application "Terminal"
>> do script "cd ~/Documents/"
>> end tell
>> ---------
>>
>> This will execute the command "cd ~/Documents/" in a new Terminal
>> window.
>>
>> To do more shell commands in the same window without combining them
>> into one "do script" command you could combine them with a semicolon
>> like this:
>> ---------
>> tell application "Terminal"
>> do script "cd ~/Documents/; ls -l"
>> end tell
>> ---------
>>
>> This is exactly how you would combine commands if you wanted to do
>> this in the shell.
>>
>> If you can't combine them then you will have to save what window you
>> are working in so that you can do each command in that window. Since
>> the last window opened is the front one this is easy:
>> ---------
>> tell application "Terminal"
>> do script "cd ~/Documents/"
>> set theWindow to front window
>> delay 1
>> do script "ls -l" in theWindow
>> end tell
>> ---------
>>
>> You need to have a little delay in there because for some reason if
>> the commands are entered too quickly they don't get executed properly.
>> I did a delay of 1 second to prevent this
>>
>> -Ken
>>
>>
>> On Mar 4, 2004, at 10:35 PM, Juguang Xiao wrote:
>>
>>> I am very new to AppleScript, so my this question may be quite naive.
>>> I cannot find a right reference to answer it.
>>>
>>> How to open a new Terminal, rather than activate it? And how to move
>>> and resize the window of it?
>>>
>>> One general question is how to find the method set of one specific
>>> Application? Such as what are methods available for/in/from Terminal.
>>
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>>
> Juguang Xiao
> _______________________________________________
> applescript-users mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/applescript-users
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Move and resize the window (From: Juguang Xiao <email@hidden>)

  • Prev by Date: Re: do visual basic
  • Next by Date: Re: do visual basic
  • Previous by thread: Re: Move and resize the window
  • Next by thread: Re: Move and resize the window
  • Index(es):
    • Date
    • Thread