public static async Task StartObs() { System.Diagnostics.Debug.WriteLine("inside StartObs"); var obsStream = Process.GetProcessesByName("obs64"); if (obsStream.Length == 0) { Process.Start("C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\OBS Studio\\OBS Studio (64bit)"); } obs = Process.GetProcessesByName("obs64").FirstOrDefault(); IntPtr h = obs.MainWindowHandle; SetForegroundWindow(h); await Task.Delay(8000); System.Diagnostics.Debug.WriteLine("sending OBS inputs..."); Debug.WriteLine("Starting stream..at: " + DateTime.Now); var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.LoadFile("../../test.ahk"); ahk.ExecFunction("StartStream"); }
public static async Task StartObs() { System.Diagnostics.Debug.WriteLine("inside StartObs"); var obsStream = Process.GetProcessesByName("obs64"); if (obsStream.Length == 0) { Process.Start(Constants.ObsStudioAbsolutePath); } obs = Process.GetProcessesByName("obs64").FirstOrDefault(); IntPtr h = obs.MainWindowHandle; SetForegroundWindow(h); await Task.Delay(8000); System.Diagnostics.Debug.WriteLine("sending OBS inputs..."); Debug.WriteLine("Starting stream..at: " + DateTime.Now); var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.LoadFile(Constants.AhkRelativeFilePath); ahk.ExecFunction("StartStream"); }
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 }
static void Main(string[] args) { //create an autohtkey engine. var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); //execute any raw ahk code ahk.ExecRaw("MsgBox, Hello World!"); //create new hotkeys ahk.ExecRaw("^a::Send, Hello World"); //programmatically set variables ahk.SetVar("x", "1"); ahk.SetVar("y", "4"); //execute statements ahk.ExecRaw("z:=x+y"); //return variables back from ahk string zValue = ahk.GetVar("z"); Console.WriteLine("Value of z is {0}", zValue); // "Value of z is 5" //Load a library or exec scripts in a file ahk.Load("functions.ahk"); //execute a specific function (found in functions.ahk), with 2 parameters ahk.ExecFunction("MyFunction", "Hello", "World"); //execute a label ahk.ExecLabel("DOSTUFF"); //create a new function string sayHelloFunction = "SayHello(name) \r\n { \r\n MsgBox, Hello %name% \r\n return \r\n }"; ahk.ExecRaw(sayHelloFunction); //execute's newly made function\ ahk.ExecRaw(@"SayHello(""Mario"") "); //execute a function (in functions.ahk) that adds 5 and return results var add5Results = ahk.Eval("Add5( 5 )"); Console.WriteLine("Eval: Result of 5 with Add5 func is {0}", add5Results); //you can also return results with the ExecFunction add5Results = ahk.ExecFunction("Add5", "5"); Console.WriteLine("ExecFunction: Result of 5 with Add5 func is {0}", add5Results); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }
public ScanAndFire() { lastKeys = new SortedList <uint, DateTime>(); ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.ExecRaw("CoordMode, ToolTip, Screen"); ahk.ExecRaw("CoordMode, Pixel, Screen"); ahk.ExecRaw("CoordMode, Mouse, Screen"); ahk.ExecRaw("CoordMode, Caret, Screen"); ahk.ExecRaw("CoordMode, Menu, Screen"); Task.Run(new Action(RunService)); }
public static void StopObs() { Debug.WriteLine("Stopping stream..at: " + DateTime.Now); obs = Process.GetProcessesByName("obs64").FirstOrDefault(); IntPtr h = obs.MainWindowHandle; SetForegroundWindow(h); var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.LoadFile(Constants.AhkRelativeFilePath); ahk.ExecFunction("StopStream"); }
public override void Execute(ActionContext context) { try { var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); AhkEngine = ahk; } catch (Exception e) { throw new ActionException("ActionError", e.Message, e.InnerException); // TODO: change error name (or delete if not needed) } // TODO: set values to Output Arguments here // OutputArgument1 = ... }
public static void StartReplay(int playerSlot, long matchID) { IntPtr h = Dota.MainWindowHandle; SetForegroundWindow(h); //Thread.Sleep(10000); Console.WriteLine("sending input.."); System.Diagnostics.Debug.WriteLine("sending inputs..."); var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.LoadFile(Constants.AhkRelativeFilePath); ahk.ExecFunction("TestSend"); ahk.ExecFunction("WatchThisReplay", matchID.ToString(), playerSlot.ToString()); }
public static async Task StartReplay(int playerSlot) { IntPtr h = dota.MainWindowHandle; SetForegroundWindow(h); //Thread.Sleep(10000); await Task.Delay(10000); Console.WriteLine("sending input.."); System.Diagnostics.Debug.WriteLine("sending inputs..."); var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.LoadFile("../../test.ahk"); ahk.ExecFunction("TestSend"); ahk.ExecFunction("WatchThisReplay", matchID.ToString(), playerSlot.ToString()); }
// generate wordlist public string WordCount_FromFile(string filePath) // returns list of words parsed to unique words with word count (in ini format) from File { //### load AHK script into memory, execute function, return parse value ### // load wordcount.ahk function into AHK workspace string wordCountAHK = ahk.AppDir() + "\\Scripts\\WordCount.ahk"; //@"C:\Users\Jason\Google Drive\IMDB\Scripts\WordCount.ahk"; //create an autohotkey engine (AHK DLL) or use existing instance if it hasn't be initiated AutoHotkey.Interop.AutoHotkeyEngine ahkddll = new AutoHotkey.Interop.AutoHotkeyEngine(); // load the ahk function file to access in user scripts ahk.Load_ahkFile(wordCountAHK, false, false); // execute function to return ini values with counts after parsing the filePath for words string wordCounts = ahkddll.ExecFunction("Generate_WordCount", filePath); // execute loaded function return wordCounts; }
/// <summary> /// Some commands require sending keys directly to Spotify (for example, Fast Forward and Rewind which /// are not handled by Spotify). We can't inject keys directly with WM_KEYDOWN/UP since we need a keyboard /// hook to actually change the state of various modifier keys (for example, Shift + Right for Fast Forward). /// /// AutoHotKey has that hook and can modify the state for us, so let's take advantge of it. /// </summary> /// <param name="keys"></param> private static void SendComplexKeys(string keys) { // Is this nicer? // _ahk = _ahk ?? new AutoHotkey.Interop.AutoHotkeyEngine(); // only initialize AHK when needed as it can be expensive (dll copy etc) if not actually needed if (_ahk == null) { _ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); } _ahk.ExecRaw("SetTitleMatchMode 2"); _ahk.ExecRaw("DetectHiddenWindows, On"); _ahk.ExecRaw("ControlSend, ahk_parent, " + keys + ", ahk_class SpotifyMainWindow"); _ahk.ExecRaw("DetectHiddenWindows, Off"); }
public Events() { _server = new NamedPipeServer<string>("io-jaywick-labs-pastr-messaging"); _server.ClientMessage += server_ClientMessage; _server.Start(); _ahkEngine = new AutoHotkey.Interop.AutoHotkeyEngine(); _shortcutCallbackMap = new Dictionary<string, Action>(); ReserveHotKey("^+z", () => OnInvokeDrop.SafeInvoke()); ReserveHotKey("^+x", () => OnInvokeShunt.SafeInvoke()); ReserveHotKey("^+c", () => OnInvokePush.SafeInvoke()); ReserveHotKey("^+v", () => OnInvokePeek.SafeInvoke()); ReserveHotKey("^+b", () => OnInvokePop.SafeInvoke()); ReserveHotKey("^+a", () => OnInvokeExpire.SafeInvoke()); ReserveHotKey("^+s", () => OnInvokePinch.SafeInvoke()); ReserveHotKey("^+d", () => OnInvokeWipe.SafeInvoke()); ReserveHotKey("^+w", () => OnInvokeSwap.SafeInvoke()); ReserveHotKey("^+f", () => OnInvokePoke.SafeInvoke()); ReserveHotKey("^+q", () => OnInvokeRotateLeft.SafeInvoke()); ReserveHotKey("^+e", () => OnInvokeRotateRight.SafeInvoke()); ReserveHotKey("^+r", () => OnInvokeReverse.SafeInvoke()); RegisterHotKeys(); }
public override void Execute(ActionContext context) { try { AutoHotkey.Interop.AutoHotkeyEngine ahk = AhkEngine; FunctionReturn = ahk.ExecFunction(FunctionName, Arg01, Arg02, Arg03, Arg04, Arg05, Arg06, Arg07, Arg08, Arg09, Arg10); if (FunctionReturn == null || FunctionReturn == "") { FunctionReturn = "No return value"; } } catch (Exception e) { if (e is ActionException) { throw; } throw new ActionException("ExecFunctionError", "Error calling function", e.InnerException); } // TODO: set values to Output Arguments here }
public Events() { _server = new NamedPipeServer <string>("jaywick.labs.pastr.messaging"); _server.ClientMessage += server_ClientMessage; _server.Start(); _ahkEngine = AutoHotkey.Interop.AutoHotkeyEngine.Instance; _shortcutCallbackMap = new Dictionary <string, Action>(); ReserveHotKey("^+z", () => OnInvokeDrop?.Invoke()); ReserveHotKey("^+x", () => OnInvokeShunt?.Invoke()); ReserveHotKey("^+c", () => OnInvokePush?.Invoke()); ReserveHotKey("^+v", () => OnInvokePeek?.Invoke()); ReserveHotKey("^+b", () => OnInvokePop?.Invoke()); ReserveHotKey("^+a", () => OnInvokeExpire?.Invoke()); ReserveHotKey("^+s", () => OnInvokePinch?.Invoke()); ReserveHotKey("^+d", () => OnInvokeWipe?.Invoke()); ReserveHotKey("^+w", () => OnInvokeSwap?.Invoke()); ReserveHotKey("^+f", () => OnInvokePoke?.Invoke()); ReserveHotKey("^+q", () => OnInvokeRotateLeft?.Invoke()); ReserveHotKey("^+e", () => OnInvokeRotateRight?.Invoke()); ReserveHotKey("^+r", () => OnInvokeReverse?.Invoke()); RegisterHotKeys(); }
public override void Execute(ActionContext context) { try { var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); ahk.ExecRaw(RawScript); while (ahk.IsReady() == true) { System.Threading.Thread.Sleep(100); } ahk.Reset(); // MessageBox.Show("Engine finished."); } catch (Exception e) { if (e is ActionException) { throw; } throw new ActionException("ActionError", e.Message, e.InnerException); } }