Skip to content

Instantly share code, notes, and snippets.

@StanleyGoldman
Created May 9, 2017 16:51
Show Gist options
  • Save StanleyGoldman/06a6082fe243a792f25d4fbff9a424f7 to your computer and use it in GitHub Desktop.
Save StanleyGoldman/06a6082fe243a792f25d4fbff9a424f7 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace TestingOpenTerminal
{
internal class Program
{
public static void Main(string[] args)
{
var arguments = @"-e ""tell application \""Terminal\"""" "+
@"-e ""tell application \""System Events\"" to keystroke \""t\"" using {command down}"" "+
// @"-e ""do script \\""cd $pwd; clear\\"" in front window"" "+
@"-e ""end tell""";
var startInfo = new ProcessStartInfo("osascript")
{
RedirectStandardInput = false,
RedirectStandardOutput = false,
RedirectStandardError = false,
UseShellExecute = false,
CreateNoWindow = false,
Arguments = arguments
};
var process = Process.Start(startInfo);
process.OutputDataReceived += (sender, eventArgs) =>
{
Console.WriteLine(eventArgs.Data);
};
process.ErrorDataReceived += (sender, eventArgs) =>
{
Console.WriteLine("Error: " + eventArgs.Data);
};
process.WaitForExit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment