Example #1
0
        public void Populate()
        {
            windows_list = new List <WindowEntry>();
            ImageList icons = new ImageList();

            windows_list = OpenWindowGetter.GetOpenWindows();

            string my_process_name = Process.GetCurrentProcess().ProcessName + ".exe";

            // filter out our windows
            windows_list = windows_list.Where(win => win.Process != my_process_name).ToList();

            foreach (WindowEntry win in windows_list)
            {
                ushort        uicon;
                StringBuilder strB = new StringBuilder(260); // Allocate MAX_PATH chars
                strB.Append(win.ProcessPath);
                IntPtr handle = ExtractAssociatedIcon(IntPtr.Zero, strB, out uicon);
                Icon   icon   = Icon.FromHandle(handle);;

                // clone icon to a Bitmap object so we can release the handle
                Bitmap bitmap = icon.ToBitmap();

                // need to close icon handle since we used low api
                DestroyIcon(handle);

                icons.Images.Add(win.ProcessPath, bitmap);
            }

            olv.SmallImageList = icons;
            olv.SetObjects(windows_list);
            olv.Refresh();
        }
Example #2
0
        private void CreateViewPointDocs(string systemname, string path, SPES_DocumentReferencer pReferencer)
        {
            using (Application app = new Application())
            {
                Application subapplic  = this._application;
                IntPtr      appkey     = new IntPtr(0);
                IntPtr      helpappkey = new IntPtr(0);
                Application applic     = null;
                foreach (var window in OpenWindowGetter.GetOpenWindows())
                {
                    if (window.Value.Contains("Visio Professional"))
                    {
                        OpenWindowGetter.SetForegroundWindow(window.Key);
                        applic = NetOffice.VisioApi.Application.GetActiveInstance();
                        if (app == applic)
                        {
                            helpappkey = window.Key;
                        }
                        else if (applic == this._application)
                        {
                            appkey = window.Key;
                        }
                        ;
                    }
                    ;
                }
                OpenWindowGetter.SetForegroundWindow(helpappkey);
                CreateemptyModels(app, path, systemname, pReferencer);
                var doc = app.Documents.Add("");
                CreateRvp(systemname, doc);
                doc.SaveAs(System.IO.Path.Combine(path, systemname + "_RVP.vsdx"));
                doc.Close();

                doc = app.Documents.Add("");
                CreateFvp(systemname, doc);
                //app.Documents.OpenEx("SMT_FN_Funktionsnetz.vssx", 4); app.Documents.OpenEx("SMT_IA.vssx", 4);
                doc.SaveAs(System.IO.Path.Combine(path, systemname + "_FVP.vsdx"));
                doc.Close();
                pReferencer.AddAssignment(systemname + "_FVP.vsdx", typeof(FunktionsnetzNetwork).Name);

                doc = app.Documents.Add("");
                CreateLvp(systemname, doc);
                //app.Documents.OpenEx("SMT_Class.vssx", 4);
                doc.SaveAs(System.IO.Path.Combine(path, systemname + "_LVP.vsdx"));
                doc.Close();
                pReferencer.AddAssignment(systemname + "_LVP.vsdx", typeof(LogicalViewpointNetwork).Name);

                doc = app.Documents.Add("");
                CreateTvp(systemname, doc);
                //app.Documents.OpenEx("SMT_SM.vssx", 4);
                //app.Documents.OpenEx("SMT_IA.vssx", 4);
                doc.SaveAs(System.IO.Path.Combine(path, systemname + "_TVP.vsdx"));
                doc.Close();
                pReferencer.AddAssignment(systemname + "_TVP.vsdx", typeof(TechnicalViewpointNetwork).Name);

                OpenWindowGetter.SetForegroundWindow(appkey);
                app.Quit();
            }
        }
        public Window Get(string name)
        {
            var listofwind = OpenWindowGetter.GetListOfWindows();
            var findedname = listofwind.FirstOrDefault(a => a.Name == name);

            if (findedname != null)
            {
                return(findedname);
            }
            throw new HttpRequestWithStatusException("Erorr 404  can't find name");
        }
Example #4
0
        private void FindAllVisibleWindows()
        {
            foreach (KeyValuePair <IntPtr, uint> window in OpenWindowGetter.GetOpenWindows())
            {
                IntPtr handle  = window.Key;
                uint   process = window.Value;

                newWindowList.Add(new WindowInfo()
                {
                    handle = handle, id = process
                });
            }
        }
Example #5
0
        private void DispatcherTimerErrorPopUpTick(object sender, EventArgs e)
        {
            foreach (KeyValuePair <IntPtr, string> window in OpenWindowGetter.GetOpenWindows())
            {
                IntPtr handle = window.Key;
                string title  = window.Value;

                if (title.ToLower().Equals("failed to connect") ||
                    title.ToLower().Contains("network") ||
                    title.ToLower().Contains("netzwerkfehler") ||
                    title.Equals("VoliBot"))
                {
                    SendMessage(handle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
                }
            }
        }
Example #6
0
        private IntPtr GetPokerTableHandle()
        {
            IntPtr tableHandle = IntPtr.Zero;

            foreach (KeyValuePair <IntPtr, string> window in OpenWindowGetter.GetOpenWindows())
            {
                IntPtr handle = window.Key;
                string title  = window.Value;
                if (title.IndexOf("Hold'em") != -1 && (title.IndexOf("USD") != -1))
                {
                    tableHandle = handle;
                }
            }

            return(tableHandle);
        }
Example #7
0
        static void Main(string[] args)
        {
            foreach (KeyValuePair <IntPtr, string> window in OpenWindowGetter.GetOpenWindows())
            {
                if (window.Value.Contains("Antimatter"))
                {
                    IntPtr handle = window.Key;
                    string title  = window.Value;

                    // This line gets the key and name of the window currently playing antimatter
                    // Should be able to start doing click stuff? No need to prompt user at all
                    Console.WriteLine("{0}: {1}", handle, title);
                }
            }

            Console.ReadKey();
        }
Example #8
0
        static void Main(string[] args)
        {
            WindowClient client = new WindowClient("http://localhost:8090");

            Console.WriteLine("The following windows are above the browser in z order:\n");
            foreach (WindowInfo window in OpenWindowGetter.GetWindowsAboveBrowser())
            {
                IntPtr handle = window.WindowHandle;
                string title  = window.WindowText;
                long   topX   = window.Info.rcWindow.Left;
                long   topY   = window.Info.rcWindow.Top;
                long   botX   = window.Info.rcWindow.Right;
                long   botY   = window.Info.rcWindow.Bottom;

                Console.WriteLine("{0}:      {1}\nTopX: {2}\nTopY: {3}\nBotX: {4}\nBotY: {5}\n\n", handle, title, topX, topY, botX, botY);

                client.SendWindowInfo(window).Wait();
            }
        }
Example #9
0
File: Main.cs Project: lbl1985/Wox
        public List <Result> Query(Query query)
        {
            List <Result> resList = new List <Result> {
            };

            foreach (KeyValuePair <IntPtr, string> window in OpenWindowGetter.GetOpenWindows())
            {
                string windowTitle  = window.Value;
                IntPtr windowHandle = window.Key;

                if (windowTitle != "Wox")
                {
                    string ProcessPath = "";
                    try
                    {
                        ProcessPath = GetProcessPath(windowHandle);
                    }
                    catch (Exception e)
                    {
                    }
                    resList.Add(new Result
                    {
                        Title    = window.Value,
                        SubTitle = ProcessPath,
                        IcoPath  = ProcessPath,
                        Action   = e =>
                        {
                            // after user select the item

                            // return false to tell Wox don't hide query window, otherwise Wox will hide it automatically
                            BringToForeground(windowHandle);
                            return(true);
                        }
                    });
                }
            }

            var resList1 = resList.Where(p => p.Title.ToLower().Contains(query.Search.ToLower())).ToList();

            return(resList1);
        }
Example #10
0
        private void CreateSubSystemElements(IVPage p, IntPtr appkey, SPES_DocumentReferencer pReferencer)
        {
            using (Application app = new Application())
            {
                Application subapplic  = this._application;
                IntPtr      helpappkey = new IntPtr(0);
                Application applic     = null;;

                foreach (var window in OpenWindowGetter.GetOpenWindows())
                {
                    if (window.Value.Contains("Visio Professional"))
                    {
                        OpenWindowGetter.SetForegroundWindow(window.Key);
                        applic = NetOffice.VisioApi.Application.GetActiveInstance();
                        if (app == applic)
                        {
                            helpappkey = window.Key;
                        }
                        ;
                    }
                    ;
                }
                OpenWindowGetter.SetForegroundWindow(helpappkey);
                CreateemptyModels(app, this._application.ActiveDocument.Path, p.Name, pReferencer);
                IVShape     header, systemName, rvp, fvp, lvp, tvp, statusRvp, statusFvp, statusLvp, statusTvp;
                IVHyperlink rvphl, fvphl, lvphl, tvphl;
                header = p.DrawRectangle(1, 1, 8, 1.5); header.LineStyle = "none"; header.Text = "Artifacts of " + p.Name;
                header.SetCenter(4, (28 / 2.54)); header.CellsSRC(3, 0, 7).FormulaU = "24 pt";
                header.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";

                systemName = p.DrawRectangle(1, 1, 8, 4); systemName.Text = p.Name; systemName.SetCenter(4, (23.2 / 2.54));
                systemName.CellsSRC(1, 11, 4).Formula = "0"; systemName.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";

                rvp = p.DrawRectangle(1, 1, 2.5, 3); rvp.Text = "Requirements Engineering Viewpoint";
                rvp.SetCenter(4.2 / 2.54, (22.8 / 2.54)); rvp.CellsSRC(1, 11, 4).Formula = "0";
                rvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";
                statusRvp = p.DrawOval(1, 1, 1.16, 1.16); statusRvp.SetCenter(4.2 / 2.54, 23.5 / 2.54); statusRvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,0,0))";

                fvp = p.DrawRectangle(1, 1, 2.5, 3); fvp.Text = "Functional Viewpoint"; fvp.SetCenter(8.2 / 2.54, (22.8 / 2.54));
                fvp.CellsSRC(1, 11, 4).Formula = "0"; fvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";
                statusFvp = p.DrawOval(1, 1, 1.16, 1.16); statusFvp.SetCenter(8.2 / 2.54, 23.5 / 2.54); statusFvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,0,0))";

                lvp = p.DrawRectangle(1, 1, 2.5, 3); lvp.Text = "Logical Viewpoint"; lvp.SetCenter(12.2 / 2.54, (22.8 / 2.54));
                lvp.CellsSRC(1, 11, 4).Formula = "0"; lvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";
                statusLvp = p.DrawOval(1, 1, 1.16, 1.16); statusLvp.SetCenter(12.2 / 2.54, 23.5 / 2.54); statusLvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,0,0))";

                tvp = p.DrawRectangle(1, 1, 2.5, 3); tvp.Text = "Technical Viewpoint"; tvp.SetCenter(16.2 / 2.54, (22.8 / 2.54));
                tvp.CellsSRC(1, 11, 4).Formula = "0"; tvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";
                statusTvp = p.DrawOval(1, 1, 1.16, 1.16); statusTvp.SetCenter(16.2 / 2.54, 23.5 / 2.54); statusTvp.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,0,0))";

                var doc = app.Documents.Add("");
                CreateRvp(p.Name, doc);
                doc.SaveAs(System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_RVP.vsdx"));

                doc.Close();
                rvphl         = rvp.AddHyperlink();
                rvphl.Address = (System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_RVP.vsdx"));

                doc = app.Documents.Add("");
                CreateFvp(p.Name, doc);
                //todo: load shapes -> load modules
                //app.Documents.OpenEx("SMT_FN_Funktionsnetz.vssx", 4);
                //app.Documents.OpenEx("SMT_IA.vssx", 4);
                doc.SaveAs(System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_FVP.vsdx"));
                doc.Close();
                pReferencer.AddAssignment(systemName.Text + "_FVP.vsdx", typeof(FunktionsnetzNetwork).Name);
                fvphl         = fvp.AddHyperlink();
                fvphl.Address = (System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_FVP.vsdx"));

                doc = app.Documents.Add("");
                CreateLvp(p.Name, doc);
                //app.Documents.OpenEx("SMT_Class.vssx", 4);
                doc.SaveAs(System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_LVP.vsdx"));
                doc.Close();
                pReferencer.AddAssignment(systemName.Text + "_LVP.vsdx", typeof(LogicalViewpointNetwork).Name);
                lvphl         = lvp.AddHyperlink();
                lvphl.Address = (System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_LVP.vsdx"));

                doc = app.Documents.Add("");
                CreateTvp(p.Name, doc);
                //app.Documents.OpenEx("SMT_SM.vssx", 4);
                //app.Documents.OpenEx("SMT_IA.vssx", 4);
                doc.SaveAs(System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_TVP.vsdx"));
                doc.Close();
                pReferencer.AddAssignment(systemName.Text + "_TVP.vsdx", typeof(TechnicalViewpointNetwork).Name);
                tvphl         = tvp.AddHyperlink();
                tvphl.Address = (System.IO.Path.Combine(this._application.ActiveDocument.Path, systemName.Text + "_TVP.vsdx"));
                app.Quit();
                OpenWindowGetter.SetForegroundWindow(appkey);
            }
        }
Example #11
0
        public void CreateSubsystems(SPES_DocumentReferencer pReferencer)
        {
            //bestimme Namen des übergeordneten Systems anhand des Seitennamens

            IVPage active     = this._application.ActivePage;
            string systemname = active.Name.Substring(4);

            //TODO: check if file is LVP_Overview datei (Logical Viewpoint) / Logical Design
            if (this._application.ActiveDocument.Name != $"{systemname}_LVP.vsdx")
            {
                throw new Exception("Active Document is not the LVP overview file.");
            }

            IVSelection    selects = this._application.ActiveWindow.Selection;
            List <IVShape> shapes  = new List <IVShape>();

            foreach (var shape in selects.SelectionForDragCopy)
            {
                if (shape.Shapes != null)
                {
                    bool firstshape = true;
                    int  count      = 0;
                    foreach (var subshape in shape.Shapes)
                    {
                        count++;
                        if (count % 2 == 1)
                        {
                            if (firstshape == true)
                            {
                                shapes.Add(subshape);
                            }
                            firstshape = false;
                        }
                    }
                }
                else
                {
                    shapes.Add(shape);
                }
            }
            //System.Windows.Forms.MessageBox.Show("Create Documents?");
            //getPage "Systemübersicht"--> dazu Document holen mit passender Page
            //speichere aktuelle Applikation ab und suche Applikation mit der Page "Systemübersicht"
            IVDocument  systemdoc      = null;
            IVPage      systemoverview = null;
            Application subapplic      = this._application;
            IntPtr      subapplickey   = new IntPtr(0);
            IntPtr      applickey      = new IntPtr(0);
            Application applic         = null;;
            bool        found          = false;

            foreach (var window in OpenWindowGetter.GetOpenWindows())
            {
                if (found == false)
                {
                    if (window.Value.Contains("Visio Professional") || window.Value.Contains("Microsoft Visio"))
                    {
                        OpenWindowGetter.SetForegroundWindow(window.Key);
                        applic = NetOffice.VisioApi.Application.GetActiveInstance();
                        if (subapplic == applic)
                        {
                            subapplickey = window.Key;
                        }
                        ;
                        foreach (var doc in applic.Documents)
                        {
                            foreach (var page in doc.Pages)
                            {
                                if (page.Name == "System Overview")
                                {
                                    systemdoc      = doc;
                                    systemoverview = page;
                                    applickey      = window.Key;
                                    found          = true;
                                }
                            }
                        }
                    }
                }
            }

            if (found == false)
            {
                var file = new System.IO.DirectoryInfo(
                    new System.IO.FileInfo(_application.ActiveDocument.FullName).Directory.FullName)
                           .GetFiles().First(t => t.Name.Contains("_Overview.vsdx"));
                _application.Documents.Open(file.FullName);

                foreach (var window in OpenWindowGetter.GetOpenWindows())
                {
                    if (found == false)
                    {
                        if (window.Value.Contains("Visio Professional") || window.Value.Contains("Microsoft Visio"))
                        {
                            OpenWindowGetter.SetForegroundWindow(window.Key);
                            applic = NetOffice.VisioApi.Application.GetActiveInstance();
                            if (subapplic == applic)
                            {
                                subapplickey = window.Key;
                            }
                            ;
                            foreach (var doc in applic.Documents)
                            {
                                foreach (var page in doc.Pages)
                                {
                                    if (page.Name == "System Overview")
                                    {
                                        systemdoc      = doc;
                                        systemoverview = page;
                                        applickey      = window.Key;
                                        found          = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //erstelle für jede ausgewählte Shape/Subsystem auf dem Zeichenblatt "Systemübersicht" ein Rechteck und verbinde dieses mit dem höher gelegenen System
            int     counter  = 0;
            int     sum      = shapes.Count;
            IVShape preshape = null;

            foreach (var shape in systemoverview.Shapes)
            {
                if (shape.Text == systemname)
                {
                    preshape = shape;
                }
            }
            double xvalue = (Convert.ToDouble(preshape.CellsSRC(1, 1, 0).FormulaU.Substring(0, preshape.CellsSRC(1, 1, 0).FormulaU.IndexOf(' ')))) / 10;
            double yvalue = (Convert.ToDouble(preshape.CellsSRC(1, 1, 1).FormulaU.Substring(0, preshape.CellsSRC(1, 1, 1).FormulaU.IndexOf(' ')))) / 10;

            foreach (var shape in shapes)
            {
                IVShape subsystem = systemoverview.DrawRectangle(1, 1, 3, 1.5);
                subsystem.Text = shape.Text;
                subsystem.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";
                subsystem.SetCenter(BerechneXPosition(xvalue, sum, counter) / 2.54, (yvalue - 3.0) / 2.54);
                counter++;
                //verbinde zu übergeordnetem System
                preshape.AutoConnect(subsystem, 0);
                //erstelle neues Zeichenblatt und erstelle Hyperlink
                IVPage shapePage = systemdoc.Pages.Add();
                shapePage.Name = shape.Text;
                IVHyperlink hl = subsystem.Hyperlinks.Add();
                hl.SubAddress = shapePage.Name; //geht nur wenn, Page in selber Dokumentebene ist.

                //rufe Methode auf, die für die gespeicherten Pages, die benötigten Dokumente erstellt und einbindet
                CreateSubSystemElements(shapePage, applickey, pReferencer);
            }
            //setze Verbinder als gerade/straight
            foreach (var connects in systemoverview.Shapes)
            {
                if (connects.Name.Contains("Dynamic connector") || connects.Name.Contains("Dynamischer Verbinder"))
                {
                    connects.CellsSRC(1, 23, 10).Formula = "16";
                }
            }

            //systemoverview.CreateSelection(VisSelectionTypes.visSelTypeAll).Align(VisHorizontalAlignTypes.visHorzAlignLeft, VisVerticalAlignTypes.visVertAlignMiddle) ;
            OpenWindowGetter.SetForegroundWindow(subapplickey);
        }
Example #12
0
        public void GetOpenWindowsTest()
        {
            var openWindows = OpenWindowGetter.GetOpenWindows();

            Assert.IsTrue(openWindows.Any());
        }
 public IEnumerable <Window> Get()
 {
     return(OpenWindowGetter.GetListOfWindows());
 }
 /// <summary>
 ///     Gets all the windows in the smart proc
 /// </summary>
 public static List <Window> GetWindows(this SmartProcess sproc)
 {
     return(OpenWindowGetter.GetOpenWindows(sproc.Id).Select(hwnd => Window.Create(sproc, hwnd)).ToList());
 }