forked from christianrondeau/SikuliSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSikuli.cs
42 lines (36 loc) · 1.05 KB
/
Sikuli.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.IO;
namespace SikuliSharp
{
public static class Sikuli
{
public static ISikuliSession CreateSession()
{
return new SikuliSession(CreateRuntime());
}
public static SikuliRuntime CreateRuntime()
{
return new SikuliRuntime(
new AsyncDuplexStreamsHandlerFactory(),
new SikuliScriptProcessFactory()
);
}
public static string RunProject(string projectPath)
{
return RunProject(projectPath, null);
}
public static string RunProject(string projectPath, string args)
{
if (projectPath == null) throw new ArgumentNullException("projectPath");
if (!Directory.Exists(projectPath))
throw new DirectoryNotFoundException(string.Format("Project not found in path '{0}'", projectPath));
var processFactory = new SikuliScriptProcessFactory();
using (var process = processFactory.Start(string.Format("-r {0} {1}", projectPath, args)))
{
var output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return output;
}
}
}
}