Advertisement
Guest User

ocr video screen program

a guest
May 20th, 2024
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.15 KB | Software | 0 0
  1. #!/bin/bash
  2.  
  3. # Program to recognize text on the screen.
  4.  
  5. function wait_for_window() {
  6.   # first parameter  - window title or part of the window title
  7.   window_title="$1"
  8.   time_sec=900
  9.   while [[ 0 -ne $time_sec ]]; do
  10.     echo "$time_sec, waiting... to appear"
  11.     sleep 1
  12.     time_sec=$[$time_sec-1]
  13.     xdotool search --onlyvisible --name "$window_title" windowactivate
  14.     if [[ $? == 0 ]]; then
  15.       echo "window found"
  16.       break
  17.     fi
  18.   done
  19. }
  20.  
  21. function start_program() {
  22.     window_title="dpScreenOCR"
  23.     ps cax | grep "dpscreenocr"
  24.     if [[ $? == 0 ]]; then
  25.         echo "skipping" > /dev/null
  26.     else
  27.          nohup dpscreenocr &>/dev/null &
  28.          wait_for_window "$window_title"
  29.          xdotool getactivewindow windowminimize
  30.     fi
  31.     sleep 1
  32.     xte 'keydown Control_L' 'keydown Alt_L' 'key grave' 'keyup Alt_L' 'keyup Control_L'
  33.     sleep 3
  34.     xte 'keydown Control_L' 'keydown Alt_L' 'key grave' 'keyup Alt_L' 'keyup Control_L'
  35. }
  36.  
  37. start_program
  38.  
  39. # depndencies:
  40.     # sudo apt install xautomation xdotool
  41.     # sudo add-apt-repository ppa:daniel.p/dpscreenocr
  42.     # sudo apt update
  43.     # sudo apt install dpscreenocr
  44.     # ctrl+alt+grave - default screen capture keystroke
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement