Z
Z
zeni1agent2020-01-21 22:15:15
Google
zeni1agent, 2020-01-21 22:15:15

Is it possible to somehow set up Google translator to translate pictures from the PC screen?

There is a function in Google translator to translate text from a camera picture, but it only works on android
. Is it possible to set it up so that it translates text from a computer screen?
The only way that I know now is to use the phone with scotch tape and shoot like that, but this is not very effective because the quality of the camera and the resolution of the computer are different.
I thought to download the bluestacks emulator, install Google translator on it and then somehow relay the shooting (Emulate camera shooting or intercept the signal) from the camera to the PC screen.
But I don't know how to do it
I know that there are other programs like screen translater or Yandex image translator, but they work extremely crookedly and only translate screenshots. while Google Translate translates everything in real time.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
zeni1agent, 2020-01-24
@zeni1agent

The only thing I could think of was to use AirDroid, AutoIt Window Info, AutoIt , Scissors, File Explorer, Opera.
To use, you need to
copy the code to a new .au3 file,
create a scrn folder and open it along with the DCIM folder
, you also need to open the translator in opera and Remote Control in a separate window and using AutoIt Window Info, find out the window name and replace it with $name_phone
and save the snapshot with scissors in the scrn folder.
When you run the code, you must have an English keyboard
Program code

#include <AutoItConstants.au3>


$aPos = MouseGetPos()
  MsgBox(4096, "Ask", 'go?')


; Режимы
$full = "{1}"
$window = "{2}"
$block = "{3}"
;сохранение позиций
$c_save1 = "{5}"
$c_save2 = "{6}"
; Запуск
$run = "{0}"

$run_trn = "{9}"
; Имя програмы
$program_name_1 = "Безымянный – Блокнот"
$program_name_2 = "Безымянный – Блокнот"

Global $pose_mouse[4]
Global $program
Global $mouse_pos1
Global $mouse_pos2


;Имя окна
Global $name_phone = 'Дистанционное управление'

;Скорость мыши
Global $speed_mouse = 7
;Скорость паузы
Global $speed_programs = 5000
;Комбинаций
Global $ctrl_x = "^x"
Global $ctrl_c = "^c"
Global $ctrl_v = "^v"
Global $ctrl_a = "^a"
Global $ctrl_s = "^s"
;Имя окна переводчика
Global $name_translater_win = "Google Переводчик - Opera"


Global   $way_cut = "C:\WINDOWS\system32\SnippingTool.exe"
Global   $cut_name = "Ножницы"
Global  $save_wind = "[CLASS:#32770]"
Global  $copy_wind = "Копирование файла"

Global  $foldew_win1 = "scrn"
Global  $foldew_win2 = "DCIM"

; Проверка существования окна
;If Not WinExists($foldew_win1) And WinExists($foldew_win2 ) And WinExists($name_translater_win) And WinExists($name_phone) Then
$f = WinExists($foldew_win1) + WinExists($foldew_win2 ) + WinExists($name_translater_win) + WinExists($name_phone)
If $f >= 4 Then
    MsgBox(4096, "", "Окно существует - " & $f)
Else
    MsgBox(4096, "", "Окно не существует - " & $f)
  Exit
 EndIf

HotKeySet($full, "full_fun")
Func full_fun()
   $pose_mouse[0] = 0
   $pose_mouse[1] = 0
   $pose_mouse[2] = 9999
   $pose_mouse[3] = 9999
EndFunc

HotKeySet($window, "window_fun")
Func window_fun()
   $program = WinGetPos($program_name_1)
   $pose_mouse[0] = $program[0]
   $pose_mouse[1] = $program[1]
   $pose_mouse[2] = $program[0] + $program[2]
   $pose_mouse[3] = $program[1] + $program[3]
EndFunc

HotKeySet($block, "block_fun")
Func block_fun()
   $program = WinGetPos($program_name_2)
   $pose_mouse[0] = $program[0]
   $pose_mouse[1] = $program[1]
   $pose_mouse[2] = $program[0] + $program[2]
   $pose_mouse[3] = $program[1] + $program[3]
EndFunc

HotKeySet($c_save1, "c_save1_fun")
Func c_save1_fun()
   $mouse_pos1 = MouseGetPos()
   $pose_mouse[0] = $mouse_pos1[0]
   $pose_mouse[1] = $mouse_pos1[1]
EndFunc

HotKeySet($c_save2, "c_save2_fun")
Func c_save2_fun()
   $mouse_pos2 = MouseGetPos()
   $pose_mouse[2] = $mouse_pos2[0]
   $pose_mouse[3] = $mouse_pos2[1]
EndFunc

HotKeySet($run, "run_fun")
Func run_fun()

Run($way_cut)
WinWaitActive($cut_name)

local $creen = WinGetPos($cut_name)
MouseClick("left", $creen[0] + 10, $creen[1] + 40, 1, 0)
Sleep(1000)
;Окно выбора
MouseMove($pose_mouse[0], $pose_mouse[1],0)
MouseDown ( $MOUSE_CLICK_LEFT )
MouseMove($pose_mouse[2], $pose_mouse[3],0)
MouseUp ( $MOUSE_CLICK_LEFT )

;Сохранить файл
Send($ctrl_s)
WinWaitActive($save_wind)
WinActivate($save_wind)
Send("{ENTER}")
Sleep(1000)
Send("{LEFT}{ENTER}")
Sleep(1000)
WinClose ($cut_name)

;Перекинуть ИЗ папки scrn
Local $hWnd = WinWait($foldew_win1, "", 10)
WinActivate($hWnd)
Sleep(1000)
ControlSend($hWnd, "", "[CLASS:DirectUIHWND;INSTANCE:2]", $ctrl_a)
Sleep(1000)
ControlSend($hWnd, "", "[CLASS:DirectUIHWND;INSTANCE:2]", $ctrl_c)

;Вставить В папку DCIM
Local $hWnd = WinWait($foldew_win2, "", 10)
Sleep(1000)
WinActivate($hWnd)
ControlSend($hWnd, "", "[CLASS:DirectUIHWND;INSTANCE:2]", $ctrl_v)
WinWaitActive($copy_wind )
Sleep(1000)
ControlSend($copy_wind , "", "", "{UP 2}{ENTER}")

EndFunc


;Запустить переводчик
HotKeySet($run_trn, "trans_fun")
Func trans_fun()

WinActivate($name_phone)
WinWaitActive($name_phone )

$transl = WinGetPos($name_phone)


;Активировать окно
MouseClick("left", $transl[0] + $transl[2] / 1.35, $transl[1] + $transl[3] / 1.25 , 2, $speed_mouse)
Sleep(5000)
MouseClick("left", $transl[0] + $transl[2] / 1.35, $transl[1] + $transl[3] / 1.25 , 2, $speed_mouse)
Sleep(1000)
;Поиск картиник
MouseClick("left", $transl[0] + $transl[2] / 4.5, $transl[1] + $transl[3] / 1.12 , 2, $speed_mouse)
Sleep(1000)
;Выбор
MouseClick("left", $transl[0] + $transl[2] / 2, $transl[1] + $transl[3] / 2  , 2, $speed_mouse)
Sleep(1000)
MouseClick("left", $transl[0] + $transl[2] / 2, $transl[1] + $transl[3] / 2  , 2, $speed_mouse)
Sleep(5000)
;Выбрать весь текст
MouseClick("left", $transl[0] + $transl[2] / 2, $transl[1] + $transl[3] / 1.12 , 2, $speed_mouse)
Sleep(1000)
;Выбрать текст
MouseClick("left", $transl[0] + $transl[2] / 8, $transl[1] + $transl[3] / 6 , 1, $speed_mouse)
Sleep(1000)
;Копировать текст
Send($ctrl_a)
Sleep(1000)
Send($ctrl_a)
Sleep(1000)
Send($ctrl_x)
Sleep(1000)
;Выйти
MouseClick("left", $transl[0] + $transl[2] / 9, $transl[1] + $transl[3] / 9, 2, $speed_mouse)
Sleep(1000)
;Скрыть лишнее меню
MouseClick("left", $transl[0] + $transl[2] / 2.8, $transl[1] + $transl[3] / 1.045, 2, $speed_mouse)
Sleep(1000)

;Скрыть лишнее меню
WinActivate($name_translater_win)
WinWaitActive($name_translater_win)

ControlSend($name_translater_win, "", "", $ctrl_a)
ControlSend($name_translater_win, "", "", $ctrl_v)

EndFunc

while 1
;   Sleep(100)
WEnd

But the code is very crooked, if anyone has better ideas, I'll gladly read it.

I
Inodik, 2020-02-03
@Inodik

There is a Cloud Vision API for this [1]
[1] https://cloud.google.com/vision/docs/ocr

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question