Example #1
0
        public string GetRecordingButtonText()
        {
            IntPtr mainWindowHandle = IntPtr.Zero;

            Process[] localAll = Process.GetProcesses();
            foreach (Process p in localAll)
            {
                if (string.Equals(p.ProcessName, "OBS"))
                {
                    mainWindowHandle = p.MainWindowHandle;
                }
            }
            if (mainWindowHandle == IntPtr.Zero)
            {
                throw new Exception("OBS window not found.");
            }

            IntPtr buttonHandle = GetDlgItem(mainWindowHandle, ObsStartStopRecordingButtonId);

            if (buttonHandle == IntPtr.Zero)
            {
                throw new Exception("OBS start/stop button not found.");
            }


            var controlTextGetter = new ControlTextGetter();
            var result            = controlTextGetter.Get(buttonHandle);

            return(result);
        }
Example #2
0
        public void ClickExitButton()
        {
            var mainWindowHandle  = GetMainWindowHandle();
            var buttonHandle      = GetDlgItem(mainWindowHandle, ObsExitButtonId);
            var controlTextGetter = new ControlTextGetter();
            var controlText       = controlTextGetter.Get(buttonHandle);

            if (controlText.Contains("Exit"))
            {
                ClickButton(mainWindowHandle, buttonHandle, ObsExitButtonId);
            }
        }
Example #3
0
        public void StopRecording()
        {
            var mainWindowHandle  = GetMainWindowHandle();
            var buttonHandle      = GetDlgItem(mainWindowHandle, ObsStartStopRecordingButtonId);
            var controlTextGetter = new ControlTextGetter();
            var controlText       = controlTextGetter.Get(buttonHandle);

            if (controlText.Contains("Stop"))
            {
                ClickButton(mainWindowHandle, buttonHandle, ObsStartStopRecordingButtonId);
            }
        }