lib/screen_tracker.rb
# we have to wait until the next change, because when we start, it might be half-way through
# the current second...

we have to wait until the next change, because when we start, it might be half-way through
the current second
we have to wait until the next change because when we start it might be half - way through the current second
def wait_till_next_change
    original = get_bmp
    time_since_last_screen_change = Time.now
    while(@keep_going) 
      time_before_current_scan = Time.now
      current = get_bmp
      if current != original
        if @digits
          got = attempt_to_get_time_from_screen time_before_current_scan
          if got
            @status_callback.update_playing_well_status 'tracking it successfully' 
          else
            @status_callback.update_playing_well_status 'screen location where we anticipate digits is changing, but unable to track digits from it!'
            File.binwrite('original.debug.bmp', original)
            File.binwrite('current.debug.bmp', current)
          end
          return got
        else
          puts 'screen time change only detected... [unexpected]' 
          return
        end
      else
        if(Time.now - time_since_last_screen_change > 2.0)
          got_implies_able_to_still_ocr = attempt_to_get_time_from_screen time_before_current_scan
          if got_implies_able_to_still_ocr
            @status_callback.update_playing_well_status 'appears screen is paused but still tracking?'
            return got_implies_able_to_still_ocr
          else
            @status_callback.update_playing_well_status  'screen tracker: warning--unable to track screen time for some reason [perhaps screen obscured or it\'s not playing yet?] and screen is not changing at all, either'
            retrain_on_window_loop_forever
          end
          time_since_last_screen_change = Time.now
        end
      end
      sleep 0.02
    end
  end
def wait_till_next_change original = get_bmp time_since_last_screen_change = Time . now while ( @keep_going ) time_before_current_scan = Time . now current = get_bmp if current != original if @digits got = attempt_to_get_time_from_screen time_before_current_scan if got @status_callback . update_playing_well_status 'tracking it successfully' else @status_callback . update_playing_well_status 'screen location where we anticipate digits is changing, but unable to track digits from it!' File . binwrite ( 'original.debug.bmp' , original ) File . binwrite ( 'current.debug.bmp' , current ) end return got else puts 'screen time change only detected... [unexpected]' return end else if ( Time . now - time_since_last_screen_change > 2.0 ) got_implies_able_to_still_ocr = attempt_to_get_time_from_screen time_before_current_scan if got_implies_able_to_still_ocr @status_callback . update_playing_well_status 'appears screen is paused but still tracking?' return got_implies_able_to_still_ocr else @status_callback . update_playing_well_status 'screen tracker: warning--unable to track screen time for some reason [perhaps screen obscured or it\'s not playing yet?] and screen is not changing at all, either' retrain_on_window_loop_forever end time_since_last_screen_change = Time . now end end sleep 0.02 end end
we have to wait until the next change, because when we start, it might be half-way through
the current second...
we have to wait until the next change because when we start it might be half - way through the current second ...
# save away the current time to try and be most accurate...
 # unit tests do this still <sigh>
 # screen hasn't changed/updated at all in a long time # also reget window hwnd, just in case that's the problem...(can be with VLC moving from title to title)
 # LODO loop through all available player descriptions to find the right one, or a changed different new one, et al [?]