Ejemplo n.º 1
0
        private void TSaveAs()
        {
            IntPtr windowPtr = WinApiHelper.FindWindowHandle("图形导出");

            if (windowPtr != IntPtr.Zero)
            {
                IntPtr btnSetPtr = WinApiHelper.GetControlInptr(windowPtr, "保存(&S)");
                if (btnSetPtr != IntPtr.Zero)
                {
                    WinApiHelper.PostMessage1(btnSetPtr);
                }
                number++;
            }
            else if (number > 0)
            {
                number++;
                if (number >= 3000)                  //5分钟还没关闭
                {
                    KillProcess(Process.GetCurrentProcess());
                }
            }
            else
            {
                WinApiHelper.ClickMouse();
            }
        }
Ejemplo n.º 2
0
        void timer_Elapsed(object sender)
        {
            TSaveAs();
            Thread.Sleep(10);
            IntPtr windowPtr = WinApiHelper.FindWindowHandle("确认另存为");

            if (windowPtr != IntPtr.Zero)
            {
                timer.Dispose();
                while (true)
                {
                    if (WinApiHelper.FindWindowHandle("确认另存为") == IntPtr.Zero)
                    {
                        Excute();
                        break;
                    }
                    else
                    {
                        IntPtr btnSetPtr = WinApiHelper.GetControlInptr(windowPtr, "是(&Y)");
                        if (btnSetPtr != IntPtr.Zero)
                        {
                            WinApiHelper.PostMessage1(btnSetPtr);
                        }
                        else
                        {
                            WinApiHelper.SendKey((int)System.Windows.Forms.Keys.Y);
                        }
                    }
                }
            }
            windowPtr = WinApiHelper.FindWindowHandle("AutoCAD");
            if (windowPtr != IntPtr.Zero)
            {
                timer.Dispose();
                int i = 0;
                while (true)
                {
                    if (WinApiHelper.FindWindowHandle("AutoCAD") == IntPtr.Zero)
                    {
                        Excute();
                        break;
                    }
                    else
                    {
                        IntPtr btnSetPtr = WinApiHelper.GetControlInptr(windowPtr, "否(&N)");
                        if (btnSetPtr != IntPtr.Zero)
                        {
                            WinApiHelper.PostMessage1(btnSetPtr);
                        }
                        else
                        {
                            WinApiHelper.SendKey((int)System.Windows.Forms.Keys.N);
                        }
                        Thread.Sleep(10);
                        i++;
                        if (i >= 100)
                        {
                            break;
                        }
                    }
                }
            }
        }