diff --git a/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj b/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj index f40084d..6222092 100644 --- a/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj +++ b/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj @@ -381,7 +381,7 @@ }; buildConfigurationList = C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "TP-Assist" */; compatibilityVersion = "Xcode 10.0"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, diff --git a/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript b/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript index 1caf314..a840cae 100644 --- a/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript +++ b/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript @@ -6,58 +6,17 @@ on scriptRun(argsCmd, argsProfile, argsTitle) end scriptRun on CommandRun(theCmd, theProfile, theTitle) - tell application "iTerm" - if it is not running then - tell application "iTerm" - activate - delay 0.5 - try - close first window - end try - end tell - - tell application "iTerm" - try - create window with profile theProfile - on error msg - create window with profile "Default" - end try - tell the current window - tell the current session - delay 0.5 - set name to theTitle - set profile to theProfile - write text theCmd - delay 0.5 - write text "" - end tell - end tell - end tell - else - --assume that iTerm is open and open a new tab - try + try + tell application "iTerm" + if it is not running then tell application "iTerm" activate - tell the current window - try - create tab with profile theProfile - on error msg - create tab with profile "Default" - end try - tell the current tab - tell the current session - delay 0.5 - set name to theTitle - write text theCmd - delay 0.5 - write text "" - end tell - end tell - end tell + delay 0.5 + try + close first window + end try end tell - on error msg - -- if all iTerm windows are closed the app stays open. In this scenario iTerm has - -- no "current window" and will give an error when trying to create the new tab. + tell application "iTerm" try create window with profile theProfile @@ -68,13 +27,59 @@ on CommandRun(theCmd, theProfile, theTitle) tell the current session delay 0.5 set name to theTitle + set profile to theProfile write text theCmd delay 0.5 write text "" end tell end tell end tell - end try - end if - end tell + else + --assume that iTerm is open and open a new tab + try + tell application "iTerm" + activate + tell the current window + try + create tab with profile theProfile + on error msg + create tab with profile "Default" + end try + tell the current tab + tell the current session + delay 0.5 + set name to theTitle + write text theCmd + delay 0.5 + write text "" + end tell + end tell + end tell + end tell + on error msg + -- if all iTerm windows are closed the app stays open. In this scenario iTerm has + -- no "current window" and will give an error when trying to create the new tab. + tell application "iTerm" + try + create window with profile theProfile + on error msg + create window with profile "Default" + end try + tell the current window + tell the current session + delay 0.5 + set name to theTitle + write text theCmd + delay 0.5 + write text "" + end tell + end tell + end tell + end try + end if + end tell + on error msg + display dialog "ERROR: " & msg + end try + end CommandRun diff --git a/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript b/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript index a61e3ab..33506c7 100644 --- a/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript +++ b/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript @@ -1,76 +1,83 @@ on scriptRun(argsCmd, argsProfile, argsTitle) - set theCmd to (argsCmd) + set theCmd to (argsCmd) set theProfile to (argsProfile) set theTitle to (argsTitle) CommandRun(theCmd, theProfile, theTitle) end scriptRun on CommandRun(theCmd, theProfile, theTitle) - tell application "Terminal" - if it is not running then - --if this is the first time Terminal is running you have specify window 1 - --if you dont do this you will get two windows and the title wont be set - activate - delay 1.0 - set newTerm to do script theCmd in window 1 - set newTerm's current settings to settings set theProfile - set custom title of front window to theTitle - - delay 1.0 - reopen - activate - tell application "System Events" to key code 36 - else - --Terminal is running get the window count - set windowCount to (count every window) - if windowCount = 0 then - --Terminal is running but no windows are open - --run our script in a new window + try + tell application "Terminal" + if it is not running then + --if this is the first time Terminal is running you have specify window 1 + --if you dont do this you will get two windows and the title wont be set + activate + delay 3.0 + set newTerm to do script theCmd in window 1 + set newTerm's current settings to settings set theProfile + set custom title of front window to theTitle + + delay 1.0 reopen activate - - do script theCmd in window 1 - - set current settings of selected tab of front window to settings set theProfile - set title displays custom title of front window to true - set custom title of selected tab of front window to theTitle - - delay 1.0 - reopen - activate - tell application "System Events" to key code 36 - + tell application "System Events" to key code 36 else - --Terminal is running and we have a window run in a new tab - reopen - activate - - tell application "System Events" - tell process "Terminal" - delay 0.5 - keystroke "t" using {command down} + --Terminal is running get the window count + set windowCount to (count every window) + if windowCount = 0 then + --Terminal is running but no windows are open + --run our script in a new window + reopen + activate + + do script theCmd in window 1 + + set current settings of selected tab of front window to settings set theProfile + set title displays custom title of front window to true + set custom title of selected tab of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + + else + --Terminal is running and we have a window run in a new tab + reopen + activate + + tell application "System Events" + tell process "Terminal" + delay 0.5 + keystroke "t" using {command down} + end tell end tell - end tell - - reopen - activate - do script theCmd in front window - - set current settings of selected tab of front window to settings set theProfile - set title displays custom title of front window to true - set custom title of selected tab of front window to theTitle - - delay 1.0 - reopen - activate - tell application "System Events" to key code 36 - + + reopen + activate + do script theCmd in front window + + set current settings of selected tab of front window to settings set theProfile + set title displays custom title of front window to true + set custom title of selected tab of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + + end if + + --set current settings of selected tab of front window to settings set theProfile + --set title displays custom title of front window to true + --set custom title of selected tab of front window to theTitle end if - -# set current settings of selected tab of front window to settings set theProfile -# set title displays custom title of front window to true -# set custom title of selected tab of front window to theTitle - end if - - end tell + + end tell + + on error msg + display dialog "ERROR: " & msg + end try + + end CommandRun diff --git a/client/tp_assist_macos/src/Base.lproj/Localizable.strings b/client/tp_assist_macos/src/Base.lproj/Localizable.strings index e10f545..532603b 100644 --- a/client/tp_assist_macos/src/Base.lproj/Localizable.strings +++ b/client/tp_assist_macos/src/Base.lproj/Localizable.strings @@ -3,12 +3,12 @@ TPAssist */ -"app_name" = "Teleport助手"; +"app_name" = "Teleport Assist"; //============================================= // for About Window //============================================= "version" = "Version: "; "app_full_name" = "Teleport Assist for macOS"; -"copyright" = "Copyright © 2017~2018 TP4A. All rights reserved."; +"copyright" = "Copyright © 2017~2019, tp4a.com. All rights reserved."; "visit_tp4a_website" = "Visit Teleport Website" diff --git a/client/tp_assist_macos/src/TP-Assist-Info.plist b/client/tp_assist_macos/src/TP-Assist-Info.plist index af47fa1..3231d75 100644 --- a/client/tp_assist_macos/src/TP-Assist-Info.plist +++ b/client/tp_assist_macos/src/TP-Assist-Info.plist @@ -28,8 +28,10 @@ ${MACOSX_DEPLOYMENT_TARGET} LSUIElement + NSAppleEventsUsageDescription + NSHumanReadableCopyright - Copyright © 2017~2018 TP4A. All rights reserved. + Copyright © 2017~2019, tp4a.com. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/client/tp_assist_macos/src/apple-scpt/iterm2.scpt b/client/tp_assist_macos/src/apple-scpt/iterm2.scpt index 431c2bf..dac4f8e 100644 Binary files a/client/tp_assist_macos/src/apple-scpt/iterm2.scpt and b/client/tp_assist_macos/src/apple-scpt/iterm2.scpt differ diff --git a/client/tp_assist_macos/src/apple-scpt/terminal.scpt b/client/tp_assist_macos/src/apple-scpt/terminal.scpt index abda883..98d335e 100644 Binary files a/client/tp_assist_macos/src/apple-scpt/terminal.scpt and b/client/tp_assist_macos/src/apple-scpt/terminal.scpt differ diff --git a/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings b/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings index 1c1fec3..aed4793 100644 --- a/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings +++ b/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings @@ -15,5 +15,5 @@ "about " = "关于 "; "version" = "版本:"; "app_full_name" = "Teleport助手 - macOS"; -"copyright" = "© 2017~2018 TP4A,保留所有权利。"; +"copyright" = "© 2017~2019,tp4a.com。保留所有权利。"; "visit_tp4a_website" = "访问 Teleport 网站";