当前位置: 首页>>代码示例>>C#>>正文


C# PwEntry.GetAutoTypeEnabled方法代码示例

本文整理汇总了C#中PwEntry.GetAutoTypeEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# PwEntry.GetAutoTypeEnabled方法的具体用法?C# PwEntry.GetAutoTypeEnabled怎么用?C# PwEntry.GetAutoTypeEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PwEntry的用法示例。


在下文中一共展示了PwEntry.GetAutoTypeEnabled方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MenuAddEntry

        private static void MenuAddEntry(PwDocument ds, ToolStripMenuItem tsmiContainer,
            PwEntry pe)
        {
            ToolStripMenuItem tsmiEntry = new ToolStripMenuItem();
            string strTitle = pe.Strings.ReadSafe(PwDefs.TitleField);
            string strUser = pe.Strings.ReadSafe(PwDefs.UserNameField);
            string strText = string.Empty;
            if((strTitle.Length > 0) && (strUser.Length > 0))
                strText = strTitle + ": " + strUser;
            else if(strTitle.Length > 0) strText = strTitle;
            else if(strUser.Length > 0) strText = strUser;
            tsmiEntry.Text = strText;
            tsmiEntry.ImageIndex = MenuGetImageIndex(ds, pe.IconId, pe.CustomIconUuid);
            tsmiContainer.DropDownItems.Add(tsmiEntry);

            ToolStripMenuItem tsmi;

            tsmi = new ToolStripMenuItem(KPRes.AutoType);
            tsmi.ImageIndex = (int)PwIcon.Run;
            tsmi.Tag = pe;
            tsmi.Click += OnAutoType;
            tsmi.Enabled = pe.GetAutoTypeEnabled();
            tsmiEntry.DropDownItems.Add(tsmi);

            tsmiEntry.DropDownItems.Add(new ToolStripSeparator());

            tsmi = new ToolStripMenuItem(KPRes.Copy + " " + KPRes.UserName);
            tsmi.ImageIndex = (int)PwIcon.UserKey;
            tsmi.Tag = pe;
            tsmi.Click += OnCopyUserName;
            tsmiEntry.DropDownItems.Add(tsmi);

            tsmi = new ToolStripMenuItem(KPRes.Copy + " " + KPRes.Password);
            tsmi.ImageIndex = (int)PwIcon.Key;
            tsmi.Tag = pe;
            tsmi.Click += OnCopyPassword;
            tsmiEntry.DropDownItems.Add(tsmi);
        }
开发者ID:ashwingj,项目名称:keepass2,代码行数:38,代码来源:EntryMenu.cs

示例2: PerformIntoPreviousWindow

		public static bool PerformIntoPreviousWindow(Form fCurrent, PwEntry pe,
			PwDatabase pdContext, string strSeq)
		{
			if(pe == null) { Debug.Assert(false); return false; }
			if(!pe.GetAutoTypeEnabled()) return false;
			if(!AppPolicy.Try(AppPolicyId.AutoTypeWithoutContext)) return false;

			bool bTopMost = ((fCurrent != null) ? fCurrent.TopMost : false);
			if(bTopMost) fCurrent.TopMost = false;

			try
			{
				if(!NativeMethods.LoseFocus(fCurrent)) { Debug.Assert(false); }

				return PerformIntoCurrentWindow(pe, pdContext, strSeq);
			}
			finally
			{
				if(bTopMost) fCurrent.TopMost = true;
			}
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:21,代码来源:AutoType.cs

示例3: PerformIntoCurrentWindow

		public static bool PerformIntoCurrentWindow(PwEntry pe, PwDatabase pdContext,
			string strSeq)
		{
			if(pe == null) { Debug.Assert(false); return false; }
			if(!pe.GetAutoTypeEnabled()) return false;
			if(!AppPolicy.Try(AppPolicyId.AutoTypeWithoutContext)) return false;

			IntPtr hWnd;
			string strWindow;
			try
			{
				NativeMethods.GetForegroundWindowInfo(out hWnd, out strWindow, true);
			}
			catch(Exception) { hWnd = IntPtr.Zero; strWindow = null; }

			if(!KeePassLib.Native.NativeLib.IsUnix())
			{
				if(strWindow == null) { Debug.Assert(false); return false; }
			}
			else strWindow = string.Empty;

			Thread.Sleep(100);

			if(strSeq == null)
			{
				SequenceQueriesEventArgs evQueries = GetSequencesForWindowBegin(
					hWnd, strWindow);

				List<string> lSeq = GetSequencesForWindow(pe, hWnd, strWindow,
					pdContext, evQueries.EventID);

				GetSequencesForWindowEnd(evQueries);

				if(lSeq.Count == 0) strSeq = pe.GetAutoTypeSequence();
				else strSeq = lSeq[0];
			}

			AutoTypeCtx ctx = new AutoTypeCtx(strSeq, pe, pdContext);
			return AutoType.PerformInternal(ctx, strWindow);
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:40,代码来源:AutoType.cs

示例4: GetSequenceForWindow

        private static string GetSequenceForWindow(PwEntry pwe, string strWindow,
            bool bRequireDefinedWindow)
        {
            Debug.Assert(strWindow != null); if(strWindow == null) return null;
            Debug.Assert(pwe != null); if(pwe == null) return null;

            if(!pwe.GetAutoTypeEnabled()) return null;

            string strSeq = null;
            foreach(KeyValuePair<string, string> kvp in pwe.AutoType.WindowSequencePairs)
            {
                string strWndSpec = kvp.Key;
                if(strWndSpec == null) { Debug.Assert(false); continue; }

                strWndSpec = strWndSpec.Trim();

                if(strWndSpec.Length > 0)
                    strWndSpec = SprEngine.Compile(strWndSpec, false, pwe,
                        null, false, false);

                if(MatchWindows(strWndSpec, strWindow))
                {
                    strSeq = kvp.Value;
                    break;
                }
            }

            if(Program.Config.Integration.AutoTypeMatchByTitle)
            {
                string strTitle = pwe.Strings.ReadSafe(PwDefs.TitleField);
                strTitle = strTitle.Trim();

                if(string.IsNullOrEmpty(strSeq) && (strTitle.Length > 0) &&
                    (strWindow.IndexOf(strTitle, StrUtil.CaseIgnoreCmp) >= 0))
                {
                    strSeq = pwe.AutoType.DefaultSequence;
                    Debug.Assert(strSeq != null);
                }
            }

            if((strSeq == null) && bRequireDefinedWindow) return null;

            if(!string.IsNullOrEmpty(strSeq)) return strSeq;
            return pwe.GetAutoTypeSequence();
        }
开发者ID:elitak,项目名称:keepass,代码行数:45,代码来源:AutoType.cs

示例5: GetSequencesForWindow

		// Multiple calls of this method are wrapped in
		// GetSequencesForWindowBegin and GetSequencesForWindowEnd
		private static List<string> GetSequencesForWindow(PwEntry pwe,
			IntPtr hWnd, string strWindow, PwDatabase pdContext, int iEventID)
		{
			List<string> l = new List<string>();

			if(pwe == null) { Debug.Assert(false); return l; }
			if(strWindow == null) { Debug.Assert(false); return l; }

			if(!pwe.GetAutoTypeEnabled()) return l;

			SprContext sprCtx = new SprContext(pwe, pdContext,
				SprCompileFlags.NonActive);

			RaiseSequenceQueryEvent(AutoType.SequenceQueryPre, iEventID,
				hWnd, strWindow, pwe, pdContext, l);

			// Specifically defined sequences must match before the title,
			// in order to allow selecting the first item as default one
			foreach(AutoTypeAssociation a in pwe.AutoType.Associations)
			{
				string strWndSpec = a.WindowName;
				if(strWndSpec == null) { Debug.Assert(false); continue; }

				strWndSpec = SprEngine.Compile(strWndSpec.Trim(), sprCtx);

				if(MatchWindows(strWndSpec, strWindow))
				{
					string strSeq = a.Sequence;
					if(string.IsNullOrEmpty(strSeq))
						strSeq = pwe.GetAutoTypeSequence();
					AddSequence(l, strSeq);
				}
			}

			RaiseSequenceQueryEvent(AutoType.SequenceQuery, iEventID,
				hWnd, strWindow, pwe, pdContext, l);

			if(Program.Config.Integration.AutoTypeMatchByTitle)
			{
				string strTitle = SprEngine.Compile(pwe.Strings.ReadSafe(
					PwDefs.TitleField).Trim(), sprCtx);
				if((strTitle.Length > 0) && (strWindow.IndexOf(strTitle,
					StrUtil.CaseIgnoreCmp) >= 0))
					AddSequence(l, pwe.GetAutoTypeSequence());
			}

			string strCmpUrl = null; // To cache compiled URL
			if(Program.Config.Integration.AutoTypeMatchByUrlInTitle)
			{
				strCmpUrl = SprEngine.Compile(pwe.Strings.ReadSafe(
					PwDefs.UrlField).Trim(), sprCtx);
				if((strCmpUrl.Length > 0) && (strWindow.IndexOf(strCmpUrl,
					StrUtil.CaseIgnoreCmp) >= 0))
					AddSequence(l, pwe.GetAutoTypeSequence());
			}

			if(Program.Config.Integration.AutoTypeMatchByUrlHostInTitle)
			{
				if(strCmpUrl == null)
					strCmpUrl = SprEngine.Compile(pwe.Strings.ReadSafe(
						PwDefs.UrlField).Trim(), sprCtx);

				string strCleanUrl = StrUtil.RemovePlaceholders(strCmpUrl);
				string strHost = UrlUtil.GetHost(strCleanUrl);

				if(strHost.StartsWith("www.", StrUtil.CaseIgnoreCmp) &&
					(strCleanUrl.StartsWith("http:", StrUtil.CaseIgnoreCmp) ||
					strCleanUrl.StartsWith("https:", StrUtil.CaseIgnoreCmp)))
					strHost = strHost.Substring(4);

				if((strHost.Length > 0) && (strWindow.IndexOf(strHost,
					StrUtil.CaseIgnoreCmp) >= 0))
					AddSequence(l, pwe.GetAutoTypeSequence());
			}

			if(Program.Config.Integration.AutoTypeMatchByTagInTitle)
			{
				foreach(string strTag in pwe.Tags)
				{
					if(string.IsNullOrEmpty(strTag)) { Debug.Assert(false); continue; }

					if(strWindow.IndexOf(strTag, StrUtil.CaseIgnoreCmp) >= 0)
					{
						AddSequence(l, pwe.GetAutoTypeSequence());
						break;
					}
				}
			}

			RaiseSequenceQueryEvent(AutoType.SequenceQueryPost, iEventID,
				hWnd, strWindow, pwe, pdContext, l);

			return l;
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:96,代码来源:AutoType.cs

示例6: Execute

        private static bool Execute(string strSeq, PwEntry pweData)
        {
            Debug.Assert(strSeq != null); if(strSeq == null) return false;
            Debug.Assert(pweData != null); if(pweData == null) return false;

            if(!pweData.GetAutoTypeEnabled()) return false;
            if(!AppPolicy.Try(AppPolicyId.AutoType)) return false;

            if(KeePassLib.Native.NativeLib.IsUnix())
            {
                if(!NativeMethods.TryXDoTool())
                {
                    MessageService.ShowWarning(KPRes.AutoTypeXDoToolRequired,
                        KPRes.PackageInstallHint);
                    return false;
                }
            }

            PwDatabase pwDatabase = null;
            try { pwDatabase = Program.MainForm.PluginHost.Database; }
            catch(Exception) { }

            bool bObfuscate = (pweData.AutoType.ObfuscationOptions !=
                AutoTypeObfuscationOptions.None);
            AutoTypeEventArgs args = new AutoTypeEventArgs(strSeq, bObfuscate, pweData);

            if(AutoType.FilterCompilePre != null) AutoType.FilterCompilePre(null, args);

            args.Sequence = SprEngine.Compile(args.Sequence, true, pweData,
                pwDatabase, true, false);

            string strError = ValidateAutoTypeSequence(args.Sequence);
            if(strError != null)
            {
                MessageService.ShowWarning(strError);
                return false;
            }

            Application.DoEvents();

            if(AutoType.FilterSendPre != null) AutoType.FilterSendPre(null, args);
            if(AutoType.FilterSend != null) AutoType.FilterSend(null, args);

            if(args.Sequence.Length > 0)
            {
                try { SendInputEx.SendKeysWait(args.Sequence, args.SendObfuscated); }
                catch(Exception excpAT)
                {
                    MessageService.ShowWarning(excpAT);
                }
            }

            pweData.Touch(false);
            if(EntryUtil.ExpireTanEntryIfOption(pweData))
                Program.MainForm.RefreshEntriesList();

            // SprEngine.Compile might have modified the database;
            // pd.Modified is set by SprEngine
            Program.MainForm.UpdateUI(false, null, false, null, false, null, false);

            return true;
        }
开发者ID:elitak,项目名称:keepass,代码行数:62,代码来源:AutoType.cs

示例7: QuickAccessForm

        public QuickAccessForm(IPluginHost host, PwEntry entry, Options options, bool tan)
        {
            this.host = host;
            this.entry = entry;
            this.tan = tan;
            this.options = options;

            host.MainWindow.FileClosingPre += MainWindow_FileClosingPre;

            InitializeComponent();

            if (options.location != (int)Options.Locations.Center)
            {
                this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
                Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
                if (options.location == (int)Options.Locations.LowerRight)
                {
                    this.Left = workingArea.Right - this.Width;
                    this.Top = workingArea.Bottom - this.Height;
                }
                else if (options.location == (int)Options.Locations.UpperRight)
                {
                    this.Left = workingArea.Right - this.Width;
                    this.Top = workingArea.Top;
                }
                else if (options.location == (int)Options.Locations.LowerLeft)
                {
                    this.Left = workingArea.Left;
                    this.Top = workingArea.Bottom - this.Height;
                }
                else if (options.location == (int)Options.Locations.UpperLeft)
                {
                    this.Left = workingArea.Left;
                    this.Top = workingArea.Top;
                }
            }

            host.MainWindow.FileClosingPre += MainWindow_FileClosingPre;
            string title = entry.Strings.ReadSafe(PwDefs.TitleField);
            if (title != null) this.Text = title;

            imgList = new ImageList();
            imgList.Images.Add((System.Drawing.Bitmap)host.Resources.GetObject("B16x16_KTouch"));
            imgList.Images.Add((System.Drawing.Bitmap)host.Resources.GetObject("B16x16_Browser"));
            imgList.Images.Add((System.Drawing.Bitmap)host.Resources.GetObject("B16x16_Personal"));
            imgList.Images.Add((System.Drawing.Bitmap)host.Resources.GetObject("B16x16_KGPG_Info"));
            imgList.Images.Add(host.MainWindow.ClientIcons.Images[(int)PwIcon.Notepad]);
            imgList.Images.Add(host.MainWindow.ClientIcons.Images[(int)PwIcon.List]);
            imgList.Images.Add((System.Drawing.Bitmap)host.Resources.GetObject("B16x16_KeePass"));

            this.Icon = host.MainWindow.Icon;
            buttonAutoType.Image = imgList.Images[0];
            buttonUrl.Image = imgList.Images[1];
            buttonCopyUser.Image = tan ? imgList.Images[3] : imgList.Images[2];
            buttonCopyPw.Image = imgList.Images[3];
            buttonCopyNotes.Image = imgList.Images[4];
            buttonCopyFields.Image = imgList.Images[5];
            buttonMainWindow.Image = imgList.Images[6];

            buttonAutoType.Enabled = entry.GetAutoTypeEnabled();
            buttonUrl.Enabled = !entry.Strings.GetSafe(PwDefs.UrlField).IsEmpty;
            buttonCopyUser.Enabled = (!entry.Strings.GetSafe(PwDefs.UserNameField).IsEmpty && !tan) || (!entry.Strings.GetSafe(PwDefs.PasswordField).IsEmpty && tan);
            buttonCopyPw.Enabled = !entry.Strings.GetSafe(PwDefs.PasswordField).IsEmpty && !tan;
            buttonCopyNotes.Enabled = !entry.Strings.GetSafe(PwDefs.NotesField).IsEmpty;
            buttonCopyFields.Enabled = Util.hasFields(entry);

            if (tan) buttonCopyUser.Text = "Copy TAN";
            buttonCopyPw.Visible = !tan;

            this.panel.Select();

            userCopied = !buttonCopyUser.Enabled;
            pwCopied = !buttonCopyPw.Enabled;

            this.Activated += QuickAccessForm_Activated;
            this.Deactivate += QuickAccessForm_Deactivate;
            this.FormClosing += QuickAccessForm_FormClosing;
        }
开发者ID:nein23,项目名称:KeePassContext,代码行数:78,代码来源:QuickAccessForm.cs

示例8: PerformIntoPreviousWindow

		public static bool PerformIntoPreviousWindow(Form fCurrent, PwEntry pe)
		{
			if((pe != null) && !pe.GetAutoTypeEnabled()) return false;

			bool bTopMost = ((fCurrent != null) ? fCurrent.TopMost : false);
			if(bTopMost) fCurrent.TopMost = false;

			try
			{
				if(!NativeMethods.LoseFocus(fCurrent)) { Debug.Assert(false); }

				return PerformIntoCurrentWindow(pe);
			}
			finally
			{
				if(bTopMost) fCurrent.TopMost = true;
			}
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:18,代码来源:AutoType.cs

示例9: GetSequencesForWindow

        private static List<string> GetSequencesForWindow(PwEntry pwe,
            string strWindow, PwDatabase pdContext)
        {
            List<string> l = new List<string>();

            if(pwe == null) { Debug.Assert(false); return l; }
            if(strWindow == null) { Debug.Assert(false); return l; }

            if(!pwe.GetAutoTypeEnabled()) return l;

            // Specifically defined sequences must match before the title,
            // in order to allow selecting the first item as default one
            foreach(AutoTypeAssociation a in pwe.AutoType.Associations)
            {
                string strWndSpec = a.WindowName;
                if(strWndSpec == null) { Debug.Assert(false); continue; }

                strWndSpec = strWndSpec.Trim();

                if(strWndSpec.Length > 0)
                    strWndSpec = SprEngine.Compile(strWndSpec, new SprContext(
                        pwe, pdContext, SprCompileFlags.All));

                if(MatchWindows(strWndSpec, strWindow))
                {
                    string strSeq = a.Sequence;
                    if(string.IsNullOrEmpty(strSeq))
                        strSeq = pwe.GetAutoTypeSequence();
                    AddSequence(l, strSeq);
                }
            }

            if(Program.Config.Integration.AutoTypeMatchByTitle)
            {
                string strTitle = pwe.Strings.ReadSafe(PwDefs.TitleField);
                strTitle = strTitle.Trim();

                if((strTitle.Length > 0) && (strWindow.IndexOf(strTitle,
                    StrUtil.CaseIgnoreCmp) >= 0))
                    AddSequence(l, pwe.GetAutoTypeSequence());
            }

            if(Program.Config.Integration.AutoTypeMatchByUrlInTitle)
            {
                string strUrl = pwe.Strings.ReadSafe(PwDefs.UrlField);
                strUrl = strUrl.Trim();

                if((strUrl.Length > 0) && (strWindow.IndexOf(strUrl,
                    StrUtil.CaseIgnoreCmp) >= 0))
                    AddSequence(l, pwe.GetAutoTypeSequence());
            }

            return l;
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:54,代码来源:AutoType.cs

示例10: PerformIntoCurrentWindow

        public static bool PerformIntoCurrentWindow(PwEntry pe, PwDatabase pdContext)
        {
            if(pe == null) { Debug.Assert(false); return false; }
            if(!pe.GetAutoTypeEnabled()) return false;
            if(!AppPolicy.Try(AppPolicyId.AutoTypeWithoutContext)) return false;

            string strWindow;
            try
            {
                IntPtr hDummy;
                NativeMethods.GetForegroundWindowInfo(out hDummy, out strWindow, true);
            }
            catch(Exception) { strWindow = null; }

            if(!KeePassLib.Native.NativeLib.IsUnix())
            {
                if(strWindow == null) { Debug.Assert(false); return false; }
            }
            else strWindow = string.Empty;

            Thread.Sleep(100);

            List<string> lSeq = GetSequencesForWindow(pe, strWindow, pdContext);
            if(lSeq.Count == 0) lSeq.Add(pe.GetAutoTypeSequence());

            AutoTypeCtx ctx = new AutoTypeCtx(lSeq[0], pe, pdContext);
            return AutoType.PerformInternal(ctx, strWindow);
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:28,代码来源:AutoType.cs


注:本文中的PwEntry.GetAutoTypeEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。