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


C# PwEntry.GetAutoTypeSequence方法代码示例

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


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

示例1: 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

示例2: 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

示例3: ConvertAutoTypeSeqExp

		private static string ConvertAutoTypeSeqExp(string strSeq, PwEntry pe)
		{
			string strExp = strSeq;
			if(string.IsNullOrEmpty(strExp)) strExp = pe.GetAutoTypeSequence();

			return ConvertAutoTypeSequence(strExp, false);
		}
开发者ID:kusuriya,项目名称:PasswordKeeper,代码行数:7,代码来源:KdbFile.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

        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

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