Пример #1
0
        /// <summary>
        /// 判断是否只读
        /// </summary>
        public bool IsOnlyRead(string pptPath)
        {
            RECT rt = new RECT();

            string pptTitle   = "" + fileNameWithExtension + " - Microsoft PowerPoint";
            IntPtr m_hGameWnd = User32API.FindWindow(null, pptTitle);

            if (m_hGameWnd == IntPtr.Zero)
            {
                ppt = new PPTHelper();
                ppt.PPTOpen(pptPath);
                m_hGameWnd = User32API.FindWindow(null, pptTitle);
            }

            pptTitle   = "Microsoft Office 激活向导";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            if (m_hGameWnd != IntPtr.Zero)
            {
                MessageBox.Show("请将Microsoft Office激活", "提示");
            }
            Thread.Sleep(1000 * 3);
            pptTitle   = "" + fileNameWithExtension + " - Microsoft PowerPoint";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            User32API.SwitchToThisWindow(m_hGameWnd, true);
            //User32API.GetWindowRect(m_hGameWnd, out rt);
            User32API.MoveWindow(m_hGameWnd, 0, 0, 1300, 800, true);//拖动到左上角
            //MouseCliceBackGround(m_hGameWnd, 570, 50);
            MouseClick(570, 50);
            MouseClick(100, 95);

            pptTitle   = "Checking for updates";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            if (m_hGameWnd != IntPtr.Zero)
            {
                MessageBox.Show("请将iSpring插件自动更新关闭", "提示");
            }
            Thread.Sleep(1000 * 1);
            pptTitle   = "发布为Flash";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            if (m_hGameWnd == IntPtr.Zero)
            {
                pptTitle   = "iSpring Free";
                m_hGameWnd = User32API.FindWindow(null, pptTitle);
                User32API.SwitchToThisWindow(m_hGameWnd, true);
                User32API.GetWindowRect(m_hGameWnd, out rt);
                User32API.MoveWindow(m_hGameWnd, 0, 0, rt.Width, rt.Height, true);//拖动到左上角
                MouseClick(420, 160);
                ppt.PPTClose();
                return(true);
            }
            else
            {
                User32API.SwitchToThisWindow(m_hGameWnd, true);
                User32API.GetWindowRect(m_hGameWnd, out rt);
                User32API.MoveWindow(m_hGameWnd, 0, 0, rt.Width, rt.Height, true);//拖动到左上角
                Thread.Sleep(1000 * 1);
                MouseClick(720, 575);
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 图像识别,驱动点击
        /// </summary>
        public void AutoClick(string tempPPTPath, string pptPath)
        {
            RECT rt = new RECT();

            KillProcess("POWERPNT");

            string pptTitle   = "" + fileNameWithExtension + " - Microsoft PowerPoint";
            IntPtr m_hGameWnd = User32API.FindWindow(null, pptTitle);

            if (m_hGameWnd == IntPtr.Zero)
            {
                ppt = new PPTHelper();
                ppt.PPTOpen(pptPath);
                m_hGameWnd = User32API.FindWindow(null, pptTitle);
            }

            Thread.Sleep(1000 * 5);

            pptTitle   = "Microsoft Office 激活向导";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            if (m_hGameWnd != IntPtr.Zero)
            {
                MessageBox.Show("请将Microsoft Office激活", "提示");
            }

            pptTitle   = "" + fileNameWithExtension + " - Microsoft PowerPoint";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            User32API.SwitchToThisWindow(m_hGameWnd, true);
            //User32API.GetWindowRect(m_hGameWnd, out rt);
            User32API.MoveWindow(m_hGameWnd, 0, 0, 1300, 800, true); //拖动到左上角

            MouseClick(570, 50);                                     //点击ispring
            MouseClick(80, 80);                                      //点击publish
            //Clipboard.Clear();
            Thread.Sleep(1000);
            pptTitle   = "Checking for updates";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            if (m_hGameWnd != IntPtr.Zero)
            {
                MessageBox.Show("请将iSpring插件自动更新关闭", "提示");
            }

            pptTitle   = "发布为Flash";
            m_hGameWnd = User32API.FindWindow(null, pptTitle);
            if (m_hGameWnd != IntPtr.Zero)
            {
                User32API.SwitchToThisWindow(m_hGameWnd, true);
                User32API.GetWindowRect(m_hGameWnd, out rt);
                User32API.MoveWindow(m_hGameWnd, 0, 0, rt.Width, rt.Height, true);//拖动到左上角
                try
                {
                    Clipboard.Clear();
                    Clipboard.SetText(fileNameWithoutExtension);
                    MouseClick(500, 125);
                    SendKeys.SendWait("^A");
                    Thread.Sleep(500);
                    SendKeys.SendWait("{BACKSPACE}");
                    Thread.Sleep(500);
                    SendKeys.SendWait("^V");  //Ctrl+V 组合键
                    Thread.Sleep(500);
                    Clipboard.Clear();

                    //User32API.Keybd_event(VirtualKey.BACK, 0, KeyEvent.KEYEVENTF_EXTENDEDKEY, 0);
                    //Thread.Sleep(500);
                    //SendKeys.SendWait(fileNameWithoutExtension);
                }
                catch (Exception ex)
                {
                    WriteLog(ex.ToString());
                }
                try
                {
                    MouseClick(500, 175);
                    Clipboard.Clear();
                    Clipboard.SetText(tempPPTPath);
                    SendKeys.SendWait("^A");
                    Thread.Sleep(500);
                    SendKeys.SendWait("{BACKSPACE}");
                    Thread.Sleep(500);
                    SendKeys.SendWait("^V");  //Ctrl+V 组合键
                    Thread.Sleep(500);
                    Clipboard.Clear();

                    //MouseClick(500, 175);
                    //User32API.Keybd_event(VirtualKey.BACK, 0, KeyEvent.KEYEVENTF_EXTENDEDKEY, 0);
                    //Thread.Sleep(500);
                    //SendKeys.SendWait(tempPPTPath);
                }
                catch (Exception ex)
                {
                    WriteLog(ex.ToString());
                }
                MouseClick(630, 570);//点击发布

                while (true)
                {
                    Thread.Sleep(1000 * 5);
                    pptTitle   = "正在生成Flash影片 {presentation_title}";
                    m_hGameWnd = User32API.FindWindow(null, pptTitle);
                    if (m_hGameWnd == IntPtr.Zero)
                    {
                        break;
                    }
                }
                KillProcess("360chrome");
                KillProcess("360se");
                KillProcess("explorer");
                KillProcess("chrome");
                KillProcess("iexplore");
            }
            else
            {
                MessageBox.Show("PPT可能无法正常使用iSpring插件", "提示");
                return;
            }

            string tarFlash = targetPath + @"\" + fileNameWithoutExtension + @"\" + fileNameWithoutExtension + ".swf";

            if (File.Exists(tarFlash))
            {
                File.Delete(tarFlash);
            }
            string sPath = tempPPTPath + fileNameWithoutExtension + @"\" + fileNameWithoutExtension + ".swf";

            if (File.Exists(sPath))
            {
                File.Move(sPath, tarFlash);
            }

            if (ppt != null)
            {
                ppt.PPTClose();
            }
            KillProcess("POWERPNT");
        }
Пример #3
0
        public void StartDeal()
        {
            if (pptPathList.Count <= 0)
            {
                return;
            }

            foreach (var path in pptPathList)
            {
                fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); //获取文件名,没有扩展名的文件名
                fileNameWithExtension    = Path.GetFileName(path);                 //获取文件名
                singlePath = targetPath + @"\" + fileNameWithoutExtension + @"\";
                if (Directory.Exists(singlePath))
                {
                    DirectoryInfo subdir = new DirectoryInfo(singlePath);
                    subdir.Delete(true);
                }
                ppt.PPTOpen(path);//打开PPT
                if (ppt.objApp == null || ppt.objPresSet == null)
                {
                    string tarFName      = Path.GetFileName(path);
                    string errorFullName = errorPath + @"\" + tarFName;
                    if (File.Exists(path))
                    {
                        if (!Directory.Exists(errorPath))
                        {
                            Directory.CreateDirectory(errorPath);
                        }
                        File.Move(path, errorFullName);
                    }
                    continue;
                }
                if (IsOnlyRead(path))
                {
                    try
                    {
                        string tarFName      = Path.GetFileName(path);
                        string errorFullName = errorPath + @"\" + tarFName;
                        if (File.Exists(path))
                        {
                            if (!Directory.Exists(errorPath))
                            {
                                Directory.CreateDirectory(errorPath);
                            }
                            if (File.Exists(errorFullName))
                            {
                                File.Delete(errorFullName);
                            }
                            File.Move(path, errorFullName);
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog(ex.ToString());
                    }
                    continue;
                }
                if (!Directory.Exists(singlePath))
                {
                    Directory.CreateDirectory(singlePath);
                }

                string pptTitle   = "" + fileNameWithoutExtension + " - Microsoft PowerPoint";
                IntPtr m_hGameWnd = User32API.FindWindow("PPTFrameClass", null);
                if (m_hGameWnd != IntPtr.Zero)
                {
                    StringBuilder s        = new StringBuilder(512);
                    int           intTitle = User32API.GetWindowText(m_hGameWnd, s, s.Capacity); //把this.handle换成你需要的句柄
                    string        strTitle = intTitle.ToString();
                    if (strTitle.Contains("受保护的视图"))
                    {
                        if (File.Exists(path))
                        {
                            if (!Directory.Exists(errorPath))
                            {
                                Directory.CreateDirectory(errorPath);
                            }
                            string tarFName      = Path.GetFileName(path);
                            string errorFullName = errorPath + @"\" + tarFName;
                            File.Move(path, errorFullName);
                        }
                        //MouseClick(105, 80);
                        continue;
                    }
                }
                SetUploadDetails();  //生成一个txt,保存上传信息

                TextReplacement();   //第一步,文字替换

                ChangeToPic(path);   //第二步,转换成图片

                ppt.PPTClose();      //关闭PPT,释放资源

                ToCompressPPT(path); //第三步,压缩PPT

                PPTToFlash(path);    //第四步,PPT转换成flash

                if (File.Exists(path))
                {
                    if (!Directory.Exists(successPath))
                    {
                        Directory.CreateDirectory(successPath);
                    }
                    string starFName       = Path.GetFileName(path);
                    string successFullName = successPath + @"\" + starFName;
                    if (File.Exists(successFullName))
                    {
                        File.Delete(successFullName);
                    }
                    File.Move(path, successFullName);
                }
            }
        }