Esempio n. 1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            var idleTime = IdleTimeFinder.GetIdleTime();

            IdleTextBox.Text      = idleTime.ToString(TimeSpanFormat);
            StartedOnTextBox.Text = (DateTime.Now - Started).ToString(TimeSpanFormat);
        }
Esempio n. 2
0
        private void InterceptKeys_OnKeyDown(object sender, KeyEventArgs e)
        {
            Logger.Info($"Key Pressed : {e.KeyCode} key press after {IdleTimeFinder.GetIdleTime()}");
            if (e.KeyCode == Keys.Escape)
            {
                var senseAdProcessor = this.clixSenseAdProcessor;
                if (senseAdProcessor != null)
                {
                    senseAdProcessor.StopAllProcessing = true;
                    senseAdProcessor.CaptureCatImage   = false;
                }

                var ptcAdProcessor = this.nemoAdProcessor;
                if (ptcAdProcessor != null)
                {
                    ptcAdProcessor.StopAllProcessing = true;
                }
                Logger.Info($"{Resources.FindImageInScreenShot_InterceptKeys_OnKeyDown_Stopping_all_Processing}");
                this.notifyIcon1.Icon            = SystemIcons.Exclamation;
                this.notifyIcon1.BalloonTipTitle = "Stop";
                this.notifyIcon1.BalloonTipText  = Resources.FindImageInScreenShot_InterceptKeys_OnKeyDown_Stopping_all_Processing;
                this.notifyIcon1.BalloonTipIcon  = ToolTipIcon.Warning;
                this.notifyIcon1.ShowBalloonTip(5000);
            }
        }
Esempio n. 3
0
        private void TrackTime()
        {
            if (IsTheTimecardStillCurrent())
            {
                // Track total time
                Timecard.Total = Timecard.Total.Add(TimeSpan.FromSeconds(1));

                // Track overtime
                if (Timecard.Total >= TimeSpan.FromHours(settings.TotalDailyWorkingHours))
                {
                    Timecard.Overtime = Timecard.Overtime.Add(TimeSpan.FromSeconds(1));
                }

                // Track idle time
                TimeSpan timeSpentidle = TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime());
                if (timeSpentidle >= acceptedIdleTime)
                {
                    Timecard.Idle = Timecard.Idle.Add(TimeSpan.FromSeconds(1));
                }

                // Track punch out time
                Timecard.Stop = DateTime.UtcNow;
            }
            else
            {
                startANewDay();
            }
        }
        private void ActivityCheck()
        {
            TimeSpan elapsedTime = TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime());

            if (elapsedTime.TotalMilliseconds < _msTrigger)
            {
                ActivityOccured?.Invoke();
            }
        }
Esempio n. 5
0
        private void CheckUserInput(object sender, EventArgs e)
        {
            TimeSpan ts = TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime());

            if (ts.TotalSeconds > 30)
            {
                Hide();
            }
        }
Esempio n. 6
0
        public static bool IsUsing()
        {
            var idleTime = IdleTimeFinder.GetIdleTime();

            if (idleTime.TotalSeconds > 30)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
        private void InterceptMouse_OnMouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            Logger.Info($"Mouse Button Pressed : {e.Button}");
            if (e.Button == MouseButtons.Left)
            {
                Logger.Info($" Location :  {e.X} ,  {e.Y} clicked after {IdleTimeFinder.GetIdleTime()} minutes");
                if (this.FollowMouse)
                {
                    this.CurrentScreen = Screen.FromPoint(new Point(e.X, e.Y));
                    var splashScreen = new TimedSpalshScreen(this.CurrentScreen.WorkingArea, 0.7, Dispatcher.CurrentDispatcher);
                    splashScreen.ShowSplashScreen("Counting down", 10000);
                    this.FollowMouse = false;
                }

                if (this.addingImageClixSenseFind)
                {
                    this.screenShotsManager.AddToFindImages(e, Settings.Default.ClickSenseFindDir);
                    this.addingImageClixSenseFind = false;
                }

                if (this.addingImageClixSenseClose)
                {
                    this.screenShotsManager.AddToFindImages(e, Settings.Default.ClickSenseCloseDir);
                    this.addingImageClixSenseClose = false;
                }

                if (this.addingImageNemoFind)
                {
                    this.screenShotsManager.AddToFindImages(e, Settings.Default.NemoFindDir);
                    this.addingImageNemoFind = false;
                }

                if (this.addingImageNemoDot)
                {
                    this.screenShotsManager.AddToFindImages(e, Settings.Default.NemoDotDir);
                    this.addingImageNemoDot = false;
                }

                if (this.addingImageNemoClose)
                {
                    this.screenShotsManager.AddToFindImages(e, Settings.Default.NemoCloseDir);
                    this.addingImageNemoClose = false;
                }

                var senseAdProcessor = this.clixSenseAdProcessor;

                if (senseAdProcessor != null)
                {
                    senseAdProcessor?.SaveSenseCatImageToDb(e);
                    senseAdProcessor.CaptureCatImage = false;
                    Logger.Info($" {nameof(senseAdProcessor.CaptureCatImage)} : {senseAdProcessor.CaptureCatImage}");
                }
            }
        }
Esempio n. 8
0
        public static bool IsIdle() //In minutes
        {
            TimeSpan idleTime = TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime());

            TimeSpan timeUntilIdle = TimeSpan.FromMinutes(minutesIdle);

            if (TimeSpan.Compare(idleTime, timeUntilIdle) >= 0)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 9
0
 static void Main()
 {
     MessageBox.Show("AutoSleep starting...");                              // Dialog to show that program is running
     while (true)                                                           // infinite loop to ensure progrma is running despite wakingup from sleep
     {
         if (IdleTimeFinder.GetIdleTime() > 600000)                         // Check if 15 minutes have passed
         {
             Application.SetSuspendState(PowerState.Hibernate, true, true); // Sleep
             MessageBox.Show("AutoSleep starting...");                      // Dialog to show that program is running
         }
         Thread.Sleep(1000);                                                // (Power optimization) Makes the program wait 1 second before refreshing, prevents overconsumption of CPU power
         //takes about 20% of CPU if constantly checking for idle time (while loop)
     }
 }
Esempio n. 10
0
        static void Main()
        {
            // Initialize variabales
            int  sleepTime     = 10 * 60 * 1000; // 10 minutes
            bool displayed     = false;          // for warning/alert message
            long LastInputTime = IdleTimeFinder.GetLastInputTime();
            // DateTime StartupTime = DateTime.Now; // Else would be undefined

            SoundPlayer alertSound = new SoundPlayer(@"C:\Users\Tze Zhao\Desktop\C#\AutoSleep\Google_event_notification_tone.wav"); //Initiate Sound player

            AutoClosingMessageBox.Show("AutoSleep starting", "AutoSleep.exe", 5000);                                                // Dialog to show that program is running

            while (true)                                                                                                            // infinite loop to ensure program is running despite waking up from sleep
            {
                // To display warning message
                if (IdleTimeFinder.GetIdleTime() > sleepTime - 60000) // Check if there is one minute left before shutdown
                {
                    if (displayed)
                    {
                        if (IdleTimeFinder.GetLastInputTime() != LastInputTime) // means that user has interacted with device
                        {
                            LastInputTime = IdleTimeFinder.GetLastInputTime();  // update last interacted time
                            displayed     = false;                              // computer to display again the next time device is going to sleep
                        }
                    }
                    else
                    {
                        alertSound.Play();                                                             // play alert sound
                        AutoClosingMessageBox.Show("Going to sleep in 1 min", "AutoSleep.exe", 30000); // alert user that computer is going to sleep
                        displayed = true;                                                              // computer has displayed
                    }
                }


                // To put PC to sleep

                //&& (StartupTime.AddMinutes(sleepTime / 60000) > DateTime.Now

                if (IdleTimeFinder.GetIdleTime() > sleepTime)                                // Check if 10 minutes have passed since last user interaction //and waking up from sleep
                {
                    Application.SetSuspendState(PowerState.Suspend, true, true);             // Sleep
                    AutoClosingMessageBox.Show("AutoSleep starting", "AutoSleep.exe", 5000); // Dialog to show that program is running after waking up
                    //StartupTime = DateTime.Now;
                }
                Thread.Sleep(1000); // (Power optimization) Makes the program wait 1 second before refreshing, prevents overconsumption of CPU power
                //takes about 20% of CPU if constantly checking for idle time (while loop)
            }
        }
Esempio n. 11
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var idleTime = IdleTimeFinder.GetIdleTime();

            if (idleTime > Settings.Default.IdleTimeInMinutes * 60 * 1000 && Status == ProcessStatus.Running)
            {
                StopCommand.Execute(null);
                if (Status == ProcessStatus.Stopped)
                {
                    var result = MessageBox.Show("The StopScript was executed as ilde time was detected! Do you want to run StartScript?", "Idle time - script executed!", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        StartCommand.Execute(null);
                    }
                }
            }
        }
Esempio n. 12
0
        void idle_Tick(object sender, EventArgs e)
        {
            var idleTime = IdleTimeFinder.GetIdleTime();

            if (idleTime > maxIdleTime)
            {
                ShowOnTop();

                String str          = String.Format("You have been idle for more than {0} minutes.", maxIdleTime / 60000);
                var    timeOnDialog = DateTime.Now.TimeOfDay;
                idleTicker.Stop();
                MessageBox.Show(str, "You have been idle!", MessageBoxButtons.OK);

                var currTime      = DateTime.Now.TimeOfDay;
                var diff          = currTime - timeOnDialog;
                var totalIdleTime = idleTime + diff.TotalMilliseconds;

                String       remStr     = String.Format("Subtract {0} minutes from all running timers?", totalIdleTime / 60000);
                DialogResult timeResult = MessageBox.Show(remStr, "Subtract time?", MessageBoxButtons.YesNo);

                if (timeResult == DialogResult.Yes)
                {
                    // subtract from all running timers
                    foreach (IssueControl issue in this.issueControls)
                    {
                        issue.WatchTimer.SubtractWhenRunning(totalIdleTime);
                        issue.UpdateOutput();
                    }

                    backupTimer.SubtractWhenRunning(totalIdleTime);
                    UpdateBackupTime();
                }

                idleTicker.Start();
            }
        }
Esempio n. 13
0
        public static int GetIdleTime()
        {
            var idleTime = IdleTimeFinder.GetIdleTime();

            return((int)idleTime.TotalSeconds);
        }
Esempio n. 14
0
        public static byte[] idleTime(Command command)
        {
            TimeSpan time = TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime());

            return(Util.Serialization.serialize(time));
        }
Esempio n. 15
0
 public static TimeSpan Do()
 {
     return(IdleTimeFinder.getTimeSpent(IdleTimeFinder.GetIdleTime()));
 }
Esempio n. 16
0
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var timeLeft = AppSettings.Settings.IdleTimeLimit - TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime());

            if (timeLeft.Seconds > 0 && timeLeft.Seconds <= 3)
            {
                Notifier.ShowInformation($"You will be loged out in: { timeLeft.Seconds }!");
            }
            else if (timeLeft.Seconds <= 0)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    Logout();
                });
            }
        }