Merge branch 'feature/mstsc' of github.com:tp4a/teleport into feature/mstsc

pull/175/head^2
ApexLiu 2019-08-01 17:44:41 +08:00
commit 10142bfef6
8 changed files with 134 additions and 120 deletions

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -28,8 +28,10 @@
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key>
<true/>
<key>NSAppleEventsUsageDescription</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017~2018 TP4A. All rights reserved.</string>
<string>Copyright © 2017~2019, tp4a.com. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>

View File

@ -15,5 +15,5 @@
"about " = "关于 ";
"version" = "版本:";
"app_full_name" = "Teleport助手 - macOS";
"copyright" = "© 2017~2018 TP4A保留所有权利。";
"copyright" = "© 2017~2019tp4a.com。保留所有权利。";
"visit_tp4a_website" = "访问 Teleport 网站";