Esempio n. 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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 判断窗口是否在运行
        /// </summary>
        /// <param name="WindowsTitle">窗口的标题名称</param>
        /// <returns></returns>
        public bool IsRuning(string WindowsTitle)
        {
            IntPtr WindowHandle = User32API.FindWindow(null, WindowsTitle);//窗口句柄

            if (WindowHandle == IntPtr.Zero)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加信息
        /// </summary>
        public void ToAdd()
        {
            if (detailsList.Count > 0)
            {
                KillProcess("firefox");
                Process.Start(browserPath, addUrl);
                string title      = "手工新增客户 - Mozilla Firefox";
                string className  = "MozillaWindowClass";
                IntPtr m_hGameWnd = IntPtr.Zero;

                MessageBoxButtons message = MessageBoxButtons.OKCancel;
                DialogResult      dr      = MessageBox.Show("-------------------------请自行登录-------------------------\r\n“手工新增客户”页面加载完毕才可以点击确认,取消则终止!", "提示(请不要改变浏览器窗口大小)", message);
                if (dr == DialogResult.OK)
                {
                    Thread.Sleep(1000);
                    m_hGameWnd = User32API.FindWindow(className, title);
                    if (m_hGameWnd != IntPtr.Zero)
                    {
                        User32API.SwitchToThisWindow(m_hGameWnd, true);
                        Thread.Sleep(500);
                        User32API.MoveWindow(m_hGameWnd, 0, 0, 1300, 700, true);
                    }
                    else
                    {
                        MessageBox.Show("没有检测到“手工新增客户”界面,请重试!", "提示");
                        return;
                    }
                    ClickAndInPut();
                }
                else
                {
                    return;
                }
            }
            else
            {
                MessageBox.Show("没有符合条件的公司,请重新设置筛选日期和关键字!", "提示");
                return;
            }
        }
Esempio n. 4
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");
        }
Esempio n. 5
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);
                }
            }
        }