« 新規インスタンスで起動させる | トップページ | [LETS]FontWorksのLETSアプリ起動と終了 »

[Terminal]ウィンドウ設定が常にタブの場合も新規ウィンドウを開く


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions

set strBundleID to "com.apple.Terminal"

###起動はランチを使うと新規ウィンドウが出来ない
tell application "Terminal" to launch
###ウィンドウの数を数えて
tell application "Terminal"
  activate
  set numCntWindow to (count of every window) as integer
end tell
###ウィンドウが無いなら終了する
if numCntWindow = 0 then
  tell application "Terminal" to quit
  delay 2
  tell application "Terminal" to launch
end if
####新規ウィンドウを開く(SystemEvent方式)
tell application "Terminal"
  activate
  tell application "System Events"
    tell process "Terminal"
      set frontmost to true
key down {command}
      keystroke "n"
key up {command}
    end tell
  end tell
end tell
###システムイベントの場合ウィンドウが出来るのを待つ
repeat 5 times
  tell application "Terminal"
    set numCntWindow to (count of every window) as integer
  end tell
  if numCntWindow = 0 then
    delay 0.5
  else
    exit repeat
  end if
end repeat

tell application "Terminal"
  tell front window
    set numWindowID to id as integer
  end tell
  tell window id numWindowID
    set position to {0, 25}
  end tell
end tell
###新規ウィンドウを開く(do script方式)
tell application "Terminal"
  launch
  activate
  set objTabWindows to do script "\n"
  tell objTabWindows
    activate
  end tell
end tell
####新規ウィンドウを開く
tell application "Terminal"
  activate
  tell application "System Events"
    tell process "Terminal"
      set frontmost to true
click menu item "タブを新しいウインドウに移動" of menu 1 of menu bar item "ウインドウ" of menu bar 1
    end tell
  end tell
  tell front window
    set numWindowID to id as integer
  end tell
  tell window id numWindowID
    set position to {0, 340}
  end tell
end tell

|

« 新規インスタンスで起動させる | トップページ | [LETS]FontWorksのLETSアプリ起動と終了 »

Terminal」カテゴリの記事