public void can_return_function_result_with_eval() { //create the function ahk.ExecRaw("TestFunctionForEval() {\r\n return \"It Works!\" \r\n}"); //test the eval string results = ahk.Eval("TestFunctionForEval()"); Assert.Equal("It Works!", results); }
public Profile(string name, Action <string, bool, uint> callback) { profileName = name; profileCallback = callback; ProfileEvent profileEventDelegate = profileEventCallback; IntPtr eptr = Marshal.GetFunctionPointerForDelegate(profileEventDelegate); ahkThread.LoadFile("ProfileThread.ahk"); ahkThread.Eval(String.Format("ph := new ProfileHandler({0})", eptr)); }
public async Task ConvertToPrismProperty() { await Task.Factory.StartNew(() => { //cut the current line const string function = "CopyLine(){\r\nSend, ^x\r\nclipboard := Clipboard\r\nreturn clipboard\r\n}"; ahk.ExecRaw(function); string eval = ahk.Eval("CopyLine()"); string line = eval.Trim().Trim('\n'); //trim spaces and line breaks if (string.IsNullOrWhiteSpace(line)) { return; } string[] split = line.Split(' '); string propertyType = split[1]; string propertyName = split[2]; string lowercase = $"{propertyName[0].ToString().ToLower()}{propertyName.Substring(1)}"; var pattern = @" private {2} {0}; public {2} {1} {{ get => {0}; set => SetProperty(ref {0},value); }} "; pattern = string.Format(pattern, lowercase, propertyName, propertyType); Application.Current.Dispatcher?.Invoke(() => Clipboard.SetText(pattern)); var paste = "Send, ^v"; ahk.ExecRaw(paste); }); }
public void can_evaluate_expressions() { Assert.Equal("450", ahk.Eval("100+200*2-50")); Assert.Equal("230", ahk.Eval("20*10+30")); Assert.Equal("210", ahk.Eval("10*20+5*2")); Assert.Equal("50", ahk.Eval("100 - 50")); Assert.Equal("2", ahk.Eval("10 // 5")); //TODO: there seems to be a problem with division with ahkdll }
public string Eval(string ahkCode) { return(ahk.Eval(ahkCode)); }