screenshots/take_shots.rb
def find_app
    terminal = SBApplication.applicationWithBundleIdentifier("com.apple.Terminal")
    terminal.windows.each do |window|
      title = window.name
      id = window.id
      encoding_options = 
      {
        :invalid           => :replace,
        :undef             => :replace,
        :replace           => '',
        :universal_newline => true
      }
      title = title.encode(Encoding.find('ASCII'),encoding_options)
      if title =~ /samples\s+mrdialog - (.+)\s+dialog.*$/i
        @app_name =  $1
        @app_name = @app_name.gsub(/\s/,'')
        @window_id = id
        return true
        break
      end
    end
    return false
  end
#------------------------------------------------- 
# check if any mrdialog app is running, if so
# populate @window_id and @app_name. They will be
# used to capture the window.
#------------------------------------------------- 
check if any mrdialog app is running, if so
populate @window_id and @app_name. They will be
used to capture the window.
check if any mrdialog app is running if so populate @window_id and @app_name . They will be used to capture the window .
def find_app
    terminal = SBApplication.applicationWithBundleIdentifier("com.apple.Terminal")
    terminal.windows.each do |window|
      title = window.name
      id = window.id
      encoding_options = 
      {
        :invalid           => :replace,
        :undef             => :replace,
        :replace           => '',
        :universal_newline => true
      }
      title = title.encode(Encoding.find('ASCII'),encoding_options)
      if title =~ /samples\s+mrdialog - (.+)\s+dialog.*$/i
        @app_name =  $1
        @app_name = @app_name.gsub(/\s/,'')
        @window_id = id
        return true
        break
      end
    end
    return false
  end
def find_app terminal = SBApplication . applicationWithBundleIdentifier ( "com.apple.Terminal" ) terminal . windows . each do | window | title = window . name id = window . id encoding_options = { :invalid => :replace , :undef => :replace , :replace => '' , :universal_newline => true } title = title . encode ( Encoding . find ( 'ASCII' ) , encoding_options ) if title =~ / samples \s +mrdialog - (.+) \s +dialog.*$ /i @app_name = $1 @app_name = @app_name . gsub ( / \s / , '' ) @window_id = id return true break end end return false end
check if any mrdialog app is running, if so
populate @window_id and @app_name.
check if any mrdialog app is running if so populate @window_id and @app_name .