private Int32 EnumChildWindowProc(IntPtr hwnd, Int32 lParam)
            {
                ApiWindow window = GetWindowIdentification(hwnd);

                if (_childClass.Length == 0 || window.ClassName.ToLower() == _childClass.ToLower())
                {
                    _listChildren.Add(window);
                }
                return(1);
            }
            private ApiWindow GetWindowIdentification(IntPtr hwnd)
            {
                System.Text.StringBuilder classBuilder = new System.Text.StringBuilder(64);
                GetClassName(hwnd, classBuilder, 64);

                ApiWindow window = new ApiWindow();

                window.ClassName       = classBuilder.ToString();
                window.MainWindowTitle = WindowText(hwnd);
                window.hWnd            = hwnd;
                return(window);
            }
 private Int32 EnumWindowProc(IntPtr hwnd, Int32 lParam)
 {
     if (GetParent(hwnd) == 0 && IsWindowVisible(hwnd) != 0)
     {
         ApiWindow window = GetWindowIdentification(hwnd);
         if (_topLevelClass.Length == 0 || window.ClassName.ToLower() == _topLevelClass.ToLower())
         {
             _listTopLevel.Add(window);
         }
     }
     return(1);
 }
            private static ApiWindow GetWindowIdentification(IntPtr hwnd)
            {
                var classBuilder = new StringBuilder(64);

                GetClassName(hwnd, classBuilder, 64);

                var window = new ApiWindow {
                    ClassName       = classBuilder.ToString(),
                    MainWindowTitle = WindowText(hwnd),
                    HWnd            = hwnd
                };

                return(window);
            }
Exemple #5
0
            Int32 EnumChildWindowProc(Int32 hwnd, Int32 lParam)
            {
                StringBuilder classBuilder = new StringBuilder(64);

                Win32User.GetClassName(hwnd, classBuilder, 64);

                ApiWindow window = new ApiWindow(new IntPtr(hwnd), classBuilder.ToString());

                if (childClass.Length == 0 ||
                    window.ClassName.ToLower() == childClass)
                {
                    WindowList.Add(window);
                }
                return(1);
            }
Exemple #6
0
        private void OpenLibrary()
        {
            ApiWindow api = new ApiWindow();

            api.ShowDialog();
        }
Exemple #7
0
        void DoIt(Point startpt, Point endpt,
                  int startnox, int startnoy,
                  int pointsx, int pointsy,
                  int pointdelay,
                  string outfile,
                  int startdelay,
                  string keys4init,
                  string childprog, string childargs)
        {
            //WindowState = FormWindowState.Minimized;

            StartProg(childprog, childargs, startdelay);

            if (childargs.Length == 0)
            {
                childargs = "Unbenannt";
            }
            else
            {
                childargs = childargs.Substring(0, childargs.Length - 4);  // Dateiname ohne '.gpx'
            }
            ApiWindow progwin = new ApiWindow("{7A96B96B-E756-4e42-8274-54CBF24F7944}",
                                              childargs + " - MapSource");

            if (progwin == null || progwin.hWnd.ToInt32() == 0)
            {
                MessageBox.Show("Programm nicht gefunden!", "Fehler");
                Close();
                return;
            }

            ChildWindows childwin  = new ChildWindows(progwin.hWnd, "msctls_statusbar32");
            ApiWindow    statuswin = childwin.WindowList.Count > 0 ? childwin.WindowList[0] : null;

            if (statuswin == null)
            {
                MessageBox.Show("Statusbar nicht gefunden!", "Fehler");
                Close();
                return;
            }

            childwin = new ChildWindows(progwin.hWnd, "GarminMapWindow");
            ApiWindow clientwin = null;

            foreach (ApiWindow win in childwin.WindowList)
            {
                if (win.GetText().Trim() == "")
                {
                    clientwin = win;
                    break;
                }
            }

            progwin.SetForeground();
            Helper.Wait4Idle();

            // Regex zum Höhe ermitteln: z.B. "N54.53305 E13.41344, 17 ft"
            Regex r = new Regex(@"N\d+\.\d+\s+E\d+\.\d+,\s+(\d+)");

            StreamWriter wr = null;

            if (outfile.Length > 0)
            {
                try {
                    if (File.Exists(outfile))
                    {
                        File.Delete(outfile);
                    }
                    wr = new StreamWriter(outfile);
                } catch (Exception ex) {
                    MessageBox.Show(string.Format("Fehler beim Erzeugen der Datei '{0}'!", outfile) + System.Environment.NewLine + ex.Message, "Fehler");
                    Close();
                }
            }

            if (keys4init.Length > 0)
            {
                Helper.SendKeys(keys4init);
                Helper.Wait4Idle();
            }

            Helper.MousePosition = startpt;
            Helper.Wait(500);

            if (outfile.Length > 0)
            {
                wr.WriteLine(outfile);
            }

            // Spaltenüberschriften
            for (int stepx = 0; stepx < pointsx; stepx++)
            {
                if (wr != null)
                {
                    wr.Write("\t");
                    wr.Write(startnox + stepx);
                }
                else
                {
                    Debug.Write("\t");
                    Debug.Write(startnox + stepx);
                }
            }
            if (wr != null)
            {
                wr.WriteLine();
            }
            else
            {
                Debug.WriteLine("");
            }

            for (int stepy = 0; stepy < pointsy; stepy++)
            {
                for (int stepx = 0; stepx < pointsx; stepx++)
                {
                    // Maus-Position setzen (Rundung halbiert den max. möglichen Fehler)
                    Point newpos = new Point(startpt.X + (pointsx <= 1 ? 0 : (int)Math.Round(((double)stepx * (endpt.X - startpt.X)) / (pointsx - 1))),
                                             startpt.Y + (pointsy <= 1 ? 0 : (int)Math.Round(((double)stepy * (endpt.Y - startpt.Y)) / (pointsy - 1))));
                    Helper.MousePosition = newpos;
                    //Helper.MouseLeftClick();
                    Helper.Wait4Idle(progwin);
                    //Helper.Wait(1);
                    Helper.WaitExt(pointdelay);

                    // Höhe ermitteln: z.B. "N54.53305 E13.41344, 17 ft"
                    string txt = Helper.GetPanelText(statuswin.hWnd, 2);   // 3. Panel
                    Match  m   = r.Match(txt);
                    if (m.Success)
                    {
                        int    h = Convert.ToInt32(m.Groups[1].Value);
                        string v = h > 0 ? h.ToString() : ".";

                        if (wr != null)
                        {
                            if (stepx == 0)
                            {
                                wr.Write(startnoy + stepy);
                            }
                            wr.Write("\t");

                            //wr.Write(newpos.X);
                            //wr.Write(";");

                            wr.Write(v);
                        }
                        else
                        {
                            if (stepx == 0)
                            {
                                Debug.Write(startnoy + stepy);
                            }
                            Debug.Write("\t");
                            Debug.Write(v);
                        }
                    }
                    else
                    {
                        stepx = pointsx;
                        stepy = pointsy;
                        if (wr != null)
                        {
                            wr.Close();
                            wr = null;
                            if (File.Exists(outfile))
                            {
                                File.Delete(outfile);
                            }
                        }
                    }
                }
                if (wr != null)
                {
                    wr.WriteLine();
                }
                else
                {
                    Debug.WriteLine("");
                }
            }

            if (wr != null)
            {
                wr.Close();
            }

            // Programm beenden
            Helper.SendKeys("%{F4}");

            Close();
        }
Exemple #8
0
            /// <summary>
            /// wartet, bis für das Programm die Nachrichtenwarteschlange leer ist
            /// </summary>
            /// <param name="hWndProg"></param>
            public static void Wait4Idle(ApiWindow win)
            {
                Process p = Process.GetProcessById((int)win.GetProcessId(true));

                p.WaitForInputIdle();
            }
            private ApiWindow GetWindowIdentification(IntPtr hwnd)
            {
                StringBuilder classBuilder = new StringBuilder(64);
                GetClassName(hwnd, classBuilder, 64);

                ApiWindow window = new ApiWindow
                {
                    ClassName = classBuilder.ToString(),
                    MainWindowTitle = WindowText(hwnd),
                    hWnd = hwnd
                };
                return window;
            }
            private ApiWindow GetWindowIdentification(IntPtr hwnd)
            {
                System.Text.StringBuilder classBuilder = new System.Text.StringBuilder(64);
                GetClassName(hwnd, classBuilder, 64);

                ApiWindow window = new ApiWindow();
                window.ClassName = classBuilder.ToString();
                window.MainWindowTitle = WindowText(hwnd);
                window.hWnd = hwnd;
                return window;
            }