• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LASTINPUTINFO类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LASTINPUTINFO的典型用法代码示例。如果您正苦于以下问题:C# LASTINPUTINFO类的具体用法?C# LASTINPUTINFO怎么用?C# LASTINPUTINFO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LASTINPUTINFO类属于命名空间,在下文中一共展示了LASTINPUTINFO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetLastInputTime

 public static DateTime GetLastInputTime()
 {
     var lastInputInfo = new LASTINPUTINFO();
     lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
     GetLastInputInfo(ref lastInputInfo);
     return DateTime.Now.AddMilliseconds(-(Environment.TickCount - lastInputInfo.dwTime));
 }
开发者ID:substans,项目名称:WindowTracking,代码行数:7,代码来源:InputInformation.cs


示例2: GetLastInputInfo

 public static extern bool GetLastInputInfo(ref LASTINPUTINFO lpii);
开发者ID:pvginkel,项目名称:SystemEx,代码行数:1,代码来源:NativeMethods.Methods.cs


示例3: getIdleTick

 public long getIdleTick()
 {
     LASTINPUTINFO vLastInputInfo = new LASTINPUTINFO();
     vLastInputInfo.cbSize = Marshal.SizeOf(vLastInputInfo);
     if (!GetLastInputInfo(ref    vLastInputInfo)) return 0;
     return Environment.TickCount - (long)vLastInputInfo.dwTime;
 }
开发者ID:yadewe,项目名称:YDW,代码行数:7,代码来源:UserOpration.cs


示例4: Scheduler

        /// <summary>
        /// This method is responsible for monitoring system resource and user activity with the computer
        /// And periodically changes the shared variable 'crawlerState'
        /// </summary>
        public void Scheduler()
        {
            PerformanceCounter pc = new PerformanceCounter("Processor", "% Idle Time", "_Total", true);

            LASTINPUTINFO info = new LASTINPUTINFO();
            info.cbSize = Marshal.SizeOf(typeof(LASTINPUTINFO));
            while (GlobalData.RunScheduler)
            {
                if (GetLastInputInfo(ref info))
                {
                    if ((Environment.TickCount - info.dwTime) / 1000 > 5 && (int)pc.NextValue() > 40)
                    {
                        crawlerState = CrawlerState.Run;
                    }
                    else
                    {
                        crawlerState = CrawlerState.Stop;
                        if ((Environment.TickCount - info.dwTime) / 1000 <= 5)
                            GlobalData.lIndexingStatus.Text = string.Format("Indexing is paused and will be resumed in {0} sec of computer inactivity [ CPU Idle : {1:F2}% ]", 5 - (Environment.TickCount - info.dwTime) / 1000, pc.NextValue());
                    }
                }
                Thread.Sleep(1000);
            }
            pc.Close();
        }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:29,代码来源:FileSystemCrawler.cs


示例5: GetIdleTick

 /// <summary>
 /// 取得当前时间与上次输入时间的差
 /// </summary>
 /// <returns>返回单位 毫秒</returns>
 public static long GetIdleTick()
 {
     LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
     lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
     if (!GetLastInputInfo(ref lastInputInfo)) return 0;
     return Environment.TickCount - (long)lastInputInfo.dwTime;
 } 
开发者ID:peisheng,项目名称:EASYFRAMEWORK,代码行数:11,代码来源:WindowsUtil.cs


示例6: CalculateIdleTime

        public static TimeSpan CalculateIdleTime() {
            if (Environment.OSVersion.Platform == PlatformID.Unix) {
				if (haveXprintIdle)
				{
					var ret = ZkData.Utils.ExecuteConsoleCommand("xprintidle");
                	if (ret != null) {
                    	int ms;
                    	if (int.TryParse(ret, out ms)) return TimeSpan.FromMilliseconds(ms);
					}else{ haveXprintIdle = false;} //some Linux might not have "xprintidle", stop trying, avoid spam in Diagnostic Log.
				}
				return DateTime.Now - Program.ToolTip.LastUserAction;
            }

            var systemUptime = Environment.TickCount; // Get the system uptime
            var idleTicks = 0; // The number of ticks that passed since last input

            var lastInputInfo = new LASTINPUTINFO();
            lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            // If we have a value from the function
            if (GetLastInputInfo(ref lastInputInfo)) {
                var lastInputTicks = (int)lastInputInfo.dwTime; // Get the number of ticks at the point when the last activity was seen
                idleTicks = systemUptime - lastInputTicks; // Number of idle ticks = system uptime ticks - number of ticks at last input
            }

            return TimeSpan.FromMilliseconds(idleTicks);
        }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:28,代码来源:WindowsApi.cs


示例7: GetIdleTime

 /// <summary>
 /// Get the lapse time between user input (mouse or keyboard) system-wide.
 /// </summary>
 /// <returns>Lapse time in seconds.</returns>
 public static double GetIdleTime()
 {
     LASTINPUTINFO lii = new LASTINPUTINFO();
     lii.cbSize = Marshal.SizeOf(lii.GetType());
     if (!GetLastInputInfo(ref lii))
         throw new ApplicationException("Error executing GetLastInputInfo");
     return (Environment.TickCount - lii.dwTime) / 1000.0;
 }
开发者ID:krbysn,项目名称:jabber-net,代码行数:12,代码来源:IdleTime.cs


示例8: GetIdle

 // note MM: http://msdn.microsoft.com/en-us/library/system.environment.tickcount.aspx
 // GetLastInputInfo info also goes round this way(although i couldn't find proof on the web)
 // but there's a risk of Overflow exception, so i cast them to long to avoid it
 // nevertheless, i'm not sure how this code will work after machine working for more than 50 days.
 // it depends whether GetLastInputInfo is synchronized with TickCount(behaves same way)
 public static uint GetIdle()
 {
     LASTINPUTINFO structure = new LASTINPUTINFO();
     structure.cbSize = Convert.ToUInt32(Marshal.SizeOf(structure));
     GetLastInputInfo(ref structure);
     // to exclude Overflow exception
     return Convert.ToUInt32((long)Environment.TickCount - (long)structure.dwTime);
 }
开发者ID:MarkiyanMatsekh,项目名称:WorkHelp,代码行数:13,代码来源:Win32Wrapper.cs


示例9: GetIdleTime

        public uint GetIdleTime()
        {
            LASTINPUTINFO lastInPut = new LASTINPUTINFO();
            lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut);
            GetLastInputInfo(ref lastInPut);

            return ((uint)Environment.TickCount - lastInPut.dwTime);
        }
开发者ID:burnssun,项目名称:BzAB,代码行数:8,代码来源:AutoBackupModel.cs


示例10: Ticks

 internal int Ticks()
 {
     var uptime = Environment.TickCount;
     var lastInput = new LASTINPUTINFO();
     lastInput.cbSize = Marshal.SizeOf(lastInput);
     var idleTicks = 0;
     if (GetLastInputInfo(ref lastInput))
         idleTicks = uptime - (int)lastInput.dwTime;
     return idleTicks;
 }
开发者ID:jb3622,项目名称:Jalapeno,代码行数:10,代码来源:IdleTime.cs


示例11: GetLastInput

        public static TimeSpan GetLastInput()
        {
            var plii = new LASTINPUTINFO();
            plii.cbSize = (uint)Marshal.SizeOf(plii);

            if (GetLastInputInfo(ref plii))
                return TimeSpan.FromMilliseconds(Environment.TickCount - plii.dwTime);
            else
                throw new Win32Exception(Marshal.GetLastWin32Error());
        }
开发者ID:ssnake,项目名称:utuner,代码行数:10,代码来源:win32.cs


示例12: GetLastInputTime

        /// <summary>
        /// Gets the last time an input has been received from user
        /// </summary>
        /// <returns></returns>
        private static long GetLastInputTime()
        {
            LASTINPUTINFO lastInPut = new LASTINPUTINFO();
            lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut);
            if (!GetLastInputInfo(ref lastInPut))
            {
                throw new Exception(GetLastError().ToString());
            }

            return lastInPut.dwTime;
        }
开发者ID:mohanaravind,项目名称:ProjectSeniorCenter,代码行数:15,代码来源:Win32.cs


示例13: GetLastInputTime

        public static long GetLastInputTime()
        {
            LASTINPUTINFO lastInPut = new LASTINPUTINFO();
            lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);

            if (!GetLastInputInfo(ref lastInPut))
            {
                throw new Exception(GetLastError().ToString());
            }

            return lastInPut.dwTime;
        }
开发者ID:triffids,项目名称:Hibernator,代码行数:12,代码来源:EnvironmentInfo.cs


示例14: GetIdleTime

        public static uint GetIdleTime()
        {
            LASTINPUTINFO lastInPut = new LASTINPUTINFO();
            lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut);
            GetLastInputInfo(ref lastInPut);

            //TimeSpan t = TimeSpan.FromMilliseconds(millisecond);
            //format(t);
            //var s = TimeSpan.FromMilliseconds(lastInPut.dwTime);
            //format(s);

            return ((uint)Environment.TickCount - lastInPut.dwTime);
              //  return ((uint)millisecond - lastInPut.dwTime);
        }
开发者ID:triffids,项目名称:Hibernator,代码行数:14,代码来源:EnvironmentInfo.cs


示例15: GetIdleTime

        public static TimeSpan GetIdleTime()
        {
            TimeSpan idleTime = TimeSpan.FromMilliseconds(0);

            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
            lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            if (GetLastInputInfo(ref lastInputInfo))
            {
                idleTime = TimeSpan.FromMilliseconds(GetTickCount() - (lastInputInfo.dwTime & uint.MaxValue));
            }

            return idleTime;
        }
开发者ID:modenl,项目名称:CoStart,代码行数:15,代码来源:IdleDetector.cs


示例16: GetLastInputTime

        static int GetLastInputTime()
        {
            int idleTime = 0;
            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
            lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            int envTicks = Environment.TickCount;

            if (GetLastInputInfo(ref lastInputInfo)){
                int lastInputTick = (int) lastInputInfo.dwTime;

                idleTime = envTicks - lastInputTick;
            }

            return ((idleTime > 0) ? (idleTime/1000) : idleTime);
        }
开发者ID:GorelH,项目名称:Scheduler,代码行数:17,代码来源:WarningSys.cs


示例17: UserActivityTimer

        /// <summary>
        /// Constructs a new timer to track the idle/activity status of the user
        /// </summary>
        /// <param name="idleThreshold">Number of milliseconds of inactivity until user is considered idle</param>
        /// <param name="active">Whether or not the timer should be created in an active state</param>
        public UserActivityTimer(long idleThreshold, bool active)
        {
            this._idleThreshold = idleThreshold;

            // Initialize system call
            this.lastInput = new LASTINPUTINFO();
            this.lastInput.cbSize = (uint)Marshal.SizeOf(this.lastInput);

            // Read initial value
            GetLastInputInfo(ref this.lastInput);
            this._lastActivity = this.lastInput.dwTime;

            // Create underlying timer
            this.activityCheckerTimer = new Timer(new TimerCallback(this.GetLastInput), null, Timeout.Infinite, 1000);
            this._lastResetTime = DateTime.Now;
            this.Enabled = active;
        }
开发者ID:MercurialForge,项目名称:Mastery,代码行数:22,代码来源:UserActivityTimer.cs


示例18: GetIdleTime

        /// <summary>
        /// Gets the user idle time in milisseconds
        /// http://dataerror.blogspot.com.br/2005/02/detect-windows-idle-time.html
        /// </summary>
        /// <returns></returns>
        public static long GetIdleTime()
        {
            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
            lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            int envTicks = Environment.TickCount;

            if (GetLastInputInfo(out lastInputInfo))
            {
                int lastInputTick = lastInputInfo.dwTime;
                return envTicks - lastInputTick;
            }
            else
            {
                return 0;
            }
        }
开发者ID:guitcastro,项目名称:lime,代码行数:23,代码来源:WindowsUtils.cs


示例19: GetLastInputTime

        public static int GetLastInputTime()
        {
            int idleTime = 0;
            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
            lastInputInfo.cbSize = (UInt32)System.Runtime.InteropServices.Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            int envTicks = Environment.TickCount;

            if (GetLastInputInfo(ref lastInputInfo))
            {
                int lastInputTick = (Int32)lastInputInfo.dwTime;

                idleTime = envTicks - lastInputTick;
            }

            return ((idleTime > 0) ? (idleTime / 1000) : 0);
        }
开发者ID:DeadHipo,项目名称:Photo-Lock,代码行数:18,代码来源:InputTime.cs


示例20: GetLastInputTime

        public static int GetLastInputTime()
        {
            uint idleTime = 0;
            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
            lastInputInfo.cbSize = (UInt32)Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            uint envTicks = (uint)Environment.TickCount;

            if (GetLastInputInfo(ref lastInputInfo))
            {
                uint lastInputTick = lastInputInfo.dwTime;

                idleTime = envTicks - lastInputTick;
            }

            return (int)((idleTime > 0) ? (idleTime / 1000) : 0);
        }
开发者ID:RichardSlater,项目名称:CudaManager,代码行数:18,代码来源:SysDetect.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LColor类代码示例发布时间:2022-05-24
下一篇:
C# KryptonRibbon类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap