-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadFile.cs
47 lines (42 loc) · 1.41 KB
/
LoadFile.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
43
44
45
46
47
using System;
using Robin.Core;
using Robin.Core.Attributes;
using System.ComponentModel;
using System.Windows.Forms;
using sharpAHK;
namespace Modules.AhkTest8
{
[Action(Order = 1)]
[Throws("ActionError")] // TODO: change error name (or delete if not needed)
public class LoadFile : ActionBase
{
[InputArgument, DefaultValue("")]
public string ScriptName { get; set; }
[InputArgument, DefaultValue("")]
public string FunctionName { get; set; }
[OutputArgument, DefaultValue("Script completed successfully.")]
public string AhkResult { get; set; }
public override void Execute(ActionContext context)
{
try
{
var ahk = new AutoHotkey.Interop.AutoHotkeyEngine();
ahk.LoadFile(ScriptName);
ahk.ExecFunction(FunctionName);
while (ahk.IsReady() == true)
{
System.Threading.Thread.Sleep(100);
}
ahk.Reset();
// MessageBox.Show("Engine finished.");
AhkResult = ("Finished successfully.");
}
catch (Exception e)
{
if (e is ActionException) throw;
throw new ActionException("ActionError", e.Message, e.InnerException);
}
// TODO: set values to Output Arguments here
}
}
}