public ToolAddControlPoints()
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "CustomCE";                      //localizable text
            base.m_caption  = "添加控制点";                         //localizable text
            base.m_message  = "添加控制点";                         //localizable text
            base.m_toolTip  = "添加控制点";                         //localizable text
            base.m_name     = "CustomCE.ToolAddControlPoints"; //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
            FrmLinkTableRaster frm = m_FrmLinkTableRaster;

            frm.pRasterLayer            = pRasterLayer;
            frm.TargetPoints            = TargetPoints;
            frm.OriginPoints            = OriginPoints;
            frm.TransformedOriginPoints = TransformedOriginPoints;
            //frm.pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
            //frm.Show();
            frm.Owner =
                System.Windows.Forms.Form.FromChildHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="attr"></param>
        /// <returns>image,displayname,typename</returns>
        public static Tuple <ImageSource, string, string> LoadFileInfoByPath(string path, FileAttributes attr = 0)
        {
            ImageSource icon = null;

            //TT91027 - The folder's icon doesn't display in the content list while restore the backup job which target is FTP.
            //change ftp path '/' to '\' for XP.
            path = path.Replace('/', '\\');
            ShellAPI.SHFILEINFO shellInfo = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGFI      vFlags    =
                ShellAPI.SHGFI.SHGFI_SMALLICON |
                ShellAPI.SHGFI.SHGFI_ICON |
                ShellAPI.SHGFI.SHGFI_USEFILEATTRIBUTES |
                ShellAPI.SHGFI.SHGFI_DISPLAYNAME |
                ShellAPI.SHGFI.SHGFI_TYPENAME;
            ShellAPI.SHGetFileInfo(path, (uint)attr, ref shellInfo, (uint)Marshal.SizeOf(shellInfo), vFlags);
            string displayName = shellInfo.szDisplayName;

            if (shellInfo.hIcon != IntPtr.Zero)
            {
                icon = GetImageSourceFromIcon(shellInfo.hIcon);
                User32API.DestroyIcon(shellInfo.hIcon);
                shellInfo.hIcon = IntPtr.Zero;
            }
            string typeName = shellInfo.szTypeName;

            return(new Tuple <ImageSource, string, string>(icon, displayName, typeName));
        }
        /// <summary>
        /// 鼠标点击
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="option">1:鼠标左键点击,2:鼠标右键点击</param>
        public void MouseClick(int x, int y, int option = 1)
        {
            User32API.SetCursorPos(x, y);//设置鼠标位置(相对于整个桌面);
            Thread.Sleep(100);
            switch (option)
            {
            case 1:
            {
                User32API.MouseEvent(MouseEventType.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
                Thread.Sleep(100);
                User32API.MouseEvent(MouseEventType.MOUSEEVENTF_LEFTUP, x, y, 0, 0);
                Thread.Sleep(100);
                break;
            }

            case 2:
            {
                User32API.MouseEvent(MouseEventType.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0);
                Thread.Sleep(100);
                User32API.MouseEvent(MouseEventType.MOUSEEVENTF_RIGHTUP, x, y, 0, 0);
                Thread.Sleep(100);
                break;
            }

            default:
                break;
            }
            Thread.Sleep(500);
        }
        public static ImageSource LoadDriveIcon(string path)
        {
            if (path == null)
            {
                return(null);
            }
            //TT91027 - The folder's icon doesn't display in the content list while restore the backup job which target is FTP.
            //change ftp path '/' to '\' for XP.
            path = path.Replace('/', '\\');
            ShellAPI.SHFILEINFO shellInfo = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGFI      vFlags    =
                ShellAPI.SHGFI.SHGFI_LARGEICON |
                ShellAPI.SHGFI.SHGFI_ICON |
                ShellAPI.SHGFI.SHGFI_USEFILEATTRIBUTES |
                ShellAPI.SHGFI.SHGFI_DISPLAYNAME;

            ShellAPI.SHGetFileInfo(path, (uint)FileAttributes.Directory, ref shellInfo, (uint)Marshal.SizeOf(shellInfo), vFlags);
            var ico = GetImageSourceFromIcon(shellInfo.hIcon);

            if (shellInfo.hIcon != IntPtr.Zero)
            {
                User32API.DestroyIcon(shellInfo.hIcon);
                shellInfo.hIcon = IntPtr.Zero;
            }
            return(ico);
        }
        /// <summary>
        /// load computer display name and icon
        /// </summary>
        /// <param name="displayName"></param>
        /// <param name="computerIcon"></param>
        public static void LoadComputer(out string displayName, out ImageSource computerIcon)
        {
            try
            {
                IntPtr ptrIDL = IntPtr.Zero;
                var    result = ShellAPI.SHGetSpecialFolderLocation(IntPtr.Zero, ShellAPI.CSIDL.CSIDL_DRIVES, ref ptrIDL);
                if (result != 0)
                {
                    Marshal.ThrowExceptionForHR(result);
                }

                ShellAPI.SHFILEINFO shellInfo = new ShellAPI.SHFILEINFO();
                ShellAPI.SHGFI      vFlags    =
                    ShellAPI.SHGFI.SHGFI_SMALLICON |
                    ShellAPI.SHGFI.SHGFI_ICON |
                    ShellAPI.SHGFI.SHGFI_PIDL |
                    ShellAPI.SHGFI.SHGFI_DISPLAYNAME |
                    ShellAPI.SHGFI.SHGFI_TYPENAME |
                    ShellAPI.SHGFI.SHGFI_ADDOVERLAYS;
                ShellAPI.SHGetFileInfo(ptrIDL, 0, ref shellInfo, (uint)Marshal.SizeOf(shellInfo), vFlags);
                displayName  = shellInfo.szDisplayName;
                computerIcon = GetImageSourceFromIcon(shellInfo.hIcon);
                if (shellInfo.hIcon != IntPtr.Zero)
                {
                    User32API.DestroyIcon(shellInfo.hIcon);
                    shellInfo.hIcon = IntPtr.Zero;
                }
            }
            catch (Exception ex)
            {
                displayName  = string.Empty;
                computerIcon = null;
                LogHelper.Debug("Application Exception:", ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }

            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            if (pMapCtr != null)
            {
                pMap = pMapCtr.Map;
            }
            IPageLayoutControl pLayoutCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IPageLayoutControl;

            if (pLayoutCtr != null)
            {
                pMap = pLayoutCtr.ActiveView.FocusMap;
            }
            frmAddTINNode.Owner =
                System.Windows.Forms.Form.FromChildHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
            // TODO:  Add toolAddTinNode.OnCreate implementation
        }
Exemple #8
0
        public void MouseCliceBackGround(IntPtr hwnd, int x, int y)
        {
            int WM_LBUTTONDOWN = 0x201; //按下
            int WM_LBUTTONUP   = 0x202; //弹起

            System.Drawing.Point point = new System.Drawing.Point(x, y);
            User32API.SendMessageA(hwnd, WM_LBUTTONDOWN, point.X, point.Y);
            User32API.SendMessageA(hwnd, WM_LBUTTONUP, point.X, point.Y);
        }
Exemple #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            IntPtr mainWindowHandle = IntPtr.Zero;

            foreach (Process p in Process.GetProcessesByName("steam-idle"))
            {
                ShowWindowAsync(User32API.GetWindowHandle((uint)p.Id), SW_SHOWDEFAULT);
            }
        }
Exemple #10
0
        public static void RemoveProjectPathToWindowTitle()
        {
            var    handler = User32API.GetCurrentWindowHandle();
            string name    = User32API.GetWindowTitle(handler);

            string path = Directory.GetCurrentDirectory();

            User32API.SetWindowText(handler, name.Replace(" - " + path, ""));
        }
Exemple #11
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);
        }
Exemple #12
0
        public void BuildDriveList()
        {
            base.Items.Clear();

            ShellAPI.SHFILEINFO shInfo    = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGFI      dwAttribs =
                ShellAPI.SHGFI.SHGFI_ICON |
                ShellAPI.SHGFI.SHGFI_SMALLICON |
                ShellAPI.SHGFI.SHGFI_SYSICONINDEX |
                ShellAPI.SHGFI.SHGFI_DISPLAYNAME;

            ListDictionary _iconDict = new ListDictionary();

            foreach (string drive in System.IO.Directory.GetLogicalDrives())
            {
                IntPtr m_pHandle = ShellAPI.SHGetFileInfo(drive, ShellAPI.FILE_ATTRIBUTE_NORMAL, ref shInfo, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shInfo), dwAttribs);

                if (m_pHandle.Equals(IntPtr.Zero) == false)
                {
                    int idxIcon = 0;
                    if (_iconDict.Contains(shInfo.iIcon) == false)
                    {
                        base.ImageList.Images.Add(System.Drawing.Icon.FromHandle(shInfo.hIcon).Clone() as System.Drawing.Icon);

                        User32API.DestroyIcon(shInfo.hIcon);

                        _iconDict.Add(shInfo.iIcon, _iconDict.Count);
                        idxIcon = _iconDict.Count - 1;
                    }
                    else
                    {
                        idxIcon = Convert.ToInt32(_iconDict[shInfo.iIcon]);
                    }

                    try
                    {
                        DriveInfo drv_info = new DriveInfo(shInfo.szDisplayName.Substring(shInfo.szDisplayName.IndexOf("(") + 1, 1));
                        if (drv_info.DriveType == DriveType.CDRom)
                        {
                            ImageComboItem item = new ImageComboItem(shInfo.szDisplayName, idxIcon, false);
                            item.ItemValue = drive;
                            base.Items.Add(item);
                        }
                    }
                    catch
                    {
                    }
                }
            }

            if (base.Items.Count != 0)
            {
                base.SelectedIndex = 0;
            }
        }
Exemple #13
0
        private void HideProcessWindow(int PID)
        {
            IntPtr intptr;

            intptr = User32API.GetWindowHandle(PID);
            ShowWindow(intptr, GlobalVariable.SW_HIDE);
            if (!GlobalVariable.Hid_PID.Contains(PID))
            {
                GlobalVariable.Hid_PID.Add(PID);
            }
        }
Exemple #14
0
        private void ShowProcessWindow(int PID)
        {
            IntPtr intptr;

            intptr = User32API.GetWindowHandle(PID);
            ShowWindow(intptr, GlobalVariable.SW_SHOW);
            if (GlobalVariable.Hid_PID.Contains(PID))
            {
                GlobalVariable.Hid_PID.Remove(PID);
            }
        }
 /// <summary>
 /// 鼠标点击
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="index">点击次数</param>
 public void LeftMouseClick(int x, int y, int index = 1)
 {
     User32API.SetCursorPos(x, y);//设置鼠标位置(相对于整个桌面);
     Thread.Sleep(100);
     for (int i = 0; i < index; i++)
     {
         User32API.MouseEvent(MouseEventType.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
         Thread.Sleep(100);
         User32API.MouseEvent(MouseEventType.MOUSEEVENTF_LEFTUP, x, y, 0, 0);
         Thread.Sleep(100);
     }
 }
Exemple #16
0
        public static void AddProjectPathToWindowTitle()
        {
            var    handler = User32API.GetCurrentWindowHandle();
            string name    = User32API.GetWindowTitle(handler);

            string path = Directory.GetCurrentDirectory();

            if (name.Contains(path))
            {
                return;
            }

            User32API.SetWindowText(handler, name + " - " + path);
        }
        /// <summary>
        /// Load file  icon, file type from shell
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="attributes">The attr.</param>
        public static System.Windows.Media.ImageSource LoadFileInfo(string path, out string typeName)
        {
            FileAttributes attributes;

            if (CommonProvider.Directory.Exists(path))
            {
                attributes = FileAttributes.Directory;
            }
            else if (CommonProvider.File.Exists(path))
            {
                attributes = FileAttributes.Normal;
            }
            else
            {
                typeName = string.Empty;
                return(null);
            }

            typeName = string.Empty;
            if (path == null)
            {
                return(null);
            }
            //TT91027 - The folder's icon doesn't display in the content list while restore the backup job which target is FTP.
            //change ftp path '/' to '\' for XP.
            path = path.Replace('/', '\\');
            ShellAPI.SHFILEINFO shellInfo = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGFI      vFlags    =
                ShellAPI.SHGFI.SHGFI_SMALLICON |
                ShellAPI.SHGFI.SHGFI_ICON |
                ShellAPI.SHGFI.SHGFI_USEFILEATTRIBUTES |
                ShellAPI.SHGFI.SHGFI_TYPENAME;

            ShellAPI.SHGetFileInfo(path, (uint)attributes, ref shellInfo, (uint)Marshal.SizeOf(shellInfo), vFlags);
            var ico = GetImageSourceFromIcon(shellInfo.hIcon);

            //displayName = shellInfo.szDisplayName;
            if (shellInfo.hIcon != IntPtr.Zero)
            {
                User32API.DestroyIcon(shellInfo.hIcon);
                shellInfo.hIcon = IntPtr.Zero;
            }
            typeName = shellInfo.szTypeName;
            if (ico == null && attributes == FileAttributes.Directory)
            {
                ico = DefaultFolderImage;
            }
            return(ico);
        }
Exemple #18
0
        /// <summary>
        /// Creates a new instance of the MouseHook class
        /// </summary>
        public MouseHook()
        {
            // Create an instance of HookProc.
            HookProc MouseHookProcedure = new HookProc(MouseHookProc);

            // setting the hook
            //HookHandle = User32API.SetWindowsHookEx(HookType.WH_MOUSE, MouseHookProcedure, (IntPtr)0, AppDomain.GetCurrentThreadId());
            HookHandle = User32API.SetWindowsHookEx(HookType.WH_MOUSE_LL, MouseHookProcedure, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
            //If SetWindowsHookEx fails.
            if (HookHandle == 0)
            {
                System.Windows.Forms.MessageBox.Show("hook failed");
                //return;
            }
        }
Exemple #19
0
 private void StopProcess()
 {
     try
     {
         try { SendCMD(config["ExitCMD"].ToString()); } catch (Exception) { p.Kill(); }
         try
         {
             if (p.MainWindowHandle != IntPtr.Zero)
             {
                 User32API.ShowWindow(p.MainWindowHandle, User32API.SW_SHOWNA);
             }
         }
         catch (Exception) { }
         //p.StartInfo.RedirectStandardOutput = false;
         //p.StartInfo.RedirectStandardInput = false;
     }
     catch (Exception) { }
 }
Exemple #20
0
 /// <summary>
 /// Load file information, dislpay name, icon, file type from shell
 /// </summary>
 /// <param name="pidl">The pidl.</param>
 void LoadFileInfo(IntPtr pidl)
 {
     ShellAPI.SHFILEINFO shellInfo = new ShellAPI.SHFILEINFO();
     ShellAPI.SHGFI      vFlags    =
         ShellAPI.SHGFI.SHGFI_SMALLICON |
         ShellAPI.SHGFI.SHGFI_ICON |
         ShellAPI.SHGFI.SHGFI_PIDL |
         ShellAPI.SHGFI.SHGFI_DISPLAYNAME |
         ShellAPI.SHGFI.SHGFI_TYPENAME |
         ShellAPI.SHGFI.SHGFI_ADDOVERLAYS;
     ShellAPI.SHGetFileInfo(pidl, 0, ref shellInfo, (uint)Marshal.SizeOf(shellInfo), vFlags);
     DisplayName = shellInfo.szDisplayName;
     if (shellInfo.hIcon != IntPtr.Zero)
     {
         Icon = GetImageSourceFromIcon(shellInfo.hIcon);
         User32API.DestroyIcon(shellInfo.hIcon);
         shellInfo.hIcon = IntPtr.Zero;
     }
     TypeName = shellInfo.szTypeName;
 }
        /// <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;
            }
        }
        /// <summary>
        /// Load file icon
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="attributes">The attr.</param>
        public static ImageSource LoadFileInfo(string path, FileAttributes attributes)
        {
            if (path == null)
            {
                return(null);
            }
            if (attributes == FileAttributes.Normal)
            {
                if (!CommonProvider.File.Exists(path))
                {
                    path = Path.GetFileName(path);
                }
            }

            //TT91027 - The folder's icon doesn't display in the content list while restore the backup job which target is FTP.
            //change ftp path '/' to '\' for XP.
            path = path.Replace('/', '\\');
            ShellAPI.SHFILEINFO shellInfo = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGFI      vFlags    =
                ShellAPI.SHGFI.SHGFI_SMALLICON |
                ShellAPI.SHGFI.SHGFI_ICON |
                ShellAPI.SHGFI.SHGFI_USEFILEATTRIBUTES;

            ShellAPI.SHGetFileInfo(path, (uint)attributes, ref shellInfo, (uint)Marshal.SizeOf(shellInfo), vFlags);
            var ico = GetImageSourceFromIcon(shellInfo.hIcon);

            if (shellInfo.hIcon != IntPtr.Zero)
            {
                User32API.DestroyIcon(shellInfo.hIcon);
                shellInfo.hIcon = IntPtr.Zero;
            }

            if (ico == null && attributes == FileAttributes.Directory)
            {
                ico = DefaultFolderImage;
            }
            return(ico);
        }
Exemple #23
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;

            // TODO:  Add ToolNewDisplacement.OnCreate implementation
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            //m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
            //m_FrmVectorLinkTable.OriginPoints = OriginPoints;
            //m_FrmVectorLinkTable.TargetPoints = TargetPoints;
            m_FrmVectorLinkTable.IMUFeatureList             = m_IMUFeatureList;
            m_FrmVectorLinkTable.CenterlinePointFeatureList = m_CenterlinePointFeatureList;
            m_FrmVectorLinkTable.MapCtr = pMapCtr;
            //m_FrmVectorLinkTable.refreshLayer += new RefreshEvent(RefreshLayer);

            if (m_FrmVectorLinkTable != null)
            {
                m_FrmVectorLinkTable.Owner =
                    System.Windows.Forms.Form.FromChildHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
            }

            IExtensionManager extensionManager = ((IHookHelper2)m_hookHelper).ExtensionManager;
            UID guid = new UIDClass();

            guid.Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"; //Snapping extension.
            IExtension extension = extensionManager.FindExtension(guid);

            m_SnappingEnvironment = extension as ISnappingEnvironment;

            m_snappingFeed = new SnappingFeedbackClass();
            m_snappingFeed.Initialize(hook, m_SnappingEnvironment, true);
        }
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ToolEditFeatures.OnClick implementation
            ISceneControl pSceneCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as ISceneControl;
            IMapControl2  pMapCtr   = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            // FrmEdit3DFeatures FrmEditFeatures = new FrmEdit3DFeatures();
            if (FrmEditFeatures == null)
            {
                FrmEditFeatures = new FrmEdit3DFeatures();
            }
            if (FrmEditFeatures.IsDisposed == true)
            {
                FrmEditFeatures = new FrmEdit3DFeatures();
            }
            FrmEditFeatures.psecontrol  = ((ArrayList)m_controls)[1];
            FrmEditFeatures.pmapcontrol = ((ArrayList)m_controls)[0];
            FrmEditFeatures.pTinLayer   = pTinLayer;
            FrmEditFeatures.m_SceneCtrl = pSceneCtr;
            FrmEditFeatures.m_MapCtrl   = pMapCtr;
            FrmEditFeatures.Show();
            FrmEditFeatures.Owner =
                System.Windows.Forms.Form.FromHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
        }
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;

            // TODO:  Add ToolNewDisplacement.OnCreate implementation
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            //m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
            m_FrmVectorLinkTable.OriginPoints = OriginPoints;
            m_FrmVectorLinkTable.TargetPoints = TargetPoints;
            m_FrmVectorLinkTable.MapCtr       = pMapCtr;
            //m_FrmVectorLinkTable.refreshLayer += new RefreshEvent(RefreshLayer);

            if (m_FrmVectorLinkTable != null)
            {
                m_FrmVectorLinkTable.Owner =
                    System.Windows.Forms.Form.FromChildHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
            }
        }
        /// <summary>
        /// 模拟点击输入保存
        /// </summary>
        public void ClickAndInPut()
        {
            if (detailsList.Count > 0)
            {
                int timesYzm = 0;

                #region   需要变动的三个值
                MouseClick(325, 175);//来源
                MouseClick(280, 240);

                MouseClick(410, 210);//申请人
                SendKeys.SendWait("坤");
                Thread.Sleep(500);

                MouseClick(690, 210);//电话
                SendKeys.SendWait("020");
                Thread.Sleep(500);

                MouseClick(780, 210);
                SendKeys.SendWait("83748494");
                Thread.Sleep(500);
                #endregion
                for (int i = 0; i < detailsList.Count; i++)
                {
                    LeftMouseClick(410, 138, 2);//公司
                    User32API.Keybd_event(VirtualKey.BACK, 0, KeyEvent.KEYEVENTF_EXTENDEDKEY, 0);
                    SendKeys.SendWait(detailsList[i]);

                    //SendKeys.SendWait("{BACKSPACE}");

                    while (GetPixs())//判断是否有验证码,存在则调用验证码识别接口,并点击输入
                    {
                        if (timesYzm >= 2)
                        {
                            MessageBox.Show("验证码已经输错两次,为确保不被封号,请自行输入正确验证码后点击确认!", "警告");
                            Thread.Sleep(1000 * 2);
                            break;
                        }
                        string yzmPath = basePath + "yzm.png";
                        Bitmap bitmap  = new Bitmap(yzmPath);
                        string yzm     = yzmDistinguish(bitmap);
                        LeftMouseClick(435, 610, 2);//验证码
                        User32API.Keybd_event(VirtualKey.BACK, 0, KeyEvent.KEYEVENTF_EXTENDEDKEY, 0);
                        SendKeys.SendWait(yzm);
                        MouseClick(348, 596);//保存
                        if (GetPixs())
                        {
                            timesYzm++;
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                    MouseClick(348, 596);//保存
                    Thread.Sleep(1000);
                    MouseClick(668, 340);
                }
            }
            KillProcess("firefox");
        }
 void HideWindow_Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (!GlobalVariable.Authorized)
     {
         return;                             //授权验证
     }
     Invoke((EventHandler) delegate
     {
         Addlog("开始隐藏所有窗口……", Color.Brown, true);
     });
     for (int i = 0; i < GlobalVariable.PathAmount; i++)
     {
         if (enableData[i])
         {
             if (hideData[i])
             {
                 if (PID[i] != 0)
                 {
                     IntPtr intptr;
                     intptr = User32API.GetWindowHandle(PID[i]);
                     ShowWindow(intptr, GlobalVariable.SW_HIDE);
                     GlobalVariable.Hid_PID.Add(PID[i]);
                     Invoke((EventHandler) delegate
                     {
                         Addlog("程序[" + (i + 1) + "]隐藏完成,进程ID为:" + PID[i] + "!", Color.Green);
                     });
                 }
                 else
                 {
                     Invoke((EventHandler) delegate
                     {
                         Addlog("程序[" + (i + 1) + "]启动异常,无法隐藏!", Color.Red, true);
                     });
                 }
             }
             else
             {
                 Invoke((EventHandler) delegate
                 {
                     Addlog("程序[" + (i + 1) + "]被用户设定为不需要隐藏,跳过.", Color.YellowGreen);
                 });
             }
         }
         else
         {
             Invoke((EventHandler) delegate
             {
                 Addlog("程序[" + (i + 1) + "]被用户禁用,跳过.", Color.YellowGreen);
             });
         }
     }
     HideWindow_Timer.Enabled = false;
     if (GlobalVariable.EnableAutoExit)
     {
         GlobalVariable.ShutdownCountdown = GlobalVariable.Default_ShutdownCountdown;
         Invoke((EventHandler) delegate
         {
             UpdateCountDown();
             Addlog("全部窗口隐藏完成,将在" + GlobalVariable.Default_ShutdownCountdown + "秒后退出软件!", Color.Green, true);
         });
         Shutdown_Timer.Enabled = true;
     }
     else
     {
         Invoke((EventHandler) delegate
         {
             Addlog("全部窗口隐藏完成,无需执行其他操作!", Color.Brown, true);
             StartButton.Enabled = true;
         });
     }
 }
Exemple #28
0
        private void StartProcess()
        {
            if (p != null)
            {
                try
                {
                    p.Kill();
                    p.Dispose();
                }
                catch (Exception)
                { }
            }
            p = new Process();
            string path = Regex.Replace(config.Value <string>("basicFilePath"), @"^~\\?", string.IsNullOrEmpty(SlnPath) ? "" : (Path.GetDirectoryName(SlnPath) + "\\"));

            p.StartInfo.FileName               = path;
            p.StartInfo.WorkingDirectory       = Path.GetDirectoryName(p.StartInfo.FileName);
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardInput  = true;
            p.StartInfo.RedirectStandardError  = true;
            if (config.ContainsKey("showWindow"))
            {
                if (!config.Value <bool>("showWindow"))
                {
#if DEBUG
                    p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
#else
                    p.StartInfo.CreateNoWindow = true;
#endif
                }
            }
            p.EnableRaisingEvents = true;
            var encoding = GetEncoding(config.Value <string>("OutPutEncoding"));
            p.StartInfo.StandardOutputEncoding = encoding;
            p.StartInfo.StandardErrorEncoding  = encoding;
            WriteLine("当前编码:" + p.StartInfo.StandardOutputEncoding);
            p.Start();
            p.BeginErrorReadLine();
            p.ErrorDataReceived += (_s, _e) => WriteLine(_e.Data);
            p.BeginOutputReadLine();
            p.OutputDataReceived += (_s, _e) => OnConsoleReadLine(_e.Data);
            p.Exited             += (_s, _e) =>
            {
                WriteLine("---Main Process Exited---");
            };
            try
            {
                Task.Run(() =>
                {
                    for (int i = 0; i < 2000; i++)
                    {
                        Thread.Sleep(10);
                        if (p.MainWindowHandle != IntPtr.Zero)
                        {
                            User32API.ShowWindow(p.MainWindowHandle, User32API.SW_HIDE);
                            break;
                        }
                        if (p.HasExited)
                        {
                            break;
                        }
                    }
                    //WriteLine(p.HandleCount);
                    //WriteLine(p.MainWindowHandle);
                    User32API.ShowWindow(p.Handle, User32API.SW_MINIMIZE);
                    //User32API.ShowWindow(User32API.GetPWindowHandle(p.Id), User32API.SW_MINIMIZE);
                });
            }
            catch (Exception) { }
        }
Exemple #29
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");
        }
Exemple #30
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);
                }
            }
        }