コード例 #1
0
        // --| Alert and do things according to user settings
        // --| I created this function to avoid code duplication since i am going to use it twice in keyboard press event hook and mouse movement
        public void AlertAndProtect()
        {
            // "Play a sound on detection" is checked so we play our alarm sound file on loop until he clicks "Okay." button on the other warning form
            if (chkBox_Alert.Checked)
            {
                SoundPlayer CustomSound = new SoundPlayer(Properties.Resources.alarm);
                CustomSound.PlayLooping();
            }

            // --| "lock windows on movement detection" is checked so we lock windows
            if (chkBox_Lock.Checked)
            {
                LockWorkStation();
            }

            // --| We stop all our timers and scanners since detection has been made
            ScannerTimer.Stop();
            ScannerTimer.Enabled = false;

            IdleChekTimer.Stop();
            IdleChekTimer.Enabled = false;

            // --| Display our warning form
            Form3 WarningForm = new Form3();

            WarningForm.Show();
        }
コード例 #2
0
        // --| Timer2 think
        // --| If ScannerTimer is not enabled, we enable it, we stop timer2 aswell
        // --| We get the current position of the cursor in X and Y axis
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (ScannerTimer.Enabled != true)
            {
                CursorPositionX = Cursor.Position.X;
                CursorPositionY = Cursor.Position.Y;

                ScannerTimer.Start();
                ScannerTimer.Enabled = true;

                timer2.Stop();
                timer2.Enabled = false;
            }
        }
コード例 #3
0
        // --| User clicked the "Stop Scanner" button
        // --| Now if the scanner is not running at all we throw an error message
        // --| If the scanner has been working but process was stopped by the button, we throw an info message
        // --| We also stop all scanners
        private void button1_Click_1(object sender, EventArgs e)
        {
            // --| If the "Auto-Start if system is idle" is checked, first we stop that
            if (chkBox_Idle.Checked == true)
            {
                chkBox_Idle.Checked = false;

                IdleChekTimer.Stop();
                IdleChekTimer.Enabled = false;

                isScannerDetected = false;

                // --| Disable radar.GIF animation
                pictureBox2_Scanner.Enabled = false;

                MessageBox.Show("Scanner Stopped", "Scanner has ben stopped.", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }

            // --| If there is no scanner running, we throw an information
            if (timer2.Enabled == false)
            {
                MessageBox.Show("Scanner not running", "Scanner is not running!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return;
            }

            // --| We stop the scanners
            ScannerTimer.Stop();
            ScannerTimer.Enabled = false;

            timer2.Stop();
            timer2.Enabled = false;

            isScannerDetected = false;

            // --| Disable radar.GIF animation
            pictureBox2_Scanner.Enabled = false;

            MessageBox.Show("Scanner Stopped", "Scanner has ben stopped.", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #4
0
        // --| Idle timer scanner
        // --| We check if the computer is in idle state
        private void IdleChekTimer_Tick(object sender, EventArgs e)
        {
            // --| If there is no scanner started and checkbox "Auto-Start if system is idle" is ENABLED then we start our scanning time
            if (chkBox_Idle.Checked == true && ScannerTimer.Enabled == false && timer2.Enabled == false)
            {
                // --| Useful stuff to be able to get if system is idling
                tagLASTINPUTINFO LastInput = new tagLASTINPUTINFO();

                Int32  IdleTime;
                double IdleTimeInMinutes;

                LastInput.cbSize = (uint)Marshal.SizeOf(LastInput);
                LastInput.dwTime = 0;

                if (GetLastInputInfo(ref LastInput))
                {
                    // --| Get idle time in milliseconds and convert them to minutes
                    IdleTime          = System.Environment.TickCount - LastInput.dwTime;
                    IdleTimeInMinutes = TimeSpan.FromMilliseconds(IdleTime).TotalMinutes;

                    // --| If system is idle is equal or more minutes that our specified time from combobox "IDLE Control" we enable the scanner
                    // --| We also disable Start Scanner button.
                    if (IdleTimeInMinutes >= IdleInterval)
                    {
                        if (ScannerTimer.Enabled != true)
                        {
                            // --| Get the current cursor position again and start the scanner
                            CursorPositionX = Cursor.Position.X;
                            CursorPositionY = Cursor.Position.Y;

                            ScannerTimer.Start();
                            ScannerTimer.Enabled = true;
                        }
                    }
                }
            }
        }
コード例 #5
0
        // --| User unchecked device "Keyboard"
        // --| If the Scanner or Auto-start on IDLE scanner is active, we disable them since we cannot run a scanner without having what to detect"
        private void chkBox_Keyboard_CheckedChanged(object sender, EventArgs e)
        {
            if (chkBox_Keyboard.Enabled == false || chckBox_Mouse.Checked == false)
            {
                if (ScannerTimer.Enabled == true || timer2.Enabled == true)
                {
                    // --| We stop all our timers and scanners since detection has been made
                    ScannerTimer.Stop();
                    ScannerTimer.Enabled = false;

                    timer2.Stop();
                    timer2.Enabled = false;

                    // --| Disable radar.GIF animation
                    pictureBox2_Scanner.Enabled = false;

                    MessageBox.Show("Scanner stopped, please select at least one device!", "Scanner Stopped", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (IdleChekTimer.Enabled == true)
                {
                    // --| Uncheck our "Auto-Start if system is idle" checkbox
                    chkBox_Idle.Checked = false;

                    // --| Disable radar.GIF animation
                    pictureBox2_Scanner.Enabled = false;

                    IdleChekTimer.Stop();
                    IdleChekTimer.Enabled = false;

                    MessageBox.Show("Scanner stopped, please select at least one device!", "Scanner Stopped", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
        }
コード例 #6
0
        // --| Event for key press from Global Mouse and Keyboard hook
        public void HookKeyDown(object sender, KeyEventArgs e)
        {
            // --| If user presses End KEY while one of the scanners are running, in this way we detect that he knows what key to press
            // --| and we know is the computer admin/owner so we stop the scanners
            if (e.KeyCode == Keys.End)
            {
                if (ScannerTimer.Enabled == true || timer2.Enabled == true)
                {
                    // --| We stop all our timers and scanners since user pressed F2 key so we know he is the owned or the computer
                    ScannerTimer.Stop();
                    ScannerTimer.Enabled = false;

                    timer2.Stop();
                    timer2.Enabled = false;

                    // --| Play a feedback soun so owner knows that program has detected his End shortcut and disabled scanners
                    // --| SOUND TAKEN FOR FREE FROM http://soundjax.com/alarm-1.html
                    SoundPlayer StoppedSound = new SoundPlayer(Properties.Resources.stopped);
                    StoppedSound.Play();
                }

                else if (IdleChekTimer.Enabled == true || chkBox_Idle.Checked == true)
                {
                    // --| Disable idle scanner
                    IdleChekTimer.Stop();
                    IdleChekTimer.Enabled = false;

                    // --| Uncheck "Auto-Start if system is idle" checkbox
                    chkBox_Idle.Checked = false;

                    // --| Re-enable our start scanner button and dropdown list
                    btn_StartScanner.Enabled        = true;
                    comboBox_StartSelection.Enabled = true;

                    // --| Play a feedback soun so owner knows that program has detected his End shortcut and disabled scanners
                    // --| SOUND TAKEN FOR FREE FROM http://soundjax.com/alarm-1.html
                    SoundPlayer StoppedSound = new SoundPlayer(Properties.Resources.stopped);
                    StoppedSound.Play();
                }

                // --| Disable radar.GIF animation
                pictureBox2_Scanner.Enabled = false;

                // --| Disable value for scanner detection
                isScannerDetected = false;

                return;
            }

            // --| If "Keyboard" checkbox is checked then our scanner will detect keypress
            if (chkBox_Keyboard.Checked == true)
            {
                if (ScannerTimer.Enabled == true && timer2.Enabled == false)
                {
                    // --| Our scanner has detected something so we turn it to true value
                    isScannerDetected = true;

                    // --| Do what user selected in settings
                    AlertAndProtect();
                }
            }
        }