예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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());
        }
예제 #4
0
        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 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");
        }
예제 #6
0
        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
        }
        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());
        }
예제 #8
0
        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");
        }
예제 #9
0
        // 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;
        }
예제 #10
0
        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
        }