Пример #1
0
        private void LogVolume(WaveInEventArgs e)
        {
            float volume = 0;

            // interpret as 16 bit audio
            for (int index = 0; index < e.BytesRecorded; index += 2)
            {
                short sample = (short)((e.Buffer[index + 1] << 8) |
                                       e.Buffer[index + 0]);
                // to floating point
                var sample32 = sample / 32768f;
                // absolute value
                if (sample32 < 0)
                {
                    sample32 = -sample32;
                }
                // is this the max value?
                if (sample32 > volume)
                {
                    volume = sample32;
                }
            }

            volume = (float)Math.Round(volume, 3);

            _audioVolumeWriter.WriteLine("{0} {1}", TrackzamTimer.GetTimestampString(), volume);
        }
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (IsLogging)
     {
         String newLogString = TrackzamTimer.GetTimestampString() + " " + GetActiveWindowTitle();
         AddLogItem(newLogString);
     }
 }
Пример #3
0
        private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                string         typeMsg    = "";

                switch ((MouseMessages)wParam)
                {
                case MouseMessages.WM_LBUTTONDOWN:     // left mouse click is down
                    typeMsg = "Left Click";
                    break;

                case MouseMessages.WM_RBUTTONDOWN:     // right mouse click is down
                    typeMsg = "Right Click";
                    break;

                case MouseMessages.WM_MOUSEWHEEL:     // mouse wheel is being used
                    typeMsg = "Wheel";
                    break;

                case MouseMessages.WM_MOUSEMOVE:     // mouse is moving
                    typeMsg = "Moving";
                    break;
                }
                if (typeMsg == "Moving")
                {
                    if (lastMousePos.x < 0)
                    {
                        lastMousePos = hookStruct.pt;
                    }

                    if (dist(lastMousePos, hookStruct.pt) < throttle * throttle)
                    {
                        return(CallNextHookEx(_hookID, nCode, wParam, lParam));
                    }
                    else
                    {
                        lastMousePos = hookStruct.pt;
                    }
                }
                if (!String.IsNullOrEmpty(typeMsg))
                {
                    _writer.WriteLine("{0} {1},{2} {3}", TrackzamTimer.GetTimestampString(), typeMsg, hookStruct.pt.x, hookStruct.pt.y);
                }
            }

            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        }
Пример #4
0
        /// <summary>
        ///  Starts new recording session:
        ///  Creates a dedicated directory for a new session
        ///  Starts all recording modules
        ///  Shows an error windows in case of exception with the message of that exception
        /// </summary>
        public void StartNewSession()
        {
            try
            {
                if (!Directory.Exists(ConfigManager.StorageDirectory + "/Trackzam"))
                {
                    Directory.CreateDirectory(ConfigManager.StorageDirectory + "/Trackzam");
                }
                _sessionFolderPath = Directory.CreateDirectory(ConfigManager.StorageDirectory + "/Trackzam/" + TrackzamTimer.GetNowString()).FullName;

                _audioRecorder.StartRecord(_sessionFolderPath);
                _keylogger.Start(_sessionFolderPath);
                _mouseLogger.Start(_sessionFolderPath);
                _windowLogger.StartLogging(_sessionFolderPath);
                _videoRecorder.StartRecording(_sessionFolderPath);
                IsSessionInProgress = true;
                _startTime          = TrackzamTimer.GetTimestampString();
            }
            catch (Exception e)
            {
                UIManager.ShowMessage(e.Message);
            }
        }