예제 #1
0
파일: iectl.cs 프로젝트: wrmsr/iectl
 public IEController(IEControllerOptions _options)
 {
     options = _options;
 }
예제 #2
0
파일: iectl.cs 프로젝트: wrmsr/iectl
        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());
            }
        }