Exemple #1
0
 public ScriptUtils(MSScriptControl.ScriptControlClass _script, IEController _ie)
 {
     script = _script;
     ie = _ie;
 }
Exemple #2
0
        static void Main(string[] args)
        {
            try {
                MSScriptControl.ScriptControlClass script = new MSScriptControl.ScriptControlClass();
                script.Language = "JavaScript";
                script.Timeout = 600000;
                script.AllowUI = true;
                script.UseSafeSubset = false;

                IEControllerOptions opts = new IEControllerOptions();
                IEController ie = new IEController(opts);

                ScriptUtils utils = new ScriptUtils(script, ie);
                script.AddObject("utils", utils, true); //makes var c = meta[a]; call htmlwindow - W T F

                string src = null;

                if(args.Length > 1 && args[0] == "-e") {
                    StringBuilder sb = new StringBuilder();

                    for(int i = 1; i < args.Length; i++)
                        sb.AppendLine(args[i]);

                    src = sb.ToString();
                }
                else if(args.Length > 0) {
                    using(StreamReader sr = new StreamReader(args[0]))
                        src = sr.ReadToEnd();
                }
                else
                    throw new Exception("Usage: iectl (<filename> | -e <statements...>)");

                script.AddObject("ie", ie, false);

                utils.initGlobal();

                utils.include("autoexec.js");

                //try
                {
                    utils.__eval(src);
                }
                /*catch(Exception ex)
                {
                    if(script.Error.Number > 0)
                        Console.WriteLine(script.Error.);
                }*/
            }
            catch(Exception ex) {
                Console.WriteLine(ex.ToString());
            }
        }