public Program() { windowsProxy = new WindowsProxy.WindowsProxy(new RootForm()); //windowsProxy.execute_ls_l_req(null); baseXML = windowsProxy.baseXML; window_count = windowsProxy.Window_Count; }
public void execute_delta(Sinter sinter) { int subCode = sinter.HeaderNode.SubCode; string targetId = sinter.HeaderNode.ParamsInfo.TargetId; if (subCode == serviceCodes["delta_prop_change_name"]) { if (hash.TryGetValue(targetId, out Control control)) { string newName = sinter.HeaderNode.ParamsInfo.Data2; control.BeginInvoke((Action)(() => { control.Name = newName; })); } } else if (subCode == serviceCodes["delta_prop_change_value"]) { if (hash.TryGetValue(targetId, out Control control)) { string newValue = sinter.HeaderNode.ParamsInfo.Data2; control.BeginInvoke((Action)(() => { control.Text = newValue; })); } } }
public void Test001_ls_Win7_Calc() { Process calc = bringupApp(path_win7_calc); /* create an input "ls_l" and execute it */ Sinter sinter_ls_req = new Sinter { HeaderNode = MsgUtil.BuildHeader(scraper.serviceCodes["ls_req"]), EntityNodes = null, }; cmdhlr.CommandExecSinter(sinter_ls_req); /* get ls_res */ Sinter sinter_ls_res = conn.GetSinterFromFile(conn.filepath); /* parse ls_res and find calculator */ string calcProcess = null; foreach (Entity proc in sinter_ls_res.EntityNodes) { Console.WriteLine(proc.Name + " " + proc.Process); if (proc.Name.IndexOf("calc", StringComparison.OrdinalIgnoreCase) >= 0) { calcProcess = proc.Process; break; } } Assert.IsTrue(calcProcess != null); //to check if calc is in the "ls_res" result. killProcess(calc); }
private void Control_Click(object sender, EventArgs e) { if (isSent) { return; } Button button = (Button)sender; Entity entity = (Entity)button.Tag; if (entity == null) { return; } Point center = GetCenter(entity); Sinter sinter = new Sinter { HeaderNode = MsgUtil.BuildHeader( serviceCodes["mouse"], serviceCodes["mouse_click_left"], "", "0", center.X.ToString(), center.Y.ToString() ), }; Console.WriteLine(sinter.HeaderNode.ParamsInfo.ToString()); execute_mouse(sinter); isSent = true; timer.Enabled = true; }
public void execute_ls_l_req(Sinter _) { Sinter sinter = new Sinter() { HeaderNode = MsgUtil.BuildHeader(serviceCodes["ls_l_req"]), }; connection.SendMessage(sinter); }
public void ProcessKeyPress(string keypresses) { Sinter sinter = new Sinter { HeaderNode = MsgUtil.BuildHeader(serviceCodes["kbd"]), }; sinter.HeaderNode.ParamsInfo = new Params() { TargetId = "", Data1 = keypresses, }; execute_kbd(sinter); }
public bool Render(string xmlfilePattern, Dictionary <string, Entity> dicScraper, Dictionary <string, Entity> dicProxy) { /* get input xml file and parse it to Sinter object */ Sinter sinterIn = conn.GetSinterFromFile(resultDir, xmlfilePattern); Console.WriteLine(@"Input filename: {0}\*{1}", resultDir, xmlfilePattern); Assert.IsTrue(sinterIn != null); /* execute the sinter, in this case: ls_l_res */ bool ret = cmdhlr.CommandExecSinter(sinterIn); Assert.IsTrue(ret); /* screenshot the render window, save to output folder */ Bitmap bmp = new Bitmap(proxy.Form.Width, proxy.Form.Height); proxy.Form.DrawToBitmap(bmp, new Rectangle(0, 0, proxy.Form.Width, proxy.Form.Height)); string pngfile = string.Format(@"{0}\{1}.png", TestContext.DeploymentDirectory, TestContext.TestName); bmp.Save(pngfile, ImageFormat.Png); Console.WriteLine("Output png saved to {0}", pngfile); /* create a dummy scraper to scraper our proxy window */ WindowsScraper.WindowsScraper dummyScraper = new WindowsScraper.WindowsScraper(); AutomationElement renderedElement = SinterUtil.GetAutomationElementFromId(Process.GetCurrentProcess().Id.ToString(), IdType.ProcessId); Assert.IsNotNull(renderedElement); Entity entityOut = dummyScraper.UIAElement2EntityRecursive(renderedElement); /* parse to two dictionay and compare */ ParseXML(sinterIn.EntityNode, dicScraper, 0); ParseXML(entityOut, dicProxy, 0); /* * foreach (KeyValuePair<string, Entity> kvp in dicScraper) * { * Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value.States); * } * Console.WriteLine("=================================="); * foreach (KeyValuePair<string, Entity> kvp in dicProxy) * { * Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value.States); * } */ proxy.dictFormCtrlButtons.Clear(); // this avoid user prompt proxy.Form.Close(); return(true); }
public void Test102_ls_l_WordPad() { Process calc = bringupApp(path_wordpad); /* create an input "ls_l_req" and execute it */ Sinter sinter_ls_l_req = new Sinter { HeaderNode = MsgUtil.BuildHeader(scraper.serviceCodes["ls_l_req"]), EntityNodes = null, }; sinter_ls_l_req.HeaderNode.Process = calc.Id.ToString(); cmdhlr.CommandExecSinter(sinter_ls_l_req); killProcess(calc); }
public void Test002_ls_l_Win7_Calc_Standard() { const string keyName = "HKEY_CURRENT_USER\\Software\\Microsoft\\Calc"; Registry.SetValue(keyName, "layout", 1); //switch to Standard mode Process calc = bringupApp(path_win7_calc); /* create an input "ls_l_req" and execute it */ Sinter sinter_ls_l_req = new Sinter { HeaderNode = MsgUtil.BuildHeader(scraper.serviceCodes["ls_l_req"]), EntityNodes = null, }; sinter_ls_l_req.HeaderNode.Process = calc.Id.ToString(); cmdhlr.CommandExecSinter(sinter_ls_l_req); killProcess(calc); }
public void execute_ls_l_res(Sinter sinter) { if (sinter.EntityNode == null) { return; } width = int.Parse(sinter.HeaderNode.ParamsInfo.Data1); height = int.Parse(sinter.HeaderNode.ParamsInfo.Data2); // remote/local ratio height_ratio = (float)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / height; width_ratio = (float)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / width; if (form == null) { form = (AppForm)Render(sinter.EntityNode, null); } //now show it root.DisplayProxy(form, requestedProcessId); }
public void execute_listener(Sinter sinter) { }
public void execute_mouse(Sinter sinter) { connection.SendMessage(sinter); }
public void execute_kbd(Sinter sinter) { Console.WriteLine("kbd: " + sinter.HeaderNode.ParamsInfo); //connection.SendMessage(sinter); }
public void execute_action(Sinter sinter) { }
// client related calls public void execute_ls_res(Sinter sinter) { List <Entity> new_processes = sinter.EntityNodes; root.PopulateGridView(new_processes); }
public void execute_event(Sinter sinter) { }