From e8716f8529bfce0fcd25298822e93583728f9610 Mon Sep 17 00:00:00 2001 From: Lakshya Kapoor <4314581+kapoorlakshya@users.noreply.github.com> Date: Sat, 20 Jul 2024 23:30:29 -0700 Subject: [PATCH] wip: window recording --- lib/screen-recorder/options.rb | 4 ++-- lib/screen-recorder/window.rb | 7 ++++--- spec/screen-recorder/window_spec.rb | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/screen-recorder/options.rb b/lib/screen-recorder/options.rb index 495f8c6..92a3787 100644 --- a/lib/screen-recorder/options.rb +++ b/lib/screen-recorder/options.rb @@ -67,9 +67,9 @@ def log # ready for the ffmpeg process to use # def parsed - vals = "-f #{capture_device} " + vals = "-f #{capture_device}" vals << parse_advanced(advanced_input) - vals << "-i #{input} " unless advanced_input[:i] # Input provided by user + vals << "-i #{input}" unless advanced_input[:i] # Input provided by user vals << parse_advanced(advanced) vals << parse_advanced(advanced_output) vals << output diff --git a/lib/screen-recorder/window.rb b/lib/screen-recorder/window.rb index 2c4e452..6b9fbfa 100644 --- a/lib/screen-recorder/window.rb +++ b/lib/screen-recorder/window.rb @@ -10,7 +10,8 @@ class Window < Common def initialize(title:, output:, advanced: {}) raise 'Window recording is only supported on Microsoft Windows.' unless OS.windows? - super(input: "title=#{title}", output: output, advanced: advanced) + # %("title=#{title}") + super(input: %(title="#{title}"), output: output, advanced: advanced) end class << self @@ -39,8 +40,8 @@ def window_title_for(process_name) raise NotImplementedError, 'Only Microsoft Windows (gdigrab) supports window capture.' unless OS.windows? output = `tasklist /v /fi "imagename eq #{process_name}.exe" /fo list | findstr Window` - encode = output.encode('iso-8859-1').force_encoding('utf-8') - titles = encode + output = output.encode('iso-8859-1').force_encoding('utf-8') unless output.valid_encoding? + titles = output .split("\n") .map { |i| i.gsub(FILTERED_TITLES, '') } .reject(&:empty?) diff --git a/spec/screen-recorder/window_spec.rb b/spec/screen-recorder/window_spec.rb index 2a1213a..e643257 100644 --- a/spec/screen-recorder/window_spec.rb +++ b/spec/screen-recorder/window_spec.rb @@ -15,7 +15,7 @@ end before do - browser.goto 'watir.com' + browser.goto 'google.com' browser.wait end @@ -27,10 +27,10 @@ recorder.stop aggregate_failures do - expect(recorder.options.all[:input]).to include('Watir Project') + expect(recorder.options.all[:input]).to include('Google') expect(File).to exist(recorder.options.output) expect(recorder.video.valid?).to be(true) end end end -end \ No newline at end of file +end