Gelöst! --- Batch OCR & Translate Script dreht extra Runden Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Gelöst! --- Batch OCR & Translate Script dreht extra Runden  Topic is solved

24 Feb 2024, 17:33

Hallo, dies ist mein Versuch, OCR und Translate unter einen Hut zu bekommen. Es funktioniert (auf meinem Win 10) auch perfekt, wenn ich aber (ohne Reload) eine andere Sprache zum Übersetzen auswähle und den Vorgang nochmal starte, erzeugt der Code doppelte Durchläufe.

Es Spielt keine Rolle ob ich eine oder mehrere Dateien scanne, der erste Job läuft immer problemlos.

Bei Programmstart wird die Systemsprache des Rechners gewählt. Sie kann jederzeit in eine andere Sprache eingestellt werden.

Bilddateien mit Text die im gleichen Verzeichnis liegen, werden nachdem sie OCR gescannt wurden, in die oben ausgewählte Sprache übersetzt.

Wegen Spamschutz Maßnahmen wird zwischen jeder Übersetzung eine Pause von etwa 4 Sekunden eingehalten. das reicht, ich habe in einer Woche über 250 mal bei Google übersetzen lassen und wurde nicht gesperrt.

Nach Fertigstellung liegen zu jedem Scann, Textdateien in der Originalversion und übersetzt im Verzeichnis

Der Code sieht mittlerweile von den vielen Reparatur Versuchen etwas Spagetti aus, aber ich hoffe mal, das er sich noch angenehm lesen lässt.

Ich werde wohl nochmal anfangen es zusammenzusetzen, würde mich aber freuen, wenn es mal gelesen und auch gerne kritisiert wird

#################################################
Ich habe das Problem gelöst, danke fürs lesen.

Code: Select all

	
	....
	if (thisOCRBevore = thisOCR) && (thisISOLanguageCodeBevore = thisISOLanguageCode)
	continue

	if (thisOCR)
	{
	thisOCRBevore 			:= thisOCR
	thisISOLanguageCodeBevore 	:= thisISOLanguageCode
	....
#################################################


4be5acb435771b64ee85e5dc40e3561acff71759.jpg
4be5acb435771b64ee85e5dc40e3561acff71759.jpg (158.15 KiB) Viewed 532 times

Die beiden Dateien aus diesem Beispiel:
Spoiler
Spoiler

Filename: ocr.und.translate.DEV.011.ahk

Code: Select all

	#SingleInstance force
	;#NoTrayIcon
	#NoEnv
	#Persistent
;	FileEncoding, UTF-8
	SetBatchLines, -1
	SetTitleMatchMode, 2
	SetKeyDelay 20
	SetWorkingDir, %A_ScriptDir%
	SetTimer,UPDATEDSCRIPT,500


if getControls#1
{
	FileRead, AusgabeVar,% A_ScriptFullPath
		loop, parse,% AusgabeVar, "`n"
		{
			if instr(a_loopfield, "%") || instr(a_loopfield, "0x1000")
			continue
			aloopfield := strReplace(a_loopfield,a_tab,a_space)
			aloopfield := strReplace(aloopfield,";")
			aloopfield := LTRIM(aloopfield)

			if instr(aloopfield, "GuiControl") && instr(aloopfield, "hide")
			{
			if !instr(thisHide,aloopfield)
			thisHide .= aloopfield "`n"
			}

			if instr(aloopfield, "GuiControl") && instr(aloopfield, "show")
			{
			if !instr(thisShow,aloopfield)
			thisShow .= aloopfield "`n"
			}	
		}

	sort, thisShow 
	sort, thisHide
	msgbox % clipboard := thisShow "`n" thisHide
}

	zoomfactor:=((A_ScreenWidth/1920)*(96/A_ScreenDPI))
	wa:=A_screenwidth,ha:=A_screenHeight,xx:=100

	thisZoomFactorFontVerdanaProDefault := 11

	gosub, GetISOLanguageCodes 		; LanguageCodes
	gosub, GetGoogleLanguagesAndShortName 	; GoogleLanguageCodes
	gosub, GetWin10LanguagePacks 		; Win10LanguagePacks 
	gosub, GetWin11LanguagePacks 		; Win11LanguagePacks 
	thisISOLanguageCode 	:= GetISOLanguageCode()
	thisISOLongnameCode 	:= GetISOLongnameCode()
	onlyOne := 1
	global comboSelect   
;	settimer, watchfiles, 300

	Gui, 1: -dpiscale 

	Gui, 1: Add, Tab3, x10 y0.5 Buttons vthisTab3 ; -0x107	Hidden
			 , OCR && Translate|ISOLanguageCodes|json|settings
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			thisTab3
; 	GuiControl, 1:  MoveDraw, 		thisTab3, 	% thisX(0.5) thisY(10.0) thisW(20.0) thisH(34.0) ;  default
; 	GuiControl, 1:  MoveDraw, 		thisTab3, 	% thisX(.5) thisY(.50) thisW(77.08) thisH(71.0)
	GuiControl, 1: 	+cBlack, 		thisTab3
;	GuiControl, 1: 	-0x107, 		thisTab3 ; taps unten anordnen
;	GuiControl, 1: 	+BackgroundRED, 	thisTab3
;	GuiControl, 1: ,  			thisTab3, 	test1|test2|test3
;	GuiControl, 1: ,  			thisTab3, 	test4
	GuiControl, 1:  show, 			thisTab3
;	GuiControl, 1:  hide, 			thisTab3
;	GuiControl, 1:  focus, 			thisTab3
;	GuiControl, 1:  disable, 		thisTab3
;	GuiControl, 1:  enable, 		thisTab3




	Gui, Tab, settings

	debug#1 := 0
	if debug#1
	Gui, 1: Add, Text, 0x1000 vtext1 thisX(20) thisY(0) w600 h20 ;thisW(60.0) ; r2 
	else
;	Gui, 1: Add, Text, vtext1 thisX(20) thisY(1) w600 h20 ;thisW(60.0) ; r2 
	Gui, 1: Add, Text,% "vtext1 r1"
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(16) ; 
	GuiControl, 1:  Font, 			text1
	GuiControl, 1:  MoveDraw, 		text1, 	% thisX(20) thisY(0) thisW(43.0) thisH(3.0) ;  default
	GuiControl, 1: 	+cBlue, 		text1
;	GuiControl, 1: 	+BackgroundRED, 	text1
	if debug#1
	GuiControl, 1: ,  			text1, 	%a_Space% test 1234 5678 90ab cdef ghij klmn opqr stuv wxyz test 1234 5678 90ab cdef ghij
	GuiControl, 1:  show, 			text1
;	GuiControl, 1:  hide, 			text1
;	GuiControl, 1:  focus, 			text1
;	GuiControl, 1:  disable, 		text1
;	GuiControl, 1:  enable, 		text1

	; ms-settings:regionlanguage?activationSource=SMC-Article-14236
	Gui, 1: Add, button, vButton3 gButton3 0x1000 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button3
 	GuiControl, 1:  MoveDraw, 		Button3, 	% thisX(.5) thisY(0.5) thisW(8.0) thisH(2.5) ;  default
	GuiControl, 1: 	+cBlack, 		Button3
;	GuiControl, 1: 	+BackgroundRED, 	Button3
	GuiControl, 1: ,  			Button3, 	language settings
	GuiControl, 1:  show, 			Button3
	GuiControl, 1:  hide, 			Button3
;	GuiControl, 1:  focus, 			Button3
;	GuiControl, 1:  disable, 		Button3
;	GuiControl, 1:  enable, 		Button3

	Gui, 1: Add, button, vButton4 gButton4 0x1000 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button4
 	GuiControl, 1:  MoveDraw, 		Button4, 	% thisX(9.5) thisY(0.5) thisW(8.0) thisH(2.5) ;  default
	GuiControl, 1: 	+cBlack, 		Button4
;	GuiControl, 1: 	+BackgroundRED, 	Button4
	GuiControl, 1: ,  			Button4, 	default settings
	GuiControl, 1:  show, 			Button4
	GuiControl, 1:  hide, 			Button4
;	GuiControl, 1:  focus, 			Button4
;	GuiControl, 1:  disable, 		Button4
;	GuiControl, 1:  enable, 		Button4







	Gui, Tab, OCR && Translate

	Gui, 1: Add, ComboBox, vcombo1 ; AltSubmit 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			combo1
; 	GuiControl, 1:  MoveDraw, 		combo1, 	% thisX(1.0) thisY(1.0) thisW(20.0) thisH(2.0) ;  default
 	GuiControl, 1:  MoveDraw, 		combo1, 	% thisX(1.5) thisY(1.9) thisW(17*60/100) thisH(2.0) ;  (eindrittel*maxwith/100)
	GuiControl, 1: 	+cBlack, 		combo1
;	GuiControl, 1: 	+BackgroundRED, 	combo1
;	GuiControl, 1: ,  			combo1, 	""
	GuiControl, 1:  show, 			combo1
;	GuiControl, 1:  hide, 			combo1
;	GuiControl, 1:  focus, 			combo1
;	GuiControl, 1:  disable, 		combo1
;	GuiControl, 1:  enable, 		combo1

	Gui, 1: Add, button, vButton1 gButton1, Start OCR
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button1
 	GuiControl, 1:  MoveDraw, 		Button1, 	% thisX(12.0) thisY(1.9) thisW(10*60/100) thisH(2.4) ;  default
	GuiControl, 1: 	+cBlack, 		Button1
;	GuiControl, 1: 	+BackgroundRED, 	Button1
	GuiControl, 1: ,  			Button1, 	Start OCR
	GuiControl, 1:  show, 			Button1
;	GuiControl, 1:  hide, 			Button1
;	GuiControl, 1:  focus, 			Button1
;	GuiControl, 1:  disable, 		Button1
;	GuiControl, 1:  enable, 		Button1

	Gui, 1: Add, button, vButton2 gButton2, Start OCR && Translation
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button2
 	GuiControl, 1:  MoveDraw, 		Button2, 	% thisX(18.3) thisY(1.9) thisW(15*60/100) thisH(2.4) ;  default
	GuiControl, 1: 	+cBlack, 		Button2
;	GuiControl, 1: 	+BackgroundRED, 	Button2
	GuiControl, 1: ,  			Button2, 	Start OCR && Translation
	GuiControl, 1:  show, 			Button2
;	GuiControl, 1:  hide, 			Button2
;	GuiControl, 1:  focus, 			Button2
;	GuiControl, 1:  disable, 		Button2
;	GuiControl, 1:  enable, 		Button2

;-----------------------------------------------------------------------------------------------------------------
; anmerkung: thisW(33*60/100) = thisW(prozent*guiwidth/100)
;-----------------------------------------------------------------------------------------------------------------
	if MaßNehmen
	Gui, 1: Add, text , 0x1000 vGroupBoxFileTranslate	; Maß nehmen
	else
	Gui,1:Add, GroupBox, cBlack vGroupBoxFileTranslate	Hidden	
	Gui,1: Font,							% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:    MoveDraw, 		GroupBoxFileTranslate, 		% thisX(1.0) thisY(.1) thisW(44.5*60/100) thisH(4.9) ;  default
	GuiControl, 1:    Font, 			GroupBoxFileTranslate
	GuiControl, 1: ,  GroupBoxFileTranslate, 					%a_Space% file translate %a_Space%
	GuiControl, 1:  show, 			GroupBoxFileTranslate
;	GuiControl, 1:  hide, 			GroupBoxFileTranslate
;	GuiControl, 1:    focus, 		GroupBoxFileTranslate
;	GuiControl, 1:    disable, 		GroupBoxFileTranslate
;	GuiControl, 1:    enable, 		GroupBoxFileTranslate
	GuiControl, 1: 	+cBlack, 		GroupBoxFileTranslate
	GuiControl, 1: 	+cBlack, 		GroupBoxFileTranslate
;schriftFarbe := "blue"
if (schriftFarbe = "blue")
	GuiControl, 1: 	+cBlack, 		GroupBoxFileTranslate
else
	GuiControl, 1: 	+c%thisCcolor%, 	GroupBoxFileTranslate
;	GuiControl, 1: 	+BackgroundFF9977, 	GroupBoxFileTranslate

	if MaßNehmen
	Gui,1: Add, text , 0x1000 vGroupBoxClipboardTranslate	; Maß nehmen
	else
	Gui,1:Add, GroupBox, cBlack vGroupBoxClipboardTranslate	Hidden	
	Gui,1: Font,							% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:    MoveDraw, 		GroupBoxClipboardTranslate, 		% thisX(46.5*60/100) thisY(.1) thisW(13.2*60/100) thisH(4.9) ;  default
	GuiControl, 1:    Font, 			GroupBoxClipboardTranslate
	GuiControl, 1: ,  GroupBoxClipboardTranslate, 					%a_Space% clipboard translate %a_Space%
	GuiControl, 1:  show, 			GroupBoxClipboardTranslate
;	GuiControl, 1:  hide, 			GroupBoxClipboardTranslate
;	GuiControl, 1:    focus, 		GroupBoxClipboardTranslate
;	GuiControl, 1:    disable, 		GroupBoxClipboardTranslate
;	GuiControl, 1:    enable, 		GroupBoxClipboardTranslate
	GuiControl, 1: 	+cBlack, 		GroupBoxClipboardTranslate
	GuiControl, 1: 	+cBlack, 		GroupBoxClipboardTranslate
;schriftFarbe := "blue"
if (schriftFarbe = "blue")
	GuiControl, 1: 	+cBlack, 		GroupBoxClipboardTranslate
else
	GuiControl, 1: 	+c%thisCcolor%, 	GroupBoxClipboardTranslate
;	GuiControl, 1: 	+BackgroundFF9977, 	GroupBoxClipboardTranslate

	Gui, 1: Add, button, vButton7 , Start OCR && Translation
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button7
 	GuiControl, 1:  MoveDraw, 		Button7, 	% thisX(47.0*60/100) thisY(1.9) thisW(12*60/100) thisH(2.4) ;  default
	GuiControl, 1: 	+cBlack, 		Button7
;	GuiControl, 1: 	+BackgroundRED, 	Button7
	GuiControl, 1: ,  			Button7, 	Start Translation
	GuiControl, 1:  show, 			Button7
;	GuiControl, 1:  hide, 			Button7
;	GuiControl, 1:  focus, 			Button7
;	GuiControl, 1:  disable, 		Button7
;	GuiControl, 1:  enable, 		Button7



	Gui, 1: Add, ListView, w600 vSourceFiles r20 grid, #|OCR Files
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			SourceFiles

 	GuiControl, 1:  MoveDraw, 		SourceFiles, 	% thisX(1.0) thisY(5.8) thisW(33*60/100) thisH(30.0)  ;  default

	GuiControl, 1: 	+cBlack, 		SourceFiles
;	GuiControl, 1: 	+BackgroundRED, 	SourceFiles
;	GuiControl, 1: ,  			SourceFiles, 	%a_Space% vSourceFiles %Space% 
	GuiControl, 1:  show, 			SourceFiles
;	GuiControl, 1:  hide, 			SourceFiles
;	GuiControl, 1:  focus, 			SourceFiles
;	GuiControl, 1:  disable, 		SourceFiles
;	GuiControl, 1:  enable, 		SourceFiles

	Gui, 1: Add, edit, vedit2 r2 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			edit2

	GuiControl, 1:  MoveDraw, 		edit2, 	% thisX(33*60/100+1.5) thisY(5.8) thisW(33*60/100) thisH(34.0) ;  default

	GuiControl, 1: 	+cBlack, 		edit2
;	GuiControl, 1: 	+BackgroundRED, 	edit2
	GuiControl, 1: ,  			edit2, 	%a_Space% vedit2 %Space% 
	GuiControl, 1:  show, 			edit2
;	GuiControl, 1:  hide, 			edit2
;	GuiControl, 1:  focus, 			edit2
;	GuiControl, 1:  disable, 		edit2
;	GuiControl, 1:  enable, 		edit2

	Gui, 1: Add, edit, vedit1 r2 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			edit1

	GuiControl, 1:  MoveDraw, 		edit1, 	% thisX(33*60/100*2+2) thisY(5.8) thisW(33*60/100) thisH(34.0) ;  default

	GuiControl, 1: 	+cBlack, 		edit1
;	GuiControl, 1: 	+BackgroundRED, 	edit1
;	GuiControl, 1: ,  			edit1, 	%a_Space% vedit1 %Space% 
	GuiControl, 1:  show, 			edit1
;	GuiControl, 1:  hide, 			edit1
;	GuiControl, 1:  focus, 			edit1
;	GuiControl, 1:  disable, 		edit1
;	GuiControl, 1:  enable, 		edit1

	Gui, 1: Add, button, vButton5 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button5
 	GuiControl, 1:  MoveDraw, 		Button5, 	% thisX(1.5) thisY(37.0) thisW(8.0) thisH(2.4) ;  default
	GuiControl, 1: 	+cBlack, 		Button5
;	GuiControl, 1: 	+BackgroundRED, 	Button5
	GuiControl, 1: ,  			Button5, 	add files
	GuiControl, 1:  show, 			Button5
;	GuiControl, 1:  hide, 			Button5
;	GuiControl, 1:  focus, 			Button5
;	GuiControl, 1:  disable, 		Button5
;	GuiControl, 1:  enable, 		Button5

	Gui, 1: Add, button, vButton6 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			Button6
 	GuiControl, 1:  MoveDraw, 		Button6, 	% thisX(11.5) thisY(37.0) thisW(8.0) thisH(2.4) ;  default
	GuiControl, 1: 	+cBlack, 		Button6
;	GuiControl, 1: 	+BackgroundRED, 	Button6
	GuiControl, 1: ,  			Button6, 	clear list ; delete selected
	GuiControl, 1:  show, 			Button6
;	GuiControl, 1:  hide, 			Button6
;	GuiControl, 1:  focus, 			Button6
;	GuiControl, 1:  disable, 		Button6
;	GuiControl, 1:  enable, 		Button6

	if MaßNehmen
	Gui, 1: Add, CheckBox, 0x1000 vAllowUseDragAndDrop , Allow Drop Files ; Ablegen von Dateien zulassen
	else
	Gui, 1: Add, CheckBox, vAllowUseDragAndDrop checked, Allow Drop Files ; Ablegen von Dateien zulassen
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			AllowUseDragAndDrop
 	GuiControl, 1:  MoveDraw, 		AllowUseDragAndDrop, 	% thisX((46.5*60/100)+(13.2*60/100)+1) thisY(.8) thisW(18.2*60/100) thisH(2) ;  default
	GuiControl, 1: 	+cBlack, 		AllowUseDragAndDrop
;	GuiControl, 1: 	+BackgroundRED, 	AllowUseDragAndDrop
	GuiControl, 1: ,  			AllowUseDragAndDrop, 	allow drag and drop files ; Ziehen und Ablegen
	GuiControl, 1:  show, 			AllowUseDragAndDrop
;	GuiControl, 1:  hide, 			AllowUseDragAndDrop
;	GuiControl, 1:  focus, 			AllowUseDragAndDrop
;	GuiControl, 1:  disable, 		AllowUseDragAndDrop
;	GuiControl, 1:  enable, 		AllowUseDragAndDrop

	if MaßNehmen
	Gui, 1: Add, CheckBox, 0x1000 vAllowCopyAndPasteHotkey, Allow Drop Files ; Ablegen von Dateien zulassen
	else
	Gui, 1: Add, CheckBox, vAllowCopyAndPasteHotkey, Allow Drop Files ; Ablegen von Dateien zulassen
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			AllowCopyAndPasteHotkey
 	GuiControl, 1:  MoveDraw, 		AllowCopyAndPasteHotkey, 	% thisX((46.5*60/100)+(13.2*60/100)+1) thisY(2.8) thisW(18.2*60/100) thisH(2) ;  default
	GuiControl, 1: 	+cBlack, 		AllowCopyAndPasteHotkey
;	GuiControl, 1: 	+BackgroundRED, 	AllowCopyAndPasteHotkey
	GuiControl, 1: ,  			AllowCopyAndPasteHotkey, 	enable copy and paste hotkey ; To copy and paste, you can use keyboard shortcuts
	GuiControl, 1:  show, 			AllowCopyAndPasteHotkey
;	GuiControl, 1:  hide, 			AllowCopyAndPasteHotkey
;	GuiControl, 1:  focus, 			AllowCopyAndPasteHotkey
;	GuiControl, 1:  disable, 		AllowCopyAndPasteHotkey
;	GuiControl, 1:  enable, 		AllowCopyAndPasteHotkey

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
	Gui, Tab, ISOLanguageCodes

	Gui, 1: Add, ListView, w550 vCountryCodes r20 grid, Language|Country|Code|HEX|Longname
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			CountryCodes
 	GuiControl, 1:  MoveDraw, 		CountryCodes, 	% thisX(.5) thisY(1.0) thisW(41.9) ; thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		CountryCodes
;	GuiControl, 1: 	+BackgroundRED, 	CountryCodes
	GuiControl, 1: ,  			CountryCodes, 	%a_Space% vCountryCodes %Space% 
	GuiControl, 1:  show, 			CountryCodes
;	GuiControl, 1:  hide, 			CountryCodes
;	GuiControl, 1:  focus, 			CountryCodes
;	GuiControl, 1:  disable, 		CountryCodes
;	GuiControl, 1:  enable, 		CountryCodes

	Gui, 1: Add, ListView, w300 vGoogleCountryCodes r20 grid, Language|Code
	Gui, 1: 	Font, 						% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			GoogleCountryCodes
 	GuiControl, 1:  MoveDraw, 		GoogleCountryCodes, 	% thisX(43.0) thisY(1.0) thisW(20.0) ; thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		GoogleCountryCodes
;	GuiControl, 1: 	+BackgroundRED, 	GoogleCountryCodes
	GuiControl, 1: ,  			GoogleCountryCodes, 	%a_Space% vGoogleCountryCodes %Space% 
	GuiControl, 1:  show, 			GoogleCountryCodes
;	GuiControl, 1:  hide, 			GoogleCountryCodes
;	GuiControl, 1:  focus, 			GoogleCountryCodes
;	GuiControl, 1:  disable, 		GoogleCountryCodes
;	GuiControl, 1:  enable, 		GoogleCountryCodes

	Gui, Tab, json

	Gui, 1: Add, ListView, w600 vjson r20 grid, json
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			json
 	GuiControl, 1:  MoveDraw, 		json, 	% thisX(.5) thisY(1.0) thisW(41.9) ; thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		json
;	GuiControl, 1: 	+BackgroundRED, 	json
	GuiControl, 1: ,  			json, 	%a_Space% vjson %Space% 
	GuiControl, 1:  show, 			json
;	GuiControl, 1:  hide, 			json
;	GuiControl, 1:  focus, 			json
;	GuiControl, 1:  disable, 		json
;	GuiControl, 1:  enable, 		json

;------------------------------------------------------------------ use windows codes
	combo1CountryArr 	:= object()
	combo1LongnameArr	:= object()
	combo1CodeArr 		:= object()
	combo1CodeHexArr 	:= object()
	combo1CodeLanguageArr 	:= object()
	loop, parse,% LanguageCodes, `n
	{
	split := strsplit(a_loopfield,a_tab)
	combo1CountryArr.push(split.1)
	combo1LongnameArr.push(split.2)
	combo1CodeArr.push(split.3)
	combo1CodeHexArr.push(split.4)
	combo1CodeLanguageArr.push(split.5)

	if (A_Language=split.4)
	{
	thisComputer := split.5
	combo1CountryVar .= split.1 a_space a_space "(" strreplace(split.2,"_", a_space) ")||"
	} else {
	combo1CountryVar .= split.1 a_space a_space "(" strreplace(split.2,"_", a_space) ")|"
	}
;	Gui, Tab, ISOLanguageCodes
	Gui, listview, CountryCodes 		;------------------	WhoAmI
	LV_Add("", split.5, split.1, split.3, split.4, strreplace(split.2,"_", a_space))
	LV_ModifyCol()	
	}
;	msgbox % combo1CodeLanguageArr.length() ; 115
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")
;	GuiControl, 1:,	combo1,% combo1CountryVar
;------------------------------------------------------------------ 	use google codes
	GoogleCodeLanguageArr 	:= object()
	GoogleCodeArr 		:= object()

	gui, listview, GoogleCountryCodes 	;------------------	Language for Translate
	loop, parse,% GoogleLanguageCodes , `n
	{
	split := strsplit(a_loopfield,a_tab)
	GoogleCodeLanguageArr.push(split.1)
	GoogleCodeArr.push(split.2)

	if (thisComputer=split.1)
	GoogleCountryCodes .= split.1 a_space a_space "(" split.2 ")||"
	else 
	GoogleCountryCodes .= split.1 a_space a_space "(" split.2 ")|"

	Gui, listview, GoogleCountryCodes
	LV_Add("", split.1, split.2)
	}

	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")

;	msgbox % GoogleCodeLanguageArr.length() ; 133

	GuiControl, 1:,	combo1,% GoogleCountryCodes
;------------------------------------------------------------------

	startInfo := 	"Bei Programmstart wird die Systemsprache des Rechners gewählt. Sie "
			. "kann jederzeit in eine andere Sprache eingestellt werden.`n`n"
			. "Bilddateien mit Text die im gleichen Verzeichnis liegen, werden nachdem sie OCR gescannt "
			. "wurden, in die oben ausgewählte Sprache übersetzt.`n`n"
			. "Dateien die Sie mit der Maus auf das Programm schieben, werden ebenfalls erkannt und bearbeitet.`n`n"
			. "Wegen Spamschutz Maßnahmen wird zwischen jeder Übersetzung eine Pause von etwa 4 Sekunden eingehalten.`n`n"
			. "Nach Fertigstellung liegen zu jedem Scann, Textdateien in der Originalversion und übersetzt im Verzeichnis`n`n"
			. "Die Bilddateien werden nachdem sie gescannt wurden in das Verzeichnis \done verschoben.`n`n"
			. "Google Translate übersetzt bis zu 500.000 Zeichen pro Monat kostenlos." 
			. " Alles, was darüber hinausgeht, gilt als kommerzielle Nutzung und wird "
			. "mit 20 USD pro 1 Million Zeichen in Rechnung gestellt.`n`n"
			. "Infolink:`nhttps://cloud.google.com/translate/pricing?hl=de`n`n#############################`n`n"

	GuiControl, 1:,	edit2,% startInfo

	startInfo := 	 "When the program starts, the computer's system language is selected. It can be set to another language at any time.`n`n"
			. "Image files with text located in the same directory will be translated into the language selected above after they have been OCR scanned.`n`n"
			. "Files that you drag onto the program with the mouse are also recognized and processed.`n`n"
			. "Due to spam protection measures, there is a pause of around 4 seconds between each translation.`n`n"
			. "After completion, text files for each scan are in the original version and translated in the directory`n`n"
			. "After the image files have been scanned, they will be moved to the \done directory.`n`n"
			. "Google Translate translates up to 500,000 characters per month for free. Anything beyond this is considered commercial use and will be billed at $20 per 1 million characters.`n`n"
			. "Info link:`n"
			. "https://cloud.google.com/translate/pricing?hl=en`n`n#############################`n`n"

			. "Cuando se inicia el programa, se selecciona el idioma del sistema de la computadora. Se puede configurar en otro idioma en cualquier momento.`n`n"
			. "Los archivos de imagen con texto ubicado en el mismo directorio se traducirán al idioma seleccionado anteriormente después de haber sido escaneados con OCR.`n`n"
			. "Los archivos que arrastra al programa con el mouse también se reconocen y procesan.`n`n"
			. "Debido a las medidas de protección contra spam, hay una pausa de unos 4 segundos entre cada traducción.`n`n"
			. "Una vez finalizado, los archivos de texto de cada escaneo están en la versión original y traducidos en el directorio.`n`n"
			. "Una vez escaneados los archivos de imagen, se moverán al directorio \done.`n`n"
			. "Google Translate traduce hasta 500.000 caracteres al mes de forma gratuita. Cualquier cosa más allá de esto se considera uso comercial y se facturará a 20 dólares por millón de caracteres.`n`n"
			. "Enlace de información:`n"
			. "https://cloud.google.com/translate/pricing?hl=es"

	GuiControl, 1:,	edit1,% startInfo

;	gui, show

	Gui, 1: Show,x100 ,% "Batch OCR & Translate " strReplace((substr(a_scriptname,-10)),".ahk")


	thisLoopFile =

;	Gui, Tab, ISOLanguageCodes
	Gui, listview, SourceFiles
	LV_delete()
	Loop Files,% a_scriptdir  "\*.*"
	{
	if A_LoopFileName contains jpg,png
	LV_Add("", a_index, A_LoopFileName )	
	LV_ModifyCol()
	}
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")

return 	; firstreturn

;---------------------------------------------------------------------------------------------
;---------------------------------------------------------------------------------------------
	thisrestart:

	thisTimeStamp 		:= A_DD "." Month(A_MM) "." a_YYYY " " A_Hour "-" A_Min "-" A_Sec
	thisScannFolder 	:= a_scriptDir "\done\" thisTimeStamp

	Gui, submit, nohide
;	thisISOLanguageCode 	:= GetISOLanguageCode(combo1CodeHexArr[combo1])

;	msgbox % A_GuiControl

	if (A_GuiControl="Start OCR && Translation") 
	|| (A_GuiControl="button1") 
	|| (A_GuiControl="button2") 
;	|| (A_GuiControl=1)
	|| A_GuiControl contains Start OCR
	{
	GuiControl, 1:,	edit1,% ""
	GuiControl, 1:,	edit2,% ""
	thisOCR =
	thisGoogleTranslate =
	}

	global ANow := a_now

	Loop Files,% a_scriptdir "\*.jpg"
	{
	if A_LoopFileFullPath
	thisLoopFile .= A_LoopFileFullPath "`n"
	}

	Loop Files,% a_scriptdir "\*.png"
	{
	if A_LoopFileFullPath
	thisLoopFile .= A_LoopFileFullPath "`n"
	}

	if thisLoopFile not contains jpg,png
	{
	sleep, 1
	msgbox,4096,% a_linenumber, keine jpg dateien gefunden
pause
	;exitapp
	}

;	split := strsplit(thisLoopFile,"`n")  	; ???

	sort, thisLoopFile
	loop, parse,% thisLoopFile, `n
	{
	if !A_LoopField
	continue

	ALoopField := ""
	ALoopField := A_LoopField

	try Words := thisOCR := ocr(ALoopField, "de")
	
; sprachen in windows installieren
; https://support.microsoft.com/de-de/windows/sprachpakete-f%C3%BCr-windows-a5094319-a92d-18de-5b53-1cfc697cfca8

	if !debug
	if (thisOCRBevore = thisOCR) && (thisISOLanguageCodeBevore = thisISOLanguageCode)
	continue
	thisOCRBevore 			:= thisOCR
	thisISOLanguageCodeBevore 	:= thisISOLanguageCode

	if (thisOCR) && (A_GuiControl="button2") 
	{
;	try thisGoogleTranslate 	:= GoogleTranslate(thisOCR,"iw",(thisISOLanguageCode?thisISOLanguageCode:"de"))
;	msgbox,,% a_linenumber, % thisISOLanguageCode,1
;	translateCounter++
;	try thisGoogleTranslate := GoogleTranslate(thisOCR,    ,"zh-CN") ; persisch
	try thisGoogleTranslate := GoogleTranslate(thisOCR,    ,(thisISOLanguageCode))

;	msgbox % GetISOCodeA(thisISOLanguageCode) a_space thisISOLanguageCode 
	thisXXX :=  	GetISOCodeA(thisISOLanguageCode) 
			? GetISOCodeA(thisISOLanguageCode)
			: GetISOCodeB(thisISOLanguageCode)
			. a_space thisISOLanguageCode 

	if !fileexist(thisScannFolder)
	filecreateDir,% (thisScannFolder)
	FileAppend,% thisGoogleTranslate  "`n#############`n" 
		, % (thisScannFolder "\" thisXXX " Translate.txt"), UTF-8
	}

	if !fileexist(thisScannFolder)
	filecreateDir,% (thisScannFolder)
	FileAppend,% thisOCR "`n#############`n" 
		, % (thisScannFolder "\" "Ocr.txt"), UTF-8


	if !debug
		{
			thisCode := (AhkObj[9, 1, 1])
			res :=  "Translated from: " 
				. thisCode a_space
				. (GetISOCodeA(thisCode) ? "(" GetISOCodeA(thisCode) ")" : "(" GetISOCodeB(thisCode) ")")
				. " into: " 
				. (thisISOLanguageCode) a_space a_space
				. " (" RTRIM(strSplit(combo1,"(",")").1) ")" a_space 
				. ((translateCounter>1) ? (translateCounter " Files") : (translateCounter " File"))
			;	. " (" strreplace(combo1LongnameArr["Longname"],"_", a_space) ")" a_space translateCounter " Pages" 
		;if res
		GuiControl, 1:,	Text1,% strReplace(res,a_space a_space, a_space)
		res =
		}

	; into
;	msgbox,4096,% a_linenumber,%	comboSelect := " (" RTRIM(strSplit(combo1,"(",")").1) ")" "`n" combo1

	thisOCRFULL 		.= "Page: " a_index "`n" thisOCR "`n----------------`n" 
	thisGoogleTranslateFULL .= "Page: " a_index "`n" thisGoogleTranslate "`n----------------`n" 
;thisOCR =
;thisGoogleTranslate =

	if !debug
	{	
	if !(thisGoogleTranslateLast=thisGoogleTranslate)
	{
	thisGoogleTranslateLast := thisGoogleTranslate
;	atickcount := a_tickcount
	GuiControl, 1: ,  			thisTab3,% 	"File" translateCounter
	Gui, Tab,% "File" translateCounter
	Gui, 1: Add, edit,% "vOCREdit" translateCounter " r2" 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			% "OCREdit" translateCounter 
	GuiControl, 1:  MoveDraw, 		% "OCREdit" translateCounter, 	% thisX(1.5) thisY(1.0) thisW(20.0) thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		% "OCREdit" translateCounter
;	GuiControl, 1: 	+BackgroundRED, 	% "OCREdit" translateCounter
	GuiControl, 1: ,  			% "OCREdit" translateCounter, 	% "File" translateCounter
	GuiControl, 1:  show, 			% "OCREdit" translateCounter
;	GuiControl, 1:  hide, 			% "OCREdit" translateCounter
;	GuiControl, 1:  focus, 			% "OCREdit" translateCounter
;	GuiControl, 1:  disable, 		% "OCREdit" translateCounter
;	GuiControl, 1:  enable, 		% "OCREdit" translateCounter
	thisFilesTab := "File" translateCounter
	GuiControl, 1:, %thisFilesTab%,% thisOCR
	;GuiControl, 1:, ,% thisOCR

	Gui, 1: Add, edit,% "vTranslateEdit" translateCounter " r2" 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(thisZoomFactorFontVerdanaProDefault) ; 
	GuiControl, 1:  Font, 			% "TranslateEdit" translateCounter 
	GuiControl, 1:  MoveDraw, 		% "TranslateEdit" translateCounter, 	% thisX(22.0) thisY(1.0) thisW(20.0) thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		% "TranslateEdit" translateCounter
;	GuiControl, 1: 	+BackgroundRED, 	% "TranslateEdit" translateCounter
	GuiControl, 1: ,  			% "TranslateEdit" translateCounter, 	% "File" translateCounter
	GuiControl, 1:  show, 			% "TranslateEdit" translateCounter
;	GuiControl, 1:  hide, 			% "TranslateEdit" translateCounter
;	GuiControl, 1:  focus, 			% "TranslateEdit" translateCounter
;	GuiControl, 1:  disable, 		% "TranslateEdit" translateCounter
;	GuiControl, 1:  enable, 		% "TranslateEdit" translateCounter
	thisFilesTab := "File" translateCounter
	GuiControl, 1:, %thisFilesTab%,% thisGoogleTranslate 
	}} ; debug end

	thisOCR 		:= ""
	thisGoogleTranslate 	:= ""


;	thisScannFolder 	:= a_scriptDir "\done\" thisTimeStamp
	if !fileexist(thisScannFolder)
	filecreateDir,% (thisScannFolder)
	fileMove,% ALoopField,% (thisScannFolder), 1
;	fileCopy,% ALoopField,% (thisScannFolder) ; test
	splitlength := split.length()
		random, rand, 3000, 5000
		sleep,% rand ; translate spamschutz
	} ; ---------------------------------------------------------------------- loopEnd


;	msgbox,4096,% a_linenumber,% thisISOLanguageCode "`n" combo1LongnameArr[combo1]

	combo1LongnameArr["Longname"] :=  ((combo1LongnameArr[combo1]="")
					? thisISOLongnameCode
					: (combo1LongnameArr[combo1]))

	if thisOCRFULL || thisGoogleTranslateFULL
	{
	GuiControl, 1:,	edit2,% thisOCRFULL
	GuiControl, 1:,	edit1,% thisGoogleTranslateFULL
	thisOCRFULL 		:= ""
	thisGoogleTranslateFULL := ""
	}

	if !debug
		{
			thisCode := (AhkObj[9, 1, 1])
			res :=  "Translated from: " 
				. thisCode a_space
				. (GetISOCodeA(thisCode) ? "(" GetISOCodeA(thisCode) ")" : "(" GetISOCodeB(thisCode) ")")
				. " into: " 
				. (thisISOLanguageCode) a_space a_space
				. " (" RTRIM(strSplit(combo1,"(",")").1) ")" a_space 
				. ((translateCounter>1) ? (translateCounter " Files") : (translateCounter " File"))
			;	. " (" strreplace(combo1LongnameArr["Longname"],"_", a_space) ")" a_space translateCounter " Pages" 
		;if res
		GuiControl, 1:,	Text1,% strReplace(res,a_space a_space, a_space)
		res =
		}

	thisOCRFULL 		=
	thisGoogleTranslateFULL =


	Gui, Tab, json
	Gui, listview, json
	LV_delete()
	loop, parse,% BeautifyJson(thisjson), `n
	LV_Add("", a_loopfield)	
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")

if debug
msgbox,4096,% a_linenumber " Fertig!",%    "EingabeSprache: " AhkObj[9, 1, 1] "`n"
					 . "Übersetzt in: " thisISOLanguageCode "`n" combo1LongnameArr["Longname"]


	; temporäre tabs schliessen
	;GuiControl, 1: ,  			thisTab3, 	|OCR && Translate|ISOLanguageCodes|json

thisISOLanguageCode =
;exitapp
return
;##
For Line, Array In Words
   For Each, Word In Array 
{
if (word.4>100)
msgbox,4096,% a_linenumber,% word.5
}

;Gui, Submit, Nohide
;ControlGet, AusgabeVar, List, , SysListView321

Return

GuiClose:
reload
ExitApp

;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
Button3:
try run	 ms-settings:regionlanguage?activationSource=SMC-Article-14236
return
;--------------------------------------
Button4:
if (ToggleButton4:=!ToggleButton4)
{
 GuiControl, 1:  hide,    AllowCopyAndPasteHotkey
 GuiControl, 1:  hide,    AllowUseDragAndDrop
 GuiControl, 1:  hide,    Button1
 GuiControl, 1:  hide,    Button2
 GuiControl, 1:  hide,    Button3
; GuiControl, 1:  hide,    Button4
 GuiControl, 1:  hide,    Button5
 GuiControl, 1:  hide,    Button6
 GuiControl, 1:  hide,    Button7
 GuiControl, 1:  hide,    combo1
 GuiControl, 1:  hide,    CountryCodes
 GuiControl, 1:  hide,    edit1
 GuiControl, 1:  hide,    edit2
 GuiControl, 1:  hide,    GoogleCountryCodes
 GuiControl, 1:  hide,    GroupBoxClipboardTranslate
 GuiControl, 1:  hide,    GroupBoxFileTranslate
 GuiControl, 1:  hide,    json
 GuiControl, 1:  hide,    SourceFiles
;GuiControl, 1:  hide,    SysTabControl321
 GuiControl, 1:  hide,    text1
 GuiControl, 1:  hide,    thisTab3
} else {
 GuiControl, 1:  show,    AllowCopyAndPasteHotkey
 GuiControl, 1:  show,    AllowUseDragAndDrop
 GuiControl, 1:  show,    Button1
 GuiControl, 1:  show,    Button2
 GuiControl, 1:  show,    Button3
; GuiControl, 1:  show,    Button4
 GuiControl, 1:  show,    Button5
 GuiControl, 1:  show,    Button6
 GuiControl, 1:  show,    Button7
 GuiControl, 1:  show,    combo1
 GuiControl, 1:  show,    CountryCodes
 GuiControl, 1:  show,    edit1
 GuiControl, 1:  show,    edit2
 GuiControl, 1:  show,    GoogleCountryCodes
 GuiControl, 1:  show,    GroupBoxClipboardTranslate
 GuiControl, 1:  show,    GroupBoxFileTranslate
 GuiControl, 1:  show,    json
 GuiControl, 1:  show,    SourceFiles
 GuiControl, 1:  show,    text1
 GuiControl, 1:  show,    thisTab3
}
return
;--------------------------------------
;--------------------------------------
;combo1:
Button1:
Button2:
gui, submit, nohide
if debug
msgbox,4096,% a_linenumber,%  	"Language Nr.: " combo1 "/" combo1CountryArr.length() 	"`n"
				. combo1CountryArr[combo1]  	"`n"
				. combo1LongnameArr[combo1] 	"`n"
				. combo1CodeArr[combo1] 	"`n"
				. combo1CodeHexArr[combo1]

; thisISOLanguageCode 		:= GetISOLanguageCode(combo1CodeHexArr[combo1]) 	; used windows codes
  thisISOLanguageCode 		:= strSplit(combo1,"(",")").2 				; used google codes
goto	thisrestart
return ; 
;------------------------------------------------------------------
; https://www.autohotkey.com/boards/viewtopic.php?p=393308#p393308  by sobuj53
; Take a 4-digit language code or (if no parameter) the current language code and return the corresponding 2-digit ISO code
GetISOLanguageCode(lang := 0) {
global   
LanguageCodeArray := { 0436: "af" ; Afrikaans
			, 041c: "sq" ; Albanian
			, 0401: "ar" ; Arabic_Saudi_Arabia
			, 0801: "ar" ; Arabic_Iraq
			, 0c01: "ar" ; Arabic_Egypt
			, 1001: "ar" ; Arabic_Libya
			, 1401: "ar" ; Arabic_Algeria
			, 1801: "ar" ; Arabic_Morocco
			, 1c01: "ar" ; Arabic_Tunisia
			, 2001: "ar" ; Arabic_Oman
			, 2401: "ar" ; Arabic_Yemen
			, 2801: "ar" ; Arabic_Syria
			, 2c01: "ar" ; Arabic_Jordan
			, 3001: "ar" ; Arabic_Lebanon
			, 3401: "ar" ; Arabic_Kuwait
			, 3801: "ar" ; Arabic_UAE
			, 3c01: "ar" ; Arabic_Bahrain
			, 042c: "az" ; Azeri_Latin
			, 082c: "az" ; Azeri_Cyrillic
			, 042d: "eu" ; Basque
			, 0423: "be" ; Belarusian
			, 0402: "bg" ; Bulgarian
			, 0403: "ca" ; Catalan
			, 0404: "zh-CN" ; Chinese_Taiwan
			, 0804: "zh-CN" ; Chinese_PRC
			, 0c04: "zh-CN" ; Chinese_Hong_Kong
			, 1004: "zh-CN" ; Chinese_Singapore
			, 1404: "zh-CN" ; Chinese_Macau
			, 041a: "hr" ; Croatian
			, 0405: "cs" ; Czech
			, 0406: "da" ; Danish
			, 0413: "nl" ; Dutch_Standard
			, 0813: "nl" ; Dutch_Belgian
			, 0409: "en" ; English_United_States
			, 0809: "en" ; English_United_Kingdom
			, 0c09: "en" ; English_Australian
			, 1009: "en" ; English_Canadian
			, 1409: "en" ; English_New_Zealand
			, 1809: "en" ; English_Irish
			, 1c09: "en" ; English_South_Africa
			, 2009: "en" ; English_Jamaica
			, 2409: "en" ; English_Caribbean
			, 2809: "en" ; English_Belize
			, 2c09: "en" ; English_Trinidad
			, 3009: "en" ; English_Zimbabwe
			, 3409: "en" ; English_Philippines
			, 0425: "et" ; Estonian
			, 040b: "fi" ; Finnish
			, 040c: "fr" ; French_Standard
			, 080c: "fr" ; French_Belgian
			, 0c0c: "fr" ; French_Canadian
			, 100c: "fr" ; French_Swiss
			, 140c: "fr" ; French_Luxembourg
			, 180c: "fr" ; French_Monaco
			, 0437: "ka" ; Georgian
			, 0407: "de" ; German_Standard
			, 0807: "de" ; German_Swiss
			, 0c07: "de" ; German_Austrian
			, 1007: "de" ; German_Luxembourg
			, 1407: "de" ; German_Liechtenstein
			, 0408: "el" ; Greek
			, 040d: "iw" ; Hebrew
			, 0439: "hi" ; Hindi
			, 040e: "hu" ; Hungarian
			, 040f: "is" ; Icelandic
			, 0421: "id" ; Indonesian
			, 0410: "it" ; Italian_Standard
			, 0810: "it" ; Italian_Swiss
			, 0411: "ja" ; Japanese
			, 0412: "ko" ; Korean
			, 0426: "lv" ; Latvian
			, 0427: "lt" ; Lithuanian
			, 042f: "mk" ; Macedonian
			, 043e: "ms" ; Malay_Malaysia
			, 083e: "ms" ; Malay_Brunei_Darussalam
			, 0414: "no" ; Norwegian_Bokmal
			, 0814: "no" ; Norwegian_Nynorsk
			, 0415: "pl" ; Polish
			, 0416: "pt" ; Portuguese_Brazilian
			, 0816: "pt" ; Portuguese_Standard
			, 0418: "ro" ; Romanian
			, 0419: "ru" ; Russian
			, 081a: "sr" ; Serbian_Latin
			, 0c1a: "sr" ; Serbian_Cyrillic
			, 041b: "sk" ; Slovak
			, 0424: "sl" ; Slovenian
			, 040a: "es" ; Spanish_Traditional_Sort
			, 080a: "es" ; Spanish_Mexican
			, 0c0a: "es" ; Spanish_Modern_Sort
			, 100a: "es" ; Spanish_Guatemala
			, 140a: "es" ; Spanish_Costa_Rica
			, 180a: "es" ; Spanish_Panama
			, 1c0a: "es" ; Spanish_Dominican_Republic
			, 200a: "es" ; Spanish_Venezuela
			, 240a: "es" ; Spanish_Colombia
			, 280a: "es" ; Spanish_Peru
			, 2c0a: "es" ; Spanish_Argentina
			, 300a: "es" ; Spanish_Ecuador
			, 340a: "es" ; Spanish_Chile
			, 380a: "es" ; Spanish_Uruguay
			, 3c0a: "es" ; Spanish_Paraguay
			, 400a: "es" ; Spanish_Bolivia
			, 440a: "es" ; Spanish_El_Salvador
			, 480a: "es" ; Spanish_Honduras
			, 4c0a: "es" ; Spanish_Nicaragua
			, 500a: "es" ; Spanish_Puerto_Rico
			, 0441: "sw" ; Swahili
			, 041d: "sv" ; Swedish
			, 081d: "sv" ; Swedish_Finland
			, 0449: "ta" ; Tamil
			, 041e: "th" ; Thai
			, 041f: "tr" ; Turkish
			, 0422: "uk" ; Ukrainian
			, 0420: "ur" ; Urdu
			, 042a: "vi"} ; Vietnamese
   If(lang)
     Return LanguageCodeArray[lang]
   Else Return LanguageCodeArray[A_Language]
}
;-------------------------------------------------------------
GetISOLongnameCode(lang := 0) {
global   
LanguageLongnameArray := { 0436: "Afrikaans"
			, 041c: "Albanian"
			, 0401: "Arabic_Saudi_Arabia"
			, 0801: "Arabic_Iraq"
			, 0c01: "Arabic_Egypt"
			, 1001: "Arabic_Libya"
			, 1401: "Arabic_Algeria"
			, 1801: "Arabic_Morocco"
			, 1c01: "Arabic_Tunisia"
			, 2001: "Arabic_Oman"
			, 2401: "Arabic_Yemen"
			, 2801: "Arabic_Syria"
			, 2c01: "Arabic_Jordan"
			, 3001: "Arabic_Lebanon"
			, 3401: "Arabic_Kuwait"
			, 3801: "Arabic_UAE"
			, 3c01: "Arabic_Bahrain"
			, 042c: "Azeri_Latin"
			, 082c: "Azeri_Cyrillic"
			, 042d: "Basque"
			, 0423: "Belarusian"
			, 0402: "Bulgarian"
			, 0403: "Catalan"
			, 0404: "Chinese_Taiwan"
			, 0804: "Chinese_PRC"
			, 0c04: "Chinese_Hong_Kong"
			, 1004: "Chinese_Singapore"
			, 1404: "Chinese_Macau"
			, 041a: "Croatian"
			, 0405: "Czech"
			, 0406: "Danish"
			, 0413: "Dutch_Standard"
			, 0813: "Dutch_Belgian"
			, 0409: "English_United_States"
			, 0809: "English_United_Kingdom"
			, 0c09: "English_Australian"
			, 1009: "English_Canadian"
			, 1409: "English_New_Zealand"
			, 1809: "English_Irish"
			, 1c09: "English_South_Africa"
			, 2009: "English_Jamaica"
			, 2409: "English_Caribbean"
			, 2809: "English_Belize"
			, 2c09: "English_Trinidad"
			, 3009: "English_Zimbabwe"
			, 3409: "English_Philippines"
			, 0425: "Estonian"
			, 040b: "Finnish"
			, 040c: "French_Standard"
			, 080c: "French_Belgian"
			, 0c0c: "French_Canadian"
			, 100c: "French_Swiss"
			, 140c: "French_Luxembourg"
			, 180c: "French_Monaco"
			, 0437: "Georgian"
			, 0407: "German_Standard"
			, 0807: "German_Swiss"
			, 0c07: "German_Austrian"
			, 1007: "German_Luxembourg"
			, 1407: "German_Liechtenstein"
			, 0408: "Greek"
			, 040d: "Hebrew"
			, 0439: "Hindi"
			, 040e: "Hungarian"
			, 040f: "Icelandic"
			, 0421: "Indonesian"
			, 0410: "Italian_Standard"
			, 0810: "Italian_Swiss"
			, 0411: "Japanese"
			, 0412: "Korean"
			, 0426: "Latvian"
			, 0427: "Lithuanian"
			, 042f: "Macedonian"
			, 043e: "Malay_Malaysia"
			, 083e: "Malay_Brunei_Darussalam"
			, 0414: "Norwegian_Bokmal"
			, 0814: "Norwegian_Nynorsk"
			, 0415: "Polish"
			, 0416: "Portuguese_Brazilian"
			, 0816: "Portuguese_Standard"
			, 0418: "Romanian"
			, 0419: "Russian"
			, 081a: "Serbian_Latin"
			, 0c1a: "Serbian_Cyrillic"
			, 041b: "Slovak"
			, 0424: "Slovenian"
			, 040a: "Spanish_Traditional_Sort"
			, 080a: "Spanish_Mexican"
			, 0c0a: "Spanish_Modern_Sort"
			, 100a: "Spanish_Guatemala"
			, 140a: "Spanish_Costa_Rica"
			, 180a: "Spanish_Panama"
			, 1c0a: "Spanish_Dominican_Republic"
			, 200a: "Spanish_Venezuela"
			, 240a: "Spanish_Colombia"
			, 280a: "Spanish_Peru"
			, 2c0a: "Spanish_Argentina"
			, 300a: "Spanish_Ecuador"
			, 340a: "Spanish_Chile"
			, 380a: "Spanish_Uruguay"
			, 3c0a: "Spanish_Paraguay"
			, 400a: "Spanish_Bolivia"
			, 440a: "Spanish_El_Salvador"
			, 480a: "Spanish_Honduras"
			, 4c0a: "Spanish_Nicaragua"
			, 500a: "Spanish_Puerto_Rico"
			, 0441: "Swahili"
			, 041d: "Swedish"
			, 081d: "Swedish_Finland"
			, 0449: "Tamil"
			, 041e: "Thai"
			, 041f: "Turkish"
			, 0422: "Ukrainian"
			, 0420: "Urdu"
			, 042a: "Vietnamese"}
   If(lang)
     Return LanguageLongnameArray[lang]
   Else Return LanguageLongnameArray[A_Language]
}
;-----------------------------------------------------------------
GetISOCodeA(lang) {
LanguageCodeArray := { af: "Afrikaans"
	, sq: "Albanisch"
	, am: "Amharisch"
	, ar: "Arabisch"
	, hy: "Armenisch"
	, az: "Aserbaidschanisch"
	, as: "Assamesisch"
	, ay: "Aymara"
	, bm: "Bambara"
	, eu: "Baskisch"
	, be: "Belarussisch"
	, bn: "Bengalisch"
	, bho: "Bhojpuri"
	, my: "Birmanisch"
	, bs: "Bosnisch"
	, bg: "Bulgarisch"
	, ceb: "Cebuano"
	, ny: "Chichewa"
	, zh-TW: "Chinesisch (traditionell)"
	, zh-CN: "Chinesisch (vereinfacht)"
	, da: "Dänisch"
	, de: "Deutsch"
	, dv: "Dhivehi"
	, doi: "Dogri"
	, en: "Englisch"
	, eo: "Esperanto"
	, et: "Estnisch"
	, ee: "Ewe"
	, tl: "Filipino"
	, fi: "Finnisch"
	, fr: "Französisch"
	, fy: "Friesisch"
	, gl: "Galizisch"
	, ka: "Georgisch"
	, el: "Griechisch"
	, gn: "Guarani"
	, gu: "Gujarati"
	, ht: "Haitianisch"
	, ha: "Hausa"
	, haw: "Hawaiisch"
	, iw: "Hebräisch"
	, hi: "Hindi"
	, hmn: "Hmong"
	, ig: "Igbo"
	, ilo: "Ilokano"
	, id: "Indonesisch"
	, ga: "Irisch"
	, is: "Isländisch"
	, it: "Italienisch"
	, ja: "Japanisch"
	, jw: "Javanisch"
	, yi: "Jiddisch"
	, kn: "Kannada"
	, kk: "Kasachisch"
	, ca: "Katalanisch"
	, km: "Khmer"
	, rw: "Kinyarwanda"
	, ky: "Kirgisisch"
	, gom: "Konkani"
	, ko: "Koreanisch"
	, co: "Korsisch"
	, kri: "Krio"
	, hr: "Kroatisch"
	, ku: "Kurdisch (Kurmandschi)"
	, ckb: "Kurdisch (Sorani)"
	, lo: "Lao"
	, la: "Latein"
	, lv: "Lettisch"
	, ln: "Lingala"
	, lt: "Litauisch"}
     Return LanguageCodeArray[lang]
}
;--------------------------------------------
GetISOCodeB(lang) {
LanguageCodeArray := {  lg: "Luganda"
	, lb: "Luxemburgisch"
	, mai: "Maithili"
	, mg: "Malagasy"
	, ml: "Malayalam"
	, ms: "Malaysisch"
	, mt: "Maltesisch"
	, mi: "Maori"
	, mr: "Marathi"
	, mk: "Mazedonisch"
	, mni-Mtei: "Meitei (Manipuri)"
	, lus: "Mizo"
	, mn: "Mongolisch"
	, ne: "Nepalesisch"
	, nl: "Niederländisch"
	, no: "Norwegisch"
	, or: "Odia (Oriya)"
	, om: "Oromo"
	, ps: "Paschtu"
	, fa: "Persisch"
	, pl: "Polnisch"
	, pt: "Portugiesisch"
	, pa: "Punjabi"
	, qu: "Quechua"
	, ro: "Rumänisch"
	, ru: "Russisch"
	, sm: "Samoanisch"
	, sa: "Sanskrit"
	, gd: "Schottisch-Gälisch"
	, sv: "Schwedisch"
	, nso: "Sepedi"
	, sr: "Serbisch"
	, st: "Sesotho"
	, sn: "Shona"
	, sd: "Sindhi"
	, si: "Singhalesisch"
	, sk: "Slowakisch"
	, sl: "Slowenisch"
	, so: "Somali"
	, es: "Spanisch"
	, su: "Sundanesisch"
	, sw: "Swahili"
	, tg: "Tadschikisch"
	, ta: "Tamil"
	, tt: "Tatarisch"
	, te: "Telugu"
	, th: "Thailändisch"
	, ti: "Tigrinya"
	, cs: "Tschechisch"
	, ts: "Tsonga"
	, tr: "Türkisch"
	, tk: "Turkmenisch"
	, ak: "Twi"
	, ug: "Uigurisch"
	, uk: "Ukrainisch"
	, hu: "Ungarisch"
	, ur: "Urdu"
	, uz: "Usbekisch"
	, vi: "Vietnamesisch"
	, cy: "Walisisch"
	, xh: "Xhosa"
	, yo: "Yoruba"
	, zu: "Zulu"}
     Return LanguageCodeArray[lang]
}
;------------------------------------------------------------------
GetGoogleLanguagesAndShortName:
GoogleLanguageCodes =
(
Afrikaans	af
Albanisch	sq
Amharisch	am
Arabisch	ar
Armenisch	hy
Aserbaidschanisch	az
Assamesisch	as
Aymara	ay
Bambara	bm
Baskisch	eu
Belarussisch	be
Bengalisch	bn
Bhojpuri	bho
Birmanisch	my
Bosnisch	bs
Bulgarisch	bg
Cebuano	ceb
Chichewa	ny
Chinesisch_traditionell	zh-TW
Chinesisch_vereinfacht	zh-CN
Dänisch	da
Deutsch	de
Dhivehi	dv
Dogri	doi
Englisch	en
Esperanto	eo
Estnisch	et
Ewe	ee
Filipino	tl
Finnisch	fi
Französisch	fr
Friesisch	fy
Galizisch	gl
Georgisch	ka
Griechisch	el
Guarani	gn
Gujarati	gu
Haitianisch	ht
Hausa	ha
Hawaiisch	haw
Hebräisch	iw
Hindi	hi
Hmong	hmn
Igbo	ig
Ilokano	ilo
Indonesisch	id
Irisch	ga
Isländisch	is
Italienisch	it
Japanisch	ja
Javanisch	jw
Jiddisch	yi
Kannada	kn
Kasachisch	kk
Katalanisch	ca
Khmer	km
Kinyarwanda	rw
Kirgisisch	ky
Konkani	gom
Koreanisch	ko
Korsisch	co
Krio	kri
Kroatisch	hr
Kurdisch_Kurmandschi	ku
Kurdisch_Sorani	ckb
Lao	lo
Latein	la
Lettisch	lv
Lingala	ln
Litauisch	lt
Luganda	lg
Luxemburgisch	lb
Maithili	mai
Malagasy	mg
Malayalam	ml
Malaysisch	ms
Maltesisch	mt
Maori	mi
Marathi	mr
Mazedonisch	mk
Meitei_Manipuri	mni-Mtei
Mizo	lus
Mongolisch	mn
Nepalesisch	ne
Niederländisch	nl
Norwegisch	no
Odia_Oriya	or
Oromo	om
Paschtu	ps
Persisch	fa
Polnisch	pl
Portugiesisch	pt
Punjabi	pa
Quechua	qu
Rumänisch	ro
Russisch	ru
Samoanisch	sm
Sanskrit	sa
Schottisch_Gälisch	gd
Schwedisch	sv
Sepedi	nso
Serbisch	sr
Sesotho	st
Shona	sn
Sindhi	sd
Singhalesisch	si
Slowakisch	sk
Slowenisch	sl
Somali	so
Spanisch	es
Sundanesisch	su
Swahili	sw
Tadschikisch	tg
Tamil	ta
Tatarisch	tt
Telugu	te
Thailändisch	th
Tigrinya	ti
Tschechisch	cs
Tsonga	ts
Türkisch	tr
Turkmenisch	tk
Twi	ak
Uigurisch	ug
Ukrainisch	uk
Ungarisch	hu
Urdu	ur
Usbekisch	uz
Vietnamesisch	vi
Walisisch	cy
Xhosa	xh
Yoruba	yo
Zulu	zu
)
;Chinesisch (traditionell)	zh-TW
;Chinesisch (vereinfacht)	zh-CN
;Kurdisch (Kurmandschi)	ku
;Kurdisch (Sorani)	ckb
;------------------------------------------------------------------
GetISOLanguageCodes:
LanguageCodes =
(
Afrikaans	Afrikaans	af	0436	Afrikaans
Albanian	Albanian	sq	041c	Albanisch
Algeria	Arabic_Algeria	ar	1401	Arabisch
Argentina	Spanish_Argentina	es	2c0a	Spanisch
Australian	English_Australian	en	0c09	Englisch
Austrian	German_Austrian	de	0c07	Deutsch
Azeri	Azeri_Cyrillic	az	082c	Aserbaidschanisch
Azeri	Azeri_Latin	az	042c	Aserbaidschanisch
Bahrain	Arabic_Bahrain	ar	3c01	Arabisch
Basque	Basque	eu	042d	Baskisch
Belarusian	Belarusian	be	0423	Belarussisch
Belgian	French_Belgian	fr	080c	Französisch
Belgian	Dutch_Belgian	nl	0813	Niederländisch
Belize	English_Belize	en	2809	Englisch
Bokmal	Norwegian_Bokmal	no	0414	Norwegisch
Bolivia	Spanish_Bolivia	es	400a	Spanisch
Brazilian	Portuguese_Brazilian	pt	0416	Portugiesisch
Brunei Darussalam	Malay_Brunei_Darussalam	ms	083e	Malaysisch
Bulgarian	Bulgarian	bg	0402	Bulgarisch
Canadian	English_Canadian	en	1009	Englisch
Canadian	French_Canadian	fr	0c0c	Französisch
Caribbean	English_Caribbean	en	2409	Englisch
Catalan	Catalan	ca	0403	Katalanisch
Chile	Spanish_Chile	es	340a	Spanisch
Colombia	Spanish_Colombia	es	240a	Spanisch
Costa Rica	Spanish_Costa_Rica	es	140a	Spanisch
Croatian	Croatian	hr	041a	Kroatisch
Czech	Czech	cs	0405	Tschechisch
Danish	Danish	da	0406	Dänisch
Dominican Republic	Spanish_Dominican_Republic	es	1c0a	Spanisch
Dutch	Dutch_Standard	nl	0413	Niederländisch
Ecuador	Spanish_Ecuador	es	300a	Spanisch
Egypt	Arabic_Egypt	ar	0c01	Arabisch
El Salvador	Spanish_El_Salvador	es	440a	Spanisch
Estonian	Estonian	et	0425	Estnisch
Finland	Swedish_Finland	sv	081d	Schwedisch
Finnish	Finnish	fi	040b	Finnisch
French	French_Standard	fr	040c	Französisch
Georgian	Georgian	ka	0437	Georgisch
German	German_Standard	de	0407	Deutsch
Greek	Greek	el	0408	Griechisch
Guatemala	Spanish_Guatemala	es	100a	Spanisch
Hebrew	Hebrew	iw	040d	Hebräisch
Hindi	Hindi	hi	0439	Hindi
Honduras	Spanish_Honduras	es	480a	Spanisch
Hong Kong	Chinese_Hong_Kong	zh-CN	0c04	Chinesisch (vereinfacht)
Hungarian	Hungarian	hu	040e	Ungarisch
Icelandic	Icelandic	is	040f	Isländisch
Indonesian	Indonesian	id	0421	Indonesisch
Iraq	Arabic_Iraq	ar	0801	Arabisch
Irish	English_Irish	en	1809	Englisch
Italian	Italian_Standard	it	0410	Italienisch
Jamaica	English_Jamaica	en	2009	Englisch
Japanese	Japanese	ja	0411	Japanisch
Jordan	Arabic_Jordan	ar	2c01	Arabisch
Korean	Korean	ko	0412	Koreanisch
Kuwait	Arabic_Kuwait	ar	3401	Arabisch
Latvian	Latvian	lv	0426	Lettisch
Lebanon	Arabic_Lebanon	ar	3001	Arabisch
Libya	Arabic_Libya	ar	1001	Arabisch
Liechtenstein	German_Liechtenstein	de	1407	Deutsch
Lithuanian	Lithuanian	lt	0427	Litauisch
Luxembourg	French_Luxembourg	fr	140c	Deutsch
Luxembourg	German_Luxembourg	de	1007	Französisch
Macau	Chinese_Macau	zh-CN	1404	Chinesisch (vereinfacht)
Macedonian	Macedonian	mk	042f	Mazedonisch
Malaysia	Malay_Malaysia	ms	043e	Malaysisch
Mexican	Spanish_Mexican	es	080a	Spanisch
Modern Sort	Spanish_Modern_Sort	es	0c0a	Spanisch
Monaco	French_Monaco	fr	180c	Französisch
Morocco	Arabic_Morocco	ar	1801	Arabisch
New Zealand	English_New_Zealand	en	1409	Englisch
Nicaragua	Spanish_Nicaragua	es	4c0a	Spanisch
Nynorsk	Norwegian_Nynorsk	no	0814	Norwegisch
Oman	Arabic_Oman	ar	2001	Arabisch
Panama	Spanish_Panama	es	180a	Spanisch
Paraguay	Spanish_Paraguay	es	3c0a	Spanisch
Peoples Republic of China	Chinese_PRC	zh-CN	0804	Chinesisch (vereinfacht)
Peru	Spanish_Peru	es	280a	Spanisch
Philippines	English_Philippines	en	3409	Englisch
Polish	Polish	pl	0415	Polnisch
Portuguese	Portuguese_Standard	pt	0816	Portugiesisch
Puerto Rico	Spanish_Puerto_Rico	es	500a	Spanisch
Romanian	Romanian	ro	0418	Rumänisch
Russian	Russian	ru	0419	Russisch
Saudi Arabia	Arabic_Saudi_Arabia	ar	0401	Arabisch
Serbian	Serbian_Cyrillic	sr	0c1a	Serbisch
Serbian Latin	Serbian_Latin	sr	081a	Serbisch
Singapore	Chinese_Singapore	zh-CN	1004	Chinesisch (vereinfacht)
Slovak	Slovak	sk	041b	Slowakisch
Slovenian	Slovenian	sl	0424	Slowenisch
South Africa	English_South_Africa	en	1c09	Englisch
Spanish	Spanish_Traditional_Sort	es	040a	Spanisch
Swahili	Swahili	sw	0441	Swahili
Swedish	Swedish	sv	041d	Schwedisch
Swiss	French_Swiss	fr	100c	Deutsch
Swiss	German_Swiss	de	0807	Französisch
Swiss	Italian_Swiss	it	0810	Italienisch
Syria	Arabic_Syria	ar	2801	Arabisch
Taiwan	Chinese_Taiwan	zh-CN	0404	Chinesisch (vereinfacht)
Tamil	Tamil	ta	0449	Tamil
Thai	Thai	th	041e	Thailändisch
Trinidad	English_Trinidad	en	2c09	Englisch
Tunisia	Arabic_Tunisia	ar	1c01	Arabisch
Turkish	Turkish	tr	041f	Türkisch
Ukrainian	Ukrainian	uk	0422	Ukrainisch
United Arab Emirates	Arabic_UAE	ar	3801	Arabisch
United Kingdom	English_United_Kingdom	en	0809	Englisch
United States	English_United_States	en	0409	Englisch
Urdu	Urdu	ur	0420	Urdu
Uruguay	Spanish_Uruguay	es	380a	Spanisch
Venezuela	Spanish_Venezuela	es	200a	Spanisch
Vietnamese	Vietnamese	vi	042a	Vietnamesisch
Yemen	Arabic_Yemen	ar	2401	Arabisch
Zimbabwe	English_Zimbabwe	en	3009	Englisch
)
return


GetWin10LanguagePacks:
Win10LanguagePacks =
(
Sprache	Name in Landessprache	Erforderliche Basissprache
Afrikaans	Afrikaans	English (United States)
Albanisch	Shqip	English (United States)
Amharisch	አማርኛ	English (United States) 
Arabisch	Arabisch	Jede Sprache
Armenisch	Հայերեն	English (United States)
Assamesisch	অসমীয়া	English (United States) 
Aserbaidschanisch (Lateinisch)	Azərbaycan	English (United States)
Bangla (Bangladesch)	বাংলা (ভারত)	English (United States) 
Bangla (Indien)	বাংলা (ভারত)	English (United States) 
Baskisch	Euskara	Spanisch (Spanien)
Belarussisch	беларуская мова	Russisch
Bosnisch (Lateinisch)	Bosanski	English (United States)
Bulgarisch	Bulgarisch	Jede Sprache
Katalanisch	Català	Spanisch (Spanien)
Zentralkurdisch (Arabisch)	سۆرانی	English (United States)
Cherokee (Cherokee)	ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ	English (United States)
Chinesisch (vereinfacht)	中文(简体)	Jede Sprache
Chinesisch (traditionell)	中文(繁體)	Jede Sprache
Kroatisch	Hrvatski	Jede Sprache
Tschechisch	Čeština	Jede Sprache
Dänisch	Dansk	Jede Sprache
Dari	درى	English (United States) 
Niederländisch	Nederlands	Jede Sprache
English	English	Jede Sprache
Estnisch	Eesti	Jede Sprache
Philippinisch	Philippinisch	English (United States) 
Finnisch	Suomi	Jede Sprache
Französisch	Français	Jede Sprache
Galicisch	Galego	Spanisch (Spanien)
Georgisch	ქართული	English (United States)
Deutsch	Deutsch	Jede Sprache
Griechisch	Griechisch	Jede Sprache
Gujarati	ગુજરાતી	English (United States) 
Haussa (Lateinisch)	Haussa	English (United States)
Hebräisch	עברית	Jede Sprache
Hindi	हिंदी	English (United States)
Ungarisch	Magyar	Jede Sprache
Isländisch	Íslenska	English (United States)
Igbo	Ndi Igbo	English (United States)
Indonesisch	Bahasa Indonesia	English (United States)
Irisch	Gaeilge	English (United States)
isiXhosa	isiXhosa	English (United States)
isi Zulu	isi Zulu	English (United States)
Italienisch	Italiano	Jede Sprache
Japanisch	日本語‫	Jede Sprache
Kannada	ಕನ್ನಡ	English (United States) 
Kasachisch	Қазақ	English (United States)
Khmer	ខ្មែរ	English (United States)
K'iche'	Qatzijob'al	Spanisch (Mexiko)
Kinyarwanda	Ikinyarwanda	English (United States)
Suaheli	Kiswahili	English (United States)
Konkani	कोंकणी	English (United States)
Koreanisch	한국어‫	Jede Sprache
Kirgisisch	Кыргыз	Russisch
Lettisch	Latviešu	Jede Sprache
Litauisch	Lietuvių	Jede Sprache
Luxemburgisch	Lëtzebuergesch	Französisch
Mazedonisch	македонски јазик	English (United States)
Malaiisch (Malaysia, Brunei und Singapur)	Bahasa Melayu	English (United States)
Malayalam	മലയാളം	English (United States)
Maltesisch	Malti	English (United States)
Maori	Te Reo Māori	English (United States)
Marathi	मराठी	English (United States)
Mongolisch (Kyrillisch)	Монгол хэл	English (United States)
Nepali	नेपाली	English (United States)
Norwegisch (Bokmål)	norsk (bokmål)	Jede Sprache
Norwegisch (Nynorsk)	Norsk (Nynorsk)	Norwegisch (Bokmål)
Odia	ଓଡିଆ	English (United States)
Persisch	فارسی	English (United States)
Polnisch	Polski	Jede Sprache
Portugiesisch (Brasilien)	Português	Jede Sprache
Portugiesisch (Portugal)	Português	Jede Sprache
Punjabi	ਪੰਜਾਬੀ	English (United States)
Punjabi (Arabisch)	پنجابی	English (United States)
Quechua	Runasimi	Spanisch (Mexiko)
Rumänisch	Română	Jede Sprache
Russisch	Русский	Jede Sprache
Schottisches Gälisch	Gàidhlig	English (United States)
Serbisch (Kyrillisch) – Bosnien und Herzegowina	српски	English (United States)
Serbisch (Kyrillisch, Serbien)	српски	Serbisch (Lateinisch)
Serbisch (Lateinisch)	Srpski	Jede Sprache
Sesotho sa Leboa	Sesotho sa Leboa	English (United States)
Setswana (Südafrika und Botsuana)	Tswana	English (United States) 
Sindhi (Arabisch)	سنڌي	English (United States)
Singhalesisch	සිංහල	English (United States)
Slowakisch	Slovenčina	Jede Sprache
Slowenisch	Slovenski	Jede Sprache
Spanisch	Español	Jede Sprache
Schwedisch	Svenska	Jede Sprache
Tadschikisch (Kyrillisch)	тоҷикӣ	Russisch
Tamil (Indien und Sri Lanka)	தமிழ்	English (United States)
Tatarisch	Татар	Russisch
Telugu	తెలుగు	English (United States)
Thailändisch	ไทย	Jede Sprache
Tigrinya (Äthiopien)	ትግርኛ	English (United States)
Türkisch	Türkçe	Jede Sprache
Turkmenisch	Türkmençe	Russisch
Ukrainisch	українська	Jede Sprache
Urdu	اردو	English (United States)
Uigurisch	ئۇيغۇرچە	Vereinfachtes Chinesisch (China)
Usbekisch (Lateinisch)	O'zbekcha	English (United States)
Valencianisch	Valencià	Spanisch (Spanien)
Vietnamesisch	Tiếng Việt	English (United States)
Walisisch	Cymraeg	English (United States)
Wolof	Wolof	Französisch
Yoruba	ede YorÙbá	English (United States)
)
return

GetWin11LanguagePacks:
Win11LanguagePacks =
(
Sprache	Name in Landessprache	Erforderliche Basissprache
Afrikaans	Afrikaans	English (United States)
Albanisch	Shqip	English (United States)
Amharisch	አማርኛ	English (United States) 
Arabisch	Arabisch	Jede Sprache
Armenisch	Հայերեն	English (United States)
Assamesisch	অসমীয়া	English (United States) 
Aserbaidschanisch (Lateinisch)	Azərbaycan	English (United States)
Bangla (Indien)	বাংলা (ভারত)	English (United States) 
Baskisch	Euskara	Spanisch (Spanien)
Belarussisch	беларуская мова	Russisch
Bosnisch (Lateinisch)	Bosanski	English (United States)
Bulgarisch	Bulgarisch	Jede Sprache
Katalanisch	Català	Spanisch (Spanien)
Cherokee (Cherokee)	ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ	English (United States)
Chinesisch (vereinfacht)	中文(简体)	Jede Sprache
Chinesisch (traditionell)	中文(繁體)	Jede Sprache
Kroatisch	Hrvatski	Jede Sprache
Tschechisch	Čeština	Jede Sprache
Dänisch	Dansk	Jede Sprache
Niederländisch	Nederlands	Jede Sprache
English	English	Jede Sprache
Estnisch	Eesti	Jede Sprache
Philippinisch	Philippinisch	English (United States) 
Finnisch	Suomi	Jede Sprache
Französisch	Français	Jede Sprache
Galicisch	Galego	Spanisch (Spanien)
Georgisch	ქართული	English (United States)
Deutsch	Deutsch	Jede Sprache
Griechisch	Griechisch	Jede Sprache
Gujarati	ગુજરાતી	English (United States) 
Hebräisch	עברית	Jede Sprache
Hindi	हिंदी	English (United States)
Ungarisch	Magyar	Jede Sprache
Isländisch	Íslenska	English (United States)
Indonesisch	Bahasa Indonesia	English (United States)
Irisch	Gaeilge	English (United States)
Italienisch	Italiano	Jede Sprache
Japanisch	日本語‫	Jede Sprache
Kannada	ಕನ್ನಡ	English (United States) 
Kasachisch	Қазақ	English (United States)
Khmer	ខ្មែរ	English (United States)
Konkani	कोंकणी	English (United States)
Koreanisch	한국어‫	Jede Sprache
Lettisch	Latviešu	Jede Sprache
Litauisch	Lietuvių	Jede Sprache
Luxemburgisch	Lëtzebuergesch	Französisch
Mazedonisch	македонски јазик	English (United States)
Malaiisch (Malaysia, Brunei und Singapur)	Bahasa Melayu	English (United States)
Malayalam	മലയാളം	English (United States)
Maltesisch	Malti	English (United States)
Maori	Te Reo Māori	English (United States)
Marathi	मराठी	English (United States)
Nepali	नेपाली	English (United States)
Norwegisch (Bokmål)	norsk (bokmål)	Jede Sprache
Norwegisch (Nynorsk)	Norsk (Nynorsk)	Norwegisch (Bokmål)
Odia	ଓଡିଆ	English (United States)
Persisch	فارسی	English (United States)
Polnisch	Polski	Jede Sprache
Portugiesisch (Brasilien)	Português	Jede Sprache
Portugiesisch (Portugal)	Português	Jede Sprache
Punjabi (Arabisch)	پنجابی	English (United States)
Quechua	Runasimi	Spanisch (Mexiko)
Rumänisch	Română	Jede Sprache
Russisch	Русский	Jede Sprache
Schottisches Gälisch	Gàidhlig	English (United States)
Serbisch (Kyrillisch) – Bosnien und Herzegowina	српски	English (United States)
Serbisch (Kyrillisch, Serbien)	српски	Serbisch (Lateinisch)
Serbisch (Lateinisch)	Srpski	Jede Sprache
Slowakisch	Slovenčina	Jede Sprache
Slowenisch	Slovenski	Jede Sprache
Spanisch	Español	Jede Sprache
Schwedisch	Svenska	Jede Sprache
Tamil (Indien und Sri Lanka)	தமிழ்	English (United States)
Tatarisch	Татар	Russisch
Telugu	తెలుగు	English (United States)
Thailändisch	ไทย	Jede Sprache
Türkisch	Türkçe	Jede Sprache
Ukrainisch	українська	Jede Sprache
Urdu	اردو	English (United States)
Uigurisch	ئۇيغۇرچە	Vereinfachtes Chinesisch (China)
Usbekisch (Lateinisch)	O'zbekcha	English (United States)
Valencianisch	Valencià	Spanisch (Spanien)
Vietnamesisch	Tiếng Việt	English (United States)
Walisisch	Cymraeg	English (United States)
)
;------------------------------------------------------------------
ocr(file, lang := "ShowAvailableLanguages")
{
thisOCR := ""
global translateCounter
   static OcrEngineStatics, OcrEngine, MaxDimension, LanguageFactory, Language, CurrentLanguage, BitmapDecoderStatics, GlobalizationPreferencesStatics
   if (OcrEngineStatics = "")
   {
      CreateClass("Windows.Globalization.Language", ILanguageFactory := "{9B0252AC-0C27-44F8-B792-9793FB66C63E}", LanguageFactory)
      CreateClass("Windows.Graphics.Imaging.BitmapDecoder", IBitmapDecoderStatics := "{438CCB26-BCEF-4E95-BAD6-23A822E58D01}", BitmapDecoderStatics)
      CreateClass("Windows.Media.Ocr.OcrEngine", IOcrEngineStatics := "{5BFFA85A-3384-3540-9940-699120D428A8}", OcrEngineStatics)
      DllCall(NumGet(NumGet(OcrEngineStatics+0)+6*A_PtrSize), "ptr", OcrEngineStatics, "uint*", MaxDimension)   ; MaxImageDimension
   }
   if (file = "ShowAvailableLanguages")
   {
      if (GlobalizationPreferencesStatics = "")
         CreateClass("Windows.System.UserProfile.GlobalizationPreferences", IGlobalizationPreferencesStatics := "{01BF4326-ED37-4E96-B0E9-C1340D1EA158}", GlobalizationPreferencesStatics)
      DllCall(NumGet(NumGet(GlobalizationPreferencesStatics+0)+9*A_PtrSize), "ptr", GlobalizationPreferencesStatics, "ptr*", LanguageList)   ; get_Languages
      DllCall(NumGet(NumGet(LanguageList+0)+7*A_PtrSize), "ptr", LanguageList, "int*", count)   ; count
      loop % count
      {
         DllCall(NumGet(NumGet(LanguageList+0)+6*A_PtrSize), "ptr", LanguageList, "int", A_Index-1, "ptr*", hString)   ; get_Item
         DllCall(NumGet(NumGet(LanguageFactory+0)+6*A_PtrSize), "ptr", LanguageFactory, "ptr", hString, "ptr*", LanguageTest)   ; CreateLanguage
         DllCall(NumGet(NumGet(OcrEngineStatics+0)+8*A_PtrSize), "ptr", OcrEngineStatics, "ptr", LanguageTest, "int*", bool)   ; IsLanguageSupported
         if (bool = 1)
         {
            DllCall(NumGet(NumGet(LanguageTest+0)+6*A_PtrSize), "ptr", LanguageTest, "ptr*", hText)
            buffer := DllCall("Combase.dll\WindowsGetStringRawBuffer", "ptr", hText, "uint*", length, "ptr")
            text .= StrGet(buffer, "UTF-16") "`n"
         }
         ObjRelease(LanguageTest)
      }
      ObjRelease(LanguageList)
      return text
   }
   if (lang != CurrentLanguage) or (lang = "FirstFromAvailableLanguages")
   {
      if (OcrEngine != "")
      {
         ObjRelease(OcrEngine)
         if (CurrentLanguage != "FirstFromAvailableLanguages")
            ObjRelease(Language)
      }
      if (lang = "FirstFromAvailableLanguages")
         DllCall(NumGet(NumGet(OcrEngineStatics+0)+10*A_PtrSize), "ptr", OcrEngineStatics, "ptr*", OcrEngine)   ; TryCreateFromUserProfileLanguages
      else
      {
         CreateHString(lang, hString)
         DllCall(NumGet(NumGet(LanguageFactory+0)+6*A_PtrSize), "ptr", LanguageFactory, "ptr", hString, "ptr*", Language)   ; CreateLanguage
         DeleteHString(hString)
         DllCall(NumGet(NumGet(OcrEngineStatics+0)+9*A_PtrSize), "ptr", OcrEngineStatics, ptr, Language, "ptr*", OcrEngine)   ; TryCreateFromLanguage
      }
      if (OcrEngine = 0)
      {
         msgbox Can not use language "%lang%" for OCR, please install language pack.
         ExitApp
      }
      CurrentLanguage := lang
   }
   if (SubStr(file, 2, 1) != ":")
      file := A_ScriptDir "\" file
   if !FileExist(file) or InStr(FileExist(file), "D")
   {
      msgbox File "%file%" does not exist
      ExitApp
   }
   VarSetCapacity(GUID, 16)
   DllCall("ole32\CLSIDFromString", "wstr", IID_RandomAccessStream := "{905A0FE1-BC53-11DF-8C49-001E4FC686DA}", "ptr", &GUID)
   DllCall("ShCore\CreateRandomAccessStreamOnFile", "wstr", file, "uint", Read := 0, "ptr", &GUID, "ptr*", IRandomAccessStream)
   DllCall(NumGet(NumGet(BitmapDecoderStatics+0)+14*A_PtrSize), "ptr", BitmapDecoderStatics, "ptr", IRandomAccessStream, "ptr*", BitmapDecoder)   ; CreateAsync
   WaitForAsync(BitmapDecoder)
   BitmapFrame := ComObjQuery(BitmapDecoder, IBitmapFrame := "{72A49A1C-8081-438D-91BC-94ECFC8185C6}")
   DllCall(NumGet(NumGet(BitmapFrame+0)+12*A_PtrSize), "ptr", BitmapFrame, "uint*", width)   ; get_PixelWidth
   DllCall(NumGet(NumGet(BitmapFrame+0)+13*A_PtrSize), "ptr", BitmapFrame, "uint*", height)   ; get_PixelHeight
   if (width > MaxDimension) or (height > MaxDimension)
   {
      msgbox Image is to big - %width%x%height%.`nIt should be maximum - %MaxDimension% pixels
      ExitApp
   }
   BitmapFrameWithSoftwareBitmap := ComObjQuery(BitmapDecoder, IBitmapFrameWithSoftwareBitmap := "{FE287C9A-420C-4963-87AD-691436E08383}")
   DllCall(NumGet(NumGet(BitmapFrameWithSoftwareBitmap+0)+6*A_PtrSize), "ptr", BitmapFrameWithSoftwareBitmap, "ptr*", SoftwareBitmap)   ; GetSoftwareBitmapAsync
   WaitForAsync(SoftwareBitmap)
   DllCall(NumGet(NumGet(OcrEngine+0)+6*A_PtrSize), "ptr", OcrEngine, ptr, SoftwareBitmap, "ptr*", OcrResult)   ; RecognizeAsync
   WaitForAsync(OcrResult)
   DllCall(NumGet(NumGet(OcrResult+0)+6*A_PtrSize), "ptr", OcrResult, "ptr*", LinesList)   ; get_Lines
   DllCall(NumGet(NumGet(LinesList+0)+7*A_PtrSize), "ptr", LinesList, "int*", count)   ; count
   WordArray := []
   loop % count
   {
      LineIndex := A_Index
      DllCall(NumGet(NumGet(LinesList+0)+6*A_PtrSize), "ptr", LinesList, "int", A_Index-1, "ptr*", OcrLine)
      DllCall(NumGet(NumGet(OcrLine+0)+6*A_PtrSize), "ptr", OcrLine, "ptr*", WordsList)   ; get_Words
      DllCall(NumGet(NumGet(WordsList+0)+7*A_PtrSize), "ptr", WordsList, "int*", WordsCount)   ; Words count
      loop % WordsCount
      {
         DllCall(NumGet(NumGet(WordsList+0)+6*A_PtrSize), "ptr", WordsList, "int", A_Index-1, "ptr*", OcrWord)
         VarSetCapacity(RECT, 16, 0)
         DllCall(NumGet(NumGet(OcrWord+0)+6*A_PtrSize), "ptr", OcrWord, "ptr", &RECT)   ; get_BoundingRect
         DllCall(NumGet(NumGet(OcrWord+0)+7*A_PtrSize), "ptr", OcrWord, "ptr*", hText)   ; get_Text
         buffer := DllCall("Combase.dll\WindowsGetStringRawBuffer", "ptr", hText, "uint*", length, "ptr")
         x := Round(NumGet(&RECT, 0, "float"))
         y := Round(NumGet(&RECT, 4, "float"))
         w := Round(NumGet(&RECT, 8, "float"))
         h := Round(NumGet(&RECT, 12, "float"))
         text := StrGet(buffer, "UTF-16")
         thisOCR .=  text A_Space ; *************************************************************************************
         WordArray[LineIndex, A_Index] := [x, y, w, h, text]
         ObjRelease(OcrWord)
      }
      ObjRelease(WordsList)
      ObjRelease(OcrLine)
   }
   Close := ComObjQuery(IRandomAccessStream, IClosable := "{30D5A829-7FA4-4026-83BB-D75BAE4EA99E}")
   DllCall(NumGet(NumGet(Close+0)+6*A_PtrSize), "ptr", Close)   ; Close
   ObjRelease(Close)
   Close := ComObjQuery(SoftwareBitmap, IClosable := "{30D5A829-7FA4-4026-83BB-D75BAE4EA99E}")
   DllCall(NumGet(NumGet(Close+0)+6*A_PtrSize), "ptr", Close)   ; Close
   ObjRelease(Close)
   ObjRelease(IRandomAccessStream)
   ObjRelease(BitmapDecoder)
   ObjRelease(BitmapFrame)
   ObjRelease(BitmapFrameWithSoftwareBitmap)
   ObjRelease(SoftwareBitmap)
   ObjRelease(OcrResult)
   ObjRelease(LinesList)

/*
clipOld := clipboardall
clipboard := thisOCR
FileAppend,% thisOCR "`n###########################################################`n" 
		, % (ANow "-OcrErgebnis.txt"), UTF-8
 gT()

FileAppend,% clipBoard  "`n###########################################################`n" 
		, % (ANow "-OcrTranslateErgebnis.txt"), UTF-8
clipBoard := clipOld
thisOCR := ""
*/

;	translateCounter++

   return thisOCR
;   return WordArray
}

; ----------------------------------------------------------------------------------------------------------------------
CreateClass(string, interface, ByRef Class)
{
   CreateHString(string, hString)
   VarSetCapacity(GUID, 16)
   DllCall("ole32\CLSIDFromString", "wstr", interface, "ptr", &GUID)
   result := DllCall("Combase.dll\RoGetActivationFactory", "ptr", hString, "ptr", &GUID, "ptr*", Class, "uint")
   if (result != 0)
   {
      if (result = 0x80004002)
         msgbox No such interface supported
      else if (result = 0x80040154)
         msgbox Class not registered
      else
         msgbox error: %result%
      ExitApp
   }
   DeleteHString(hString)
}
; ----------------------------------------------------------------------------------------------------------------------
CreateHString(string, ByRef hString)
{
    DllCall("Combase.dll\WindowsCreateString", "wstr", string, "uint", StrLen(string), "ptr*", hString)
}
; ----------------------------------------------------------------------------------------------------------------------
DeleteHString(hString)
{
   DllCall("Combase.dll\WindowsDeleteString", "ptr", hString)
}
; ----------------------------------------------------------------------------------------------------------------------
WaitForAsync(ByRef Object)
{
   AsyncInfo := ComObjQuery(Object, IAsyncInfo := "{00000036-0000-0000-C000-000000000046}")
   loop
   {
      DllCall(NumGet(NumGet(AsyncInfo+0)+7*A_PtrSize), "ptr", AsyncInfo, "uint*", status)   ; IAsyncInfo.Status
      if (status != 0)
      {
         if (status != 1)
         {
            DllCall(NumGet(NumGet(AsyncInfo+0)+8*A_PtrSize), "ptr", AsyncInfo, "uint*", ErrorCode)   ; IAsyncInfo.ErrorCode
            msgbox AsyncInfo status error: %ErrorCode%
            ExitApp
         }
         ObjRelease(AsyncInfo)
         break
      }
      sleep 10
   }
   DllCall(NumGet(NumGet(Object+0)+8*A_PtrSize), "ptr", Object, "ptr*", ObjectResult)   ; GetResults
   ObjRelease(Object)
   Object := ObjectResult
}

;##################################################
;https://www.autohotkey.com/boards/viewtopic.php?p=381405#p381405 by teadrinker 11. Feb 2021 16:08
/*
text =
(
@teadrinker - I've used your script a minute ago (and now it looks that I've got blocked :shh:) so, time to ask ...
Has your updated script taken the before mentioned condition already into account? I thought about to translate the transcription of YouTube videos so people from abroad will have a chance to better follow its (German) speaker. Higher translation quality would shrink the time of necessarry corrections.
)
arr := SplitText(text, 200)
for k, v in arr
   MsgBox, % v
*/

SplitText(text, max := 5000) {
   chunks := [], text .= ".", pos := 1
   Loop {
      for k, v in ["\.", "!", "\?", ";", ",", ":", "\(", "\)", " ", "$"]
         RegExMatch(SubStr(text, pos, max), "sO).+" . v . "+", m)
      until m.Len
      chunks.Push(m[0])
      pos += m.Len
   } until pos > StrLen(text)
   last := chunks.Pop()
   chunks.Push( SubStr(last, 1, -1) )
   Return chunks
}
; -------------------------------------------------------
;##################################################
;https://www.autohotkey.com/boards/viewtopic.php?p=381432#p381432 by bobo 11. Feb 2021 20:40

;SetWorkingDir,% A_ScriptDir  
;#Include GoogleTranslate().ahk		; Download: https://www.autohotkey.com/boards/viewtopic.php?t=63835 by teadrinker

; gT("input.txt","output.txt")		; eingabe aus datei, ausgabe in datei
; gT("input.txt")			; eingabe aus datei, ausgabe in zwischenablage
; gT()					; eingabe aus zwischenablage, ausgabe in zwischenablage

gT(inFile:="",outFile:="") {
global thisISOLanguageCode
	content := (inFile != "") ? fRead(inFile) : clip()			; auslesen der datei, oder CTRL+C in zwischenablage
	chars := StrSplit(content)						; content in einzelne Zeichen zerlegen
	GetISOLanguageCode := GetISOLanguageCode()
	Loop % chars.count() {
		if	(mod(A_Index,5000) = 0 || A_Index = chars.count()) {	; sobald textblock 5K zeichen erreicht, oder Anzahl restzeichen enthält ...
			trl .= GoogleTranslate(str,"auto",thisISOLanguageCode)	; textblock-übergabe an Google-Translate. Ergebnis konkatenieren.
;			trl .= GoogleTranslate(str,"auto",GetISOLanguageCode())	; textblock-übergabe an Google-Translate. Ergebnis verketten.
			str:=""							; textblock leeren
			}
		Else 
			str .= chars[A_Index]					; textblock befüllen
		}
;	SoundBeep								; feierabendbiersignalindikator
;	Return clipboard := (outFile != "") ? fWrite(outFile,trl) : trl		; schreiben in datei, oder ausgabe in zwischenablage
	Return (outFile != "") ? fWrite(outFile,trl) : trl			; schreiben in datei, oder ausgabe in zwischenablage
	}


clip() {
	Send ^c
	ClipWait
	Return clipboard
	}
fRead(inFile) {
	FileRead, content,% inFile
	Return content
	}
fWrite(outFile,trl) {
	response := (trl = "") ? "Translation failed" : "File created." 
	FileAppend,% trl,% outFile, UTF-8					; https://www.autohotkey.com/docs/commands/FileEncoding.htm
	Return response
	} 
;##################################################
; https://www.autohotkey.com/boards/viewtopic.php?t=63835 by teadrinker
;MsgBox, % GoogleTranslate("今日の天気はとても良いです")
;MsgBox, % GoogleTranslate("Hello, World!", "en", "ru")

GoogleTranslate(str, from := "auto", to := "de") {
   static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")

global   	translateCounter
translateCounter++
   json := SendRequest(JS, str, to, from, proxy := "")
   oJSON := JS.("(" . json . ")")

	thisXXX :=  	GetISOCodeA(to) 
			? GetISOCodeA(to) 
			: GetISOCodeB(to) 
			. a_space to

;	fileAppend,% BeautifyJson(json),% a_tickcount a_space thisXXX ".json", UTF-8
	global AhkObj := JsonToAHK(json)
	global thisjson := json

   if !IsObject(oJSON[1]) {
      Loop % oJSON[0].length
         trans .= oJSON[0][A_Index - 1][0]
   }
   else {
      MainTransText := oJSON[0][0][0]
      Loop % oJSON[1].length {
         trans .= "`n+"
         obj := oJSON[1][A_Index-1][1]
         Loop % obj.length {
            txt := obj[A_Index - 1]
            trans .= (MainTransText = txt ? "" : "`n" txt)
         }
      }
   }
   if !IsObject(oJSON[1])
      MainTransText := trans := Trim(trans, ",+`n ")
   else
      trans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")

   from := oJSON[2]
   trans := Trim(trans, ",+`n ")
   Return trans
}

SendRequest(JS, str, tl, sl, proxy) {
   static http
   ComObjError(false)
   if !http
   {
      http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
      ( proxy && http.SetProxy(2, proxy) )
      http.open("GET", "https://translate.google.com", true)
      http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
      http.send()
      http.WaitForResponse(-1)
   }
   http.open("POST", "https://translate.googleapis.com/translate_a/single?client=gtx"
                ; or "https://clients5.google.com/translate_a/t?client=dict-chrome-ex"
      . "&sl=" . sl . "&tl=" . tl . "&hl=" . tl
      . "&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=0&ssel=0&tsel=0&pc=1&kc=1"
      . "&tk=" . JS.("tk").(str), true)

   http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
   http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
   http.send("q=" . URIEncode(str))
   http.WaitForResponse(-1)
   Return http.responsetext
}

URIEncode(str, encoding := "UTF-8")  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &var, encoding)

   while code := NumGet(Var, A_Index - 1, "UChar")  {
      bool := (code > 0x7F || code < 0x30 || code = 0x3D)
      UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)
   }
   Return UrlStr
}

GetJScript()
{
   script =
   (
      var TKK = ((function() {
        var a = 561666268;
        var b = 1526272306;
        return 406398 + '.' + (a + b);
      })());

      function b(a, b) {
        for (var d = 0; d < b.length - 2; d += 3) {
            var c = b.charAt(d + 2),
                c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),
                c = "+" == b.charAt(d + 1) ? a >>> c : a << c;
            a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c
        }
        return a
      }

      function tk(a) {
          for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {
              var c = a.charCodeAt(f);
              128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ?
              (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240,
              g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
          }
          a = h;
          for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");
          a = b(a, "+-3^+b+-f");
          a ^= Number(e[1]) || 0;
          0 > a && (a = (a & 2147483647) + 2147483648);
          a `%= 1E6;
          return a.toString() + "." + (a ^ h)
      }
   )
   Return script
}

CreateScriptObj() {
   static doc, JS, _JS
   if !doc {
      doc := ComObjCreate("htmlfile")
      doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
      JS := doc.parentWindow
      if (doc.documentMode < 9)
         JS.execScript()
      _JS := ObjBindMethod(JS, "eval")
   }
   Return _JS
}
;#####################################################################
JsonToAHK(json, rec := false) {
   static doc := ComObjCreate("htmlfile")
         , __ := doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
         , JS := doc.parentWindow
   if !rec
      obj := %A_ThisFunc%(JS.eval("(" . json . ")"), true)
   else if !IsObject(json)
      obj := json
   else if JS.Object.prototype.toString.call(json) == "[object Array]" {
      obj := []
      Loop % json.length
         obj.Push( %A_ThisFunc%(json[A_Index - 1], true) )
   }
   else {
      obj := {}
      keys := JS.Object.keys(json)
      Loop % keys.length {
         k := keys[A_Index - 1]
         obj[k] := %A_ThisFunc%(json[k], true)
      }
   }

   Return obj
}
;##########################################################################

; https://www.autohotkey.com/boards/viewtopic.php?p=353444#p353444 by teadrinker
;MsgBox, % BeautifyJson(json)

BeautifyJson(json, indent := "    ") {
   static Doc, JS
   if !Doc {
      Doc := ComObjCreate("htmlfile")
      Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
      JS := Doc.parentWindow
   }
  try Return JS.eval("JSON.stringify(" . json . ",'','" . indent . "')")
}

;----------------------------------------------------------------------




Month(thisMonth) {
		Month := strSplit("Jan,Feb,Mrz,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez",",")
		return Month[thisMonth]
}

ConvertToMilliseconds(HHMMSSMS)
{
   Sekunden := A_YYYY . "0101" . StrReplace(SubStr(HHMMSSMS, 1, 8), ":")
   Sekunden -= A_YYYY, S
   Return (Sekunden * 1000) + SubStr(HHMMSSMS, 10)
}

ConvertToHHMMSSMS(Millisekunden)
{
   Zeitstempel := A_YYYY ; nur der Deutlichkeit halber, AHK rechnet auch mit leeren Variablen
   Zeitstempel += % (Millisekunden // 1000), S
   FormatTime, HHMMSS, %Zeitstempel%, HH:mm:ss
   Return (HHMMSS . Format(",{:03}", Mod(Millisekunden, 1000)))
}


;#####################################################################################################
;------------
; zoomfactor:=((A_ScreenWidth/1920)*(96/A_ScreenDPI))
; wa:=A_screenwidth,ha:=A_screenHeight,xx:=100

thisZoomFactorFontVerdanaPro_(factor) {
return (factor*((A_ScreenWidth/1920)*(96/A_ScreenDPI))) " , Verdana Pro"
}

thisZoomFactorBold(factor) {
global
return "s" (factor*zoomfactor) " , Comic Sans MS bold"
}

thisZoomFactorNormal(factor) {
global
;return "s" 10 " , Terminal " 
return "s" (factor*zoomfactor) " , Comic Sans MS" 
}

thisZoomFactorFontVerdanaPro(factor) { ; ab win 10
global
return "s" (factor*zoomfactor) " , Verdana Pro" 
}

thisX(factor) {
global
return	" x" (wa*factor)/xx
}

thisY(factor) {
global
return	" y" (ha*factor)/xx 
}

thisW(factor) {
global
return	" w" (wa*factor)/xx
}

thisH(factor) {
global
return	" h" (ha*factor)/xx 
}


getNationalFlags: ; wiki https://de.wikipedia.org/wiki/Liste_der_Nationalflaggen
de := "https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Flag_of_Germany.svg/800px-Flag_of_Germany.svg.png"
fr := "https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Flag_of_France_%281794%E2%80%931815%2C_1830%E2%80%931974%29.svg/800px-Flag_of_France_%281794%E2%80%931815%2C_1830%E2%80%931974%29.svg.png"
pt := "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Flag_of_Portugal.svg/600px-Flag_of_Portugal.svg.png"
es := "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Flag_of_Spain.svg/750px-Flag_of_Spain.svg.png"
en := "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Flag_of_the_United_Kingdom_%283-5%29.svg/800px-Flag_of_the_United_Kingdom_%283-5%29.svg.png"
return
;------------
watchfiles:
return
	DetectHiddenWindows, On
	DetectHiddenText, On
	thisAktiv := 1
	Loop Files,% a_scriptdir  "\*.*"
	{
	if A_LoopFileName contains jpg,png ; && thisAktiv
	{
	settimer, watchfiles, off
	WinWait, Batch OCR & Translate DEV.012, Start OCR && Transla
	IfWinNotActive, Batch OCR & Translate DEV.012, Start OCR && Transla, WinActivate, Batch OCR & Translate DEV.012, Start OCR && Transla
	WinWaitActive, Batch OCR & Translate DEV.012, Start OCR && Transla
	}}
return

	;SetTimer,UPDATEDSCRIPT,500
	UPDATEDSCRIPT(save := 1) {
	FileGetAttrib,attribs,%A_ScriptFullPath%
		IfInString,attribs,A	
		{
		FileSetAttrib,-A,%A_ScriptFullPath%
		SplashTextOn,,,Updated script,
		Sleep,1500 
			if save
			{
			If !FileExist(A_ScriptDir "\save\")
			FileCreateDir,% A_ScriptDir "\save\"
			ANow := A_DD "." Month(A_MM) "." a_YYYY " " A_Hour "-" A_Min "-" A_Sec "-" A_MSec
			FileCopy, % A_ScriptFullPath, % A_ScriptDir "\save\" A_ScriptName " save " ANow " .ahk"
			}
		Reload             
		}
	}
Last edited by effel on 02 Mar 2024, 14:33, edited 6 times in total.
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

25 Feb 2024, 08:34

@effel danke , wieder ein grossartiger Skript
kurzer Versuch mit 3 Bildern
1- tamilisch > chinesisch erkannt , nichts angezeigt
2- isländisch erkannt , lediglich die isländische Buchstaben falsch dargestellt, dadurch auch deutsche Übersetzung teilweise nicht korrekt
3- ukrainisch > kyrillische Zeichen nicht erkannt ( erkannt de )

Erkennt wahrscheinlich nur lateinische Schrift .. (?) . ( Skript ist als UTF-8 mit BOM gespeichert )


===================================================================
Page: 1

----------------
Page: 2
Léan er komin ab kveöa burt snj6inn, ab kveöa burt leiÖindin, Fad getur hün. Hün hefur sagt mér ab senn komi sp6inn, sölskin f dali og b16mstur f tün.
Hün hefur sagt mér til syndanna minna, ég sofi of mikiÖ og vinni ekki h6t. Hün hefur sagt mér\aö vakna og vinna og vonglaÖur taka nü sumrinu mote
----------------
Page: 3
y PO Bnaae l.ue OAVIH A-50, 'iM AOBeaeTbCR npnnhHATh ginOA060Be qepryBaHHR - 6yaaH0B
----------------
effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

25 Feb 2024, 20:54

garry wrote:
25 Feb 2024, 08:34
kurzer Versuch mit 3 Bildern
Hallo @garry , danke fürs testen.

Es wird evt. daran liegen, das die OCR() Funktion hier das Problem ist.

Alles wird zuerst von OCR() bearbeitet und das Ergebnis wird dann von Google übersetzt.

Wenn du z.B. ukrainisch übersetzen möchtest, muss der ukrainische Text direkt an Google zum übersetzen übergeben werden. Dafür code ich eine Möglichkeit ein. Mal schauen ob das dann funktioniert.

Ich habe bei der OCR() Funktion eine andere Länderkennung eingegeben und bekomme eine Fehlermeldung, dass ein Sprachpaket nicht installiert ist. Google zeigt mir eine Adresse, https://support.microsoft.com/de-de/windows/sprachpakete-f%C3%BCr-windows-a5094319-a92d-18de-5b53-1cfc697cfca8 wo bzw. wie ich sie installieren kann. Das werde ich mal versuchen

Code: Select all

	try Words := thisOCR := ocr(ALoopField, "de")
;	try Words := thisOCR := ocr(ALoopField, "en")
effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

25 Feb 2024, 21:42

Ich habe das lettische Sprachpaket installiert, mir dann von der BING KI eine Kurzgeschichte geben lassen und das ist mein Ergebnis, ohne das ich die OCR Funktion verändert habe, sie war noch auf de eingestellt.


Natürlich, hier ist eine kurze Geschichte auf Lettisch:

*Zelta zivs*

Reiz senos laikos, pie jūras krasta dzīvoja vecs zvejnieks ar savu sievu. Katru dienu viņš izgāja jūrā makšķerēt, bet vienmēr atgriezās ar tukšām rokām. Vienu dienu, izmetot tīklu, viņš noķēra zelta zivi. Zivs lūdza zvejnieku sevi atbrīvot, apsolot izpildīt trīs viņa vēlēšanās.

Zvejnieks bija laipns un atbrīvoja zivi, neprasot neko pretī. Atgriežoties mājās un pastāstot sievai par notikušo, viņa kļuva dusmīga un aizrādīja, ka viņam vajadzēja lūgt zivij bagātību. Nākamajā dienā zvejnieks atkal satika zelta zivi un lūdza mājai jaunu jumtu. Zivs piekrita, un, kad zvejnieks atgriezās mājās, viņa māja bija ar jaunu jumtu.

Tomēr sieva nebija apmierināta un sūtīja vīru atpakaļ pie zivs, lai lūgtu pilīti. Zvejnieks to izdarīja, un zivs arī šo vēlēšanos izpildīja. Bet sieva vēlējās vairāk un vairāk, līdz viņa kļuva alkatīga un lūdza kļūt par jūras karalieni.

Zvejnieks, lai gan nevēlējās, devās pie zivs pēdējo reizi. Zivs, redzot viņa skumjas, teica: "Dodies mājās, un viss būs tā, kā bija." Kad zvejnieks atgriezās, viņš atrada savu veco māju un saprata, ka patiesa laime nav bagātībā, bet gan mīlestībā un apmierinātībā ar to, kas ir.

Un tā viņi dzīvoja ilgi un laimīgi, nekad vairs nekārojot vairāk, nekā tiem bija nepieciešams.

---

Es ceru, ka šī stāsta morāle sniedz jums kādu iedvesmu vai mācību. Vai ir kaut kas cits, ar ko varu palīdzēt?



02_26_24 @3_33_38.PNG
02_26_24 @3_33_38.PNG (96.22 KiB) Viewed 484 times
02_26_24 @3_35_40.PNG
02_26_24 @3_35_40.PNG (65.99 KiB) Viewed 484 times
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

28 Feb 2024, 05:18

@effel , danke , funktioniert sehr gut, schnell und einfach mit lateinischer Schrift , kann es gut gebrauchen .
für andere Schriftarten > Google-Lens : https://www.google.com/?olud
Betr. die 3 grossen Felder ,LV > OCR Files / Edit1 /Edit2 > Edit2 ist rechts abgeschnitten, GUI-Grösse ist OK. Möchte die Breite von LV kleiner machen und bei Edit1 / Edit2 > x und w verändern sodass Edit2 im GUI Platz hat .
( Bsp > GuiControl, 1: MoveDraw, SourceFiles, % thisX(1.0) thisY(10.0) thisW(20.0) thisH(34.0) )
Benütze 4K Monitor, GUI Grösse und alles andere stimmt .
effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

28 Feb 2024, 14:09

garry wrote:
28 Feb 2024, 05:18
Betr. die 3 grossen Felder ,LV > OCR Files / Edit1 /Edit2 > Edit2 ist rechts abgeschnittenonitor, GUI Grösse und alles andere stimmt
Hallo @garry , sendest du bitte einen Screenshot?
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

28 Feb 2024, 15:32

GUI Grösse ist OK , weiss nicht wie ich x und w von den 3 grossen Feldern einstellen soll ( LV, Edit1, Edit2 ) , alles andere OK , ausgenommen die einzelnen character
--
-- Original Text Beispiel :
A recomendação é do relator especial da ONU para os defensores do ambiente, Michel Forst, que divulgou esta quarta-feira um retrato da repressão e criminalização do protesto ambiental pacífico e da desobediência civil observadas pelo perito em alguns países europeus, incluindo Portugal, que são signatários da Convenção de Aarhus.
--
OCR_20240228214130.jpg
OCR_20240228214130.jpg (465.8 KiB) Viewed 411 times
effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

29 Feb 2024, 01:27

Hallo @garry , mein Versuch an deinen 4K Monitor anzupassen.

Ich habe das Script oben upgedatet und hoffe dass das Layout passt. Ich kann es nicht so gut erkennen, dein Screenshot sieht so aus, dass die drei Elemente unten abgeschnitten sind.

Die Schriftgröße kannst du auch einheitlich mit thisZoomFactorFontVerdanaProDefault := 11 anpassen.

Wenn es nicht passt kannst du mal versuchen diese Werte zu verändern.

Code: Select all

 	GuiControl, 1:  MoveDraw, 		SourceFiles, 	% thisX(1.0) thisY(10.0) thisW(15.0) thisH(34.0)  ;  default
	GuiControl, 1:  MoveDraw, 		edit2, 			% thisX(17.0) thisY(10.0) thisW(15.0) thisH(34.0) ;  default
	GuiControl, 1:  MoveDraw, 		edit1, 			% thisX(33.0) thisY(10.0) thisW(15.0) thisH(34.0) ;  default

Nach jedem speichern wird das Programm neu gestartet und die alte Version liegt als Kopie im Verzeichnis \save. Das ist für mich sinnvoll, wenn ich mal Fehler mache, kann ich so immer auf die letzten Versionen zugreifen, das hat mich schon oft gerettet.



Auf meinem Monitor (1920x1080) sieht es so aus:

1e118ec5a1b4e833d82a4c87cb668e17e30549a0.jpg
1e118ec5a1b4e833d82a4c87cb668e17e30549a0.jpg (178.52 KiB) Viewed 401 times


Auf dem Laptop (1366x768) meiner Freundin so:

20240229024540.jpg
20240229024540.jpg (38.53 KiB) Viewed 401 times

Für den Laptop habe ich den Code soweit gekürzt, das nur die GUI Elemente übrig blieben, auf ihrem Win 7 Rechner läuft es leider nicht
Spoiler
Last edited by effel on 29 Feb 2024, 12:18, edited 1 time in total.
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

29 Feb 2024, 04:26

Gui-grösse alles korrekt ( das letztemal hatte ich am Bild den unteren Teil abgeschnitten )
es hat mit Skalierung zu tun , jetzt beim neusten WIN-update 200% / vorher war 150% (?) . Bei 100% ist gut
=================================================================
EDIT : dein vorletztes Skript OK , added > Gui,1: -dpiscale
Skript erscheint nicht voller Bildschirmgrösse in ca Mitte screen , alles OK
( siehe Bild unten )
=================================================================


Dieses Beispiel funktioniert gut (Position unten links ) , lediglich Probleme mit Fontsize-Berechnung ... FS hier gebastelt , nicht berechnet ...
Font-Size kann denn Problem machen mit z.B. Gui-button / Gui-Edit > Höhe und Breite


Hatte movedraw nicht verwendet , lediglich :

Code: Select all

WA:=A_screenwidth,HA:=A_screenheight,xx:=100
Gui,2: -dpiscale 
x:=(WA*0.5)/xx, y:=(ha*91)/xx,w:=(wa*30)/xx,h:=(ha*3.5)/xx   ;- GUI  x,y,w,h
Gui,2: Show,x%x% y%y% w%w% h%h%
;-- Schaltuhr von-bis > Guten morgen , etc ...

Code: Select all

#NoEnv                        ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn                         ; Enable warnings to assist with detecting common errors.
SendMode Input                ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%   ; Ensures a consistent starting directory.
#Singleinstance,force
;-
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
Gui,2: -dpiscale +AlwaysOnTop -Caption +Border
Gui,2:Color,Black, 
;-  change fontsize ( this is not correct )
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa:=3840)
 Gui,2:Font,s11 cYellow q4,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa:=1920)
 Gui,2:Font,s9 cYellow, Lucida Console
else
 Gui,2:Font,s7 cYellow, Lucida Console
;=============================================================

ac:=600,ad:=1059,ae:=1100,af:=1659,ag:=1700,ah:=2100        ;- Schaltuhr von-bis
x:=(WA*1)/xx,y:=(ha*1)/xx,w:=(wa*8)/xx
Gui,2: Add, Text,x%x% y%y% w%w% vD1  , 
x:=(WA*9.5)/xx,y:=(ha*1)/xx,w:=(wa*20)/xx
Gui,2: Add, Text,x%x% y%y% w%w% vD2  ,
x:=(WA*0.5)/xx, y:=(ha*91)/xx,w:=(wa*30)/xx,h:=(ha*3.5)/xx   ;- GUI позиция x,y,w,h
Gui,2: Show,x%x% y%y% w%w% h%h%
SetTimer,A1,1000
gosub,a1
Return
;----
A1:
T:= A_Hour . A_Min
if ((T>=ac) and (T<=ad))           ;-  if between 600-1059
 tx:="Доброе утро"                 ;->   good morning
else if ((T>=ae) and (T<=af))      ;-  if between 1100-1659
 tx:="Добрый день"                 ;->   good day
else if ((T>=ag) and (T<=ah))      ;-  if between 1700-2100
 tx:="Добрый вечер"                ;->   good evening"
else                               ;-  else
 tx:="Доброй ночи"                 ;->   good night"
GuiControl,2:, D1,%tx% >
;-
FormatTime,ru,L0x419, dddd  MMMM     yyyy-MM-dd  HH:mm:ss
GuiControl,2:, D2,%ru%
Return
;-----
2Guiclose:
Exitapp
;-----------
esc::exitapp
;===========
20240229100942_screenshot.png
20240229100942_screenshot.png (215.61 KiB) Viewed 392 times
EDIT : dein vorletztes Skript OK , added > Gui,1: -dpiscale
20240229142806_screenshot.jpg
20240229142806_screenshot.jpg (449.78 KiB) Viewed 376 times
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

29 Feb 2024, 08:38

EDIT > ALLES OK , getestet mit 4K und FullHD
=================================================================
EDIT : dein vorletztes Skript OK , added > Gui,1: -dpiscale
Skript erscheint nicht voller Bildschirmgrösse in ca Mitte screen , alles OK
( siehe letztes Bild unten )
EDIT :
Variable xx > GUI hat die volle Breite wenn ich den Wert auf 63 ändere ( statt 100 )
=================================================================

Du hast wahrscheinlich Fontsize alles richtig berechnet , dies war bei meinem Skript nicht der Fall
;-
noch dies gefunden , es geht um Variable > xx , bei mir hat denn GUI die volle Breite wenn ich Wert auf 63 ändere ( statt 100 )

Code: Select all

;- am Anfang :
 Gui,1: -dpiscale
wa:=A_screenwidth,ha:=A_screenHeight,xx:=63  ;- geändert von 100 auf 63 , dadurch habe ich volle screen-breite , lediglich Höhe ist ca 70%, GUI erscheint ca in der Mitte vom Bildschirm (Rand oben und unten )
;---
thisX(factor) {
global
return	" x" (wa*factor)/xx
}
und added noch dies , GUI volle Grösse , ALLES OK , getestet mit 4K und FullHD

Code: Select all

xxz:=100
x:=(WA*0)/xxz, y:=(ha*.1)/xxz,w:=(wa*99.9)/xxz,h:=(ha*93)/xxz   ;- GUI  x,y,w,h
Gui,1: Show,x%x% y%y% w%w% h%h%,,% "Batch OCR & Translate " strReplace((substr(a_scriptname,-10)),".ahk")
	;Gui, 1: Show,x0 ,% "Batch OCR & Translate " strReplace((substr(a_scriptname,-10)),".ahk")
ganzer Skript :

Code: Select all


;- https://www.autohotkey.com/boards/viewtopic.php?f=9&t=126502

;- GETESTET mit 4K und FullHD 
;===============================

	#SingleInstance force
	;#NoTrayIcon
	#NoEnv
	#Persistent
;	FileEncoding, UTF-8
	SetBatchLines, -1
	SetTitleMatchMode, 2
	SetKeyDelay 20
	SetWorkingDir, %A_ScriptDir%
	ANow := A_DD "." Month(A_MM) "." a_YYYY " " A_Hour "-" A_Min "-" A_Sec "-" A_MSec
	If !FileExist(A_ScriptDir "\save\")
	FileCreateDir,% A_ScriptDir "\save\"
	FileCopy, % A_ScriptFullPath, % A_ScriptDir "\save\" A_ScriptName " save " ANow " .ahk"
	zoomfactor:=((A_ScreenWidth/1920)*(96/A_ScreenDPI))
	wa:=A_screenwidth,ha:=A_screenHeight,xx:=63              ;- <<<<<<<<
	gosub, GetISOLanguageCodes
	gosub, GetGoogleLanguagesAndShortName
	thisISOLanguageCode 	:= GetISOLanguageCode()
	thisISOLongnameCode 	:= GetISOLongnameCode()
	onlyOne := 1
	global comboSelect   
	;===================
	Gui,1: default
	Gui,1: -dpiscale
	;===================
	debug#1 := 0
	if debug#1
	Gui, 1: Add, Text, 0x1000 vtext1 thisX(20) thisY(0) w600 h20 ;thisW(60.0) ; r2 ; ohne r2 funktioniert MoveDraw nicht
	else
	;Gui, 1: Add, Text, vtext1 thisX(20) thisY(0) w600 h20 ;thisW(60.0) ; r2 ; ohne r2 funktioniert MoveDraw nicht
	Gui, 1: Add, Text,% "vtext1 r1"
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(15.0) ; 
	GuiControl, 1:  Font, 			text1
	GuiControl, 1:  MoveDraw, 		text1, 	% thisX(20) thisY(0) thisW(35.0) thisH(3.0) ;  default
	GuiControl, 1: 	+cBlue, 		text1
;	GuiControl, 1: 	+BackgroundRED, 	text1
	if debug#1
	GuiControl, 1: ,  			text1, 	%a_Space% test 1234 5678 90ab cdef ghij klmn opqr stuv wxyz
	GuiControl, 1:  show, 			text1
;	GuiControl, 1:  hide, 			text1
;	GuiControl, 1:  focus, 			text1
;	GuiControl, 1:  disable, 		text1
;	GuiControl, 1:  enable, 		text1
	Gui, 1: Add, Tab3, x10 y50 Buttons vthisTab3 ; -0x107	Hidden
			 , OCR && Translate|ISOLanguageCodes|json
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			thisTab3
; 	GuiControl, 1:  MoveDraw, 		thisTab3, 	% thisX(22.0) thisY(10.0) thisW(20.0) thisH(34.0) ;  default
; 	GuiControl, 1:  MoveDraw, 		thisTab3, 	% thisX(.5) thisY(.50) thisW(77.08) thisH(71.0)
	GuiControl, 1: 	+cBlack, 		thisTab3
;	GuiControl, 1: 	-0x107, 		thisTab3 ; taps unten anordnen
;	GuiControl, 1: 	+BackgroundRED, 	thisTab3
;	GuiControl, 1: ,  			thisTab3, 	test1|test2|test3
;	GuiControl, 1: ,  			thisTab3, 	test4
	GuiControl, 1:  show, 			thisTab3
;	GuiControl, 1:  hide, 			thisTab3
;	GuiControl, 1:  focus, 			thisTab3
;	GuiControl, 1:  disable, 		thisTab3
;	GuiControl, 1:  enable, 		thisTab3
;	GuiControl, hide, SysTabControl321
	Gui, Tab, OCR && Translate
	Gui, 1: Add, ComboBox, w300 vcombo1 ; AltSubmit 
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			combo1
 	GuiControl, 1:  MoveDraw, 		combo1, 	% thisX(1.0) thisY(1.0) thisW(20.0) thisH(2.0) ;  default
	GuiControl, 1: 	+cBlack, 		combo1
;	GuiControl, 1: 	+BackgroundRED, 	combo1
;	GuiControl, 1: ,  			combo1, 	""
	GuiControl, 1:  show, 			combo1
;	GuiControl, 1:  hide, 			combo1
;	GuiControl, 1:  focus, 			combo1
;	GuiControl, 1:  disable, 		combo1
;	GuiControl, 1:  enable, 		combo1
	Gui, 1: Add, button, vButton1 gButton1, Start OCR
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			Button1
 	GuiControl, 1:  MoveDraw, 		Button1, 	% thisX(22.0) thisY(1.0) thisW(7.0) thisH(3.0) ;  default
	GuiControl, 1: 	+cBlack, 		Button1
;	GuiControl, 1: 	+BackgroundRED, 	Button1
	GuiControl, 1: ,  			Button1, 	Start OCR
	GuiControl, 1:  show, 			Button1
;	GuiControl, 1:  hide, 			Button1
;	GuiControl, 1:  focus, 			Button1
;	GuiControl, 1:  disable, 		Button1
;	GuiControl, 1:  enable, 		Button1
	Gui, 1: Add, button, vButton2 gButton2, Start OCR && Translation
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			Button2
 	GuiControl, 1:  MoveDraw, 		Button2, 	% thisX(32.0) thisY(1.0) thisW(10.0) thisH(3.0) ;  default
	GuiControl, 1: 	+cBlack, 		Button2
;	GuiControl, 1: 	+BackgroundRED, 	Button2
	GuiControl, 1: ,  			Button2, 	Start OCR && Translation
	GuiControl, 1:  show, 			Button2
;	GuiControl, 1:  hide, 			Button2
;	GuiControl, 1:  focus, 			Button2
;	GuiControl, 1:  disable, 		Button2
;	GuiControl, 1:  enable, 		Button2
	Gui, 1: Add, ListView, w600 vSourceFiles r20 grid, #|OCR Files
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(11.0) ; 
	GuiControl, 1:  Font, 			SourceFiles
 	GuiControl, 1:  MoveDraw, 		SourceFiles, 	% thisX(1.0) thisY(10.0) thisW(20.0) thisH(34.0)  ;  default
	GuiControl, 1: 	+cBlack, 		SourceFiles
;	GuiControl, 1: 	+BackgroundRED, 	SourceFiles
;	GuiControl, 1: ,  			SourceFiles, 	%a_Space% vSourceFiles %Space% 
	GuiControl, 1:  show, 			SourceFiles
;	GuiControl, 1:  hide, 			SourceFiles
;	GuiControl, 1:  focus, 			SourceFiles
;	GuiControl, 1:  disable, 		SourceFiles
;	GuiControl, 1:  enable, 		SourceFiles
	Gui, 1: Add, edit, vedit1 r2 ; ohne r2 funktioniert MoveDraw nicht
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(14.0) ; 
	GuiControl, 1:  Font, 			edit1
	GuiControl, 1:  MoveDraw, 		edit1, 	% thisX(42.5) thisY(10.0) thisW(20.0) thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		edit1
;	GuiControl, 1: 	+BackgroundRED, 	edit1
;	GuiControl, 1: ,  			edit1, 	%a_Space% vedit1 %Space% 
	GuiControl, 1:  show, 			edit1
;	GuiControl, 1:  hide, 			edit1
;	GuiControl, 1:  focus, 			edit1
;	GuiControl, 1:  disable, 		edit1
;	GuiControl, 1:  enable, 		edit1
	Gui, 1: Add, edit, vedit2 r2 ; ohne r2 funktioniert MoveDraw nicht
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(14.0) ; 
	GuiControl, 1:  Font, 			edit2
	GuiControl, 1:  MoveDraw, 		edit2, 	% thisX(22.0) thisY(10.0) thisW(20.0) thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		edit2
;	GuiControl, 1: 	+BackgroundRED, 	edit2
	GuiControl, 1: ,  			edit2, 	%a_Space% vedit2 %Space% 
	GuiControl, 1:  show, 			edit2
;	GuiControl, 1:  hide, 			edit2
;	GuiControl, 1:  focus, 			edit2
;	GuiControl, 1:  disable, 		edit2
;	GuiControl, 1:  enable, 		edit2
	Gui, Tab, ISOLanguageCodes
	Gui, 1: Add, ListView, w550 vCountryCodes r20 grid, Language|Country|Code|HEX|Longname
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			CountryCodes
 	GuiControl, 1:  MoveDraw, 		CountryCodes, 	% thisX(.5) thisY(1.0) thisW(41.9) ; thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		CountryCodes
;	GuiControl, 1: 	+BackgroundRED, 	CountryCodes
	GuiControl, 1: ,  			CountryCodes, 	%a_Space% vCountryCodes %Space% 
	GuiControl, 1:  show, 			CountryCodes
;	GuiControl, 1:  hide, 			CountryCodes
;	GuiControl, 1:  focus, 			CountryCodes
;	GuiControl, 1:  disable, 		CountryCodes
;	GuiControl, 1:  enable, 		CountryCodes
	Gui, 1: Add, ListView, w300 vGoogleCountryCodes r20 grid, Language|Code
	Gui, 1: 	Font, 						% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			GoogleCountryCodes
 	GuiControl, 1:  MoveDraw, 		GoogleCountryCodes, 	% thisX(43.0) thisY(1.0) thisW(20.0) ; thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		GoogleCountryCodes
;	GuiControl, 1: 	+BackgroundRED, 	GoogleCountryCodes
	GuiControl, 1: ,  			GoogleCountryCodes, 	%a_Space% vGoogleCountryCodes %Space% 
	GuiControl, 1:  show, 			GoogleCountryCodes
;	GuiControl, 1:  hide, 			GoogleCountryCodes
;	GuiControl, 1:  focus, 			GoogleCountryCodes
;	GuiControl, 1:  disable, 		GoogleCountryCodes
;	GuiControl, 1:  enable, 		GoogleCountryCodes
	Gui, Tab, json
	Gui, 1: Add, ListView, w600 vjson r20 grid, json
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(12.0) ; 
	GuiControl, 1:  Font, 			json
 	GuiControl, 1:  MoveDraw, 		json, 	% thisX(.5) thisY(1.0) thisW(41.9) ; thisH(34.0) ;  default
	GuiControl, 1: 	+cBlack, 		json
;	GuiControl, 1: 	+BackgroundRED, 	json
	GuiControl, 1: ,  			json, 	%a_Space% vjson %Space% 
	GuiControl, 1:  show, 			json
;	GuiControl, 1:  hide, 			json
;	GuiControl, 1:  focus, 			json
;	GuiControl, 1:  disable, 		json
;	GuiControl, 1:  enable, 		json
;------------------------------------------------------------------ use windows codes
	combo1CountryArr 	:= object()
	combo1LongnameArr	:= object()
	combo1CodeArr 		:= object()
	combo1CodeHexArr 	:= object()
	combo1CodeLanguageArr 	:= object()
	loop, parse,% LanguageCodes, `n
	{
	split := strsplit(a_loopfield,a_tab)
	combo1CountryArr.push(split.1)
	combo1LongnameArr.push(split.2)
	combo1CodeArr.push(split.3)
	combo1CodeHexArr.push(split.4)
	combo1CodeLanguageArr.push(split.5)
	if (A_Language=split.4)
	{
	thisComputer := split.5
	combo1CountryVar .= split.1 a_space a_space "(" strreplace(split.2,"_", a_space) ")||"
	} else {
	combo1CountryVar .= split.1 a_space a_space "(" strreplace(split.2,"_", a_space) ")|"
	}
;	Gui, Tab, ISOLanguageCodes
	Gui, listview, CountryCodes 		;------------------	WhoAmI
	LV_Add("", split.5, split.1, split.3, split.4, strreplace(split.2,"_", a_space))
	LV_ModifyCol()	
	}
;	msgbox % combo1CodeLanguageArr.length() ; 115
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")
;	GuiControl, 1:,	combo1,% combo1CountryVar
;------------------------------------------------------------------ 	use google codes
	GoogleCodeLanguageArr 	:= object()
	GoogleCodeArr 		:= object()
	gui, listview, GoogleCountryCodes 	;------------------	Language for Translate
	loop, parse,% GoogleLanguageCodes , `n
	{
	split := strsplit(a_loopfield,a_tab)
	GoogleCodeLanguageArr.push(split.1)
	GoogleCodeArr.push(split.2)
	if (thisComputer=split.1)
	GoogleCountryCodes .= split.1 a_space a_space "(" split.2 ")||"
	else 
	GoogleCountryCodes .= split.1 a_space a_space "(" split.2 ")|"
	Gui, listview, GoogleCountryCodes
	LV_Add("", split.1, split.2)
	}
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")
;	msgbox % GoogleCodeLanguageArr.length() ; 133
	GuiControl, 1:,	combo1,% GoogleCountryCodes
;------------------------------------------------------------------
	startInfo := 	"Bei Programmstart wird die Systemsprache des Rechners gewählt. Sie "
			. "kann jederzeit in eine andere Sprache eingestellt werden.`n`n"
			. "Bilddateien mit Text die im gleichen Verzeichnis liegen, werden nachdem sie OCR gescannt "
			. "wurden, in die oben ausgewählte Sprache übersetzt.`n`n"
			. "Dateien die Sie mit der Maus auf das Programm schieben, werden ebenfalls erkannt und bearbeitet.`n`n"
			. "Wegen Spamschutz Maßnahmen wird zwischen jeder Übersetzung eine Pause von etwa 4 Sekunden eingehalten.`n`n"
			. "Nach Fertigstellung liegen zu jedem Scann, Textdateien in der Originalversion und übersetzt im Verzeichnis`n`n"
			. "Die Bilddateien werden nachdem sie gescannt wurden in das Verzeichnis \done verschoben.`n`n"
			. "Google Translate übersetzt bis zu 500.000 Zeichen pro Monat kostenlos." 
			. " Alles, was darüber hinausgeht, gilt als kommerzielle Nutzung und wird "
			. "mit 20 USD pro 1 Million Zeichen in Rechnung gestellt.`n`n"
			. "Infolink:`nhttps://cloud.google.com/translate/pricing?hl=de`n`n#############################`n`n"
	GuiControl, 1:,	edit2,% startInfo
	startInfo := 	 "When the program starts, the computer's system language is selected. It can be set to another language at any time.`n`n"
			. "Image files with text located in the same directory will be translated into the language selected above after they have been OCR scanned.`n`n"
			. "Files that you drag onto the program with the mouse are also recognized and processed.`n`n"
			. "Due to spam protection measures, there is a pause of around 4 seconds between each translation.`n`n"
			. "After completion, text files for each scan are in the original version and translated in the directory`n`n"
			. "After the image files have been scanned, they will be moved to the \done directory.`n`n"
			. "Google Translate translates up to 500,000 characters per month for free. Anything beyond this is considered commercial use and will be billed at $20 per 1 million characters.`n`n"
			. "Info link:`n"
			. "https://cloud.google.com/translate/pricing?hl=en`n`n#############################`n`n"
			. "Cuando se inicia el programa, se selecciona el idioma del sistema de la computadora. Se puede configurar en otro idioma en cualquier momento.`n`n"
			. "Los archivos de imagen con texto ubicado en el mismo directorio se traducirán al idioma seleccionado anteriormente después de haber sido escaneados con OCR.`n`n"
			. "Los archivos que arrastra al programa con el mouse también se reconocen y procesan.`n`n"
			. "Debido a las medidas de protección contra spam, hay una pausa de unos 4 segundos entre cada traducción.`n`n"
			. "Una vez finalizado, los archivos de texto de cada escaneo están en la versión original y traducidos en el directorio.`n`n"
			. "Una vez escaneados los archivos de imagen, se moverán al directorio \done.`n`n"
			. "Google Translate traduce hasta 500.000 caracteres al mes de forma gratuita. Cualquier cosa más allá de esto se considera uso comercial y se facturará a 20 dólares por millón de caracteres.`n`n"
			. "Enlace de información:`n"
			. "https://cloud.google.com/translate/pricing?hl=es"
	GuiControl, 1:,	edit1,% startInfo
;	gui, show
;==========================================================================================================
xxz:=100
x:=(WA*0)/xxz, y:=(ha*.1)/xxz,w:=(wa*99.9)/xxz,h:=(ha*93)/xxz   ;- GUI  x,y,w,h
Gui,1: Show,x%x% y%y% w%w% h%h%,,% "Batch OCR & Translate " strReplace((substr(a_scriptname,-10)),".ahk")
;===========================================================================================================
	;Gui, 1: Show,x0 ,% "Batch OCR & Translate " strReplace((substr(a_scriptname,-10)),".ahk")
	thisLoopFile =
;	Gui, Tab, ISOLanguageCodes
	Gui, listview, SourceFiles
	LV_delete()
	Loop Files,% a_scriptdir  "\*.*"
	{
	if A_LoopFileName contains jpg,png
	LV_Add("", a_index, A_LoopFileName )	
	LV_ModifyCol()
	}
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")
Return 
 
;------------------------------ 	; firstreturn
	
	thisrestart:
	Gui, submit, nohide
;	thisISOLanguageCode 	:= GetISOLanguageCode(combo1CodeHexArr[combo1])
;	msgbox % A_GuiControl
	if (A_GuiControl="Start OCR && Translation") 
	|| (A_GuiControl="button1") 
	|| (A_GuiControl="button2") 
;	|| (A_GuiControl=1)
	|| A_GuiControl contains Start OCR
	{
	GuiControl, 1:,	edit1,% ""
	GuiControl, 1:,	edit2,% ""
	thisOCR =
	thisGoogleTranslate =
	}
	global ANow := a_now
	Loop Files,% a_scriptdir "\*.jpg"
	{
	if A_LoopFileFullPath
	thisLoopFile .= A_LoopFileFullPath "`n"
	}
	Loop Files,% a_scriptdir "\*.png"
	{
	if A_LoopFileFullPath
	thisLoopFile .= A_LoopFileFullPath "`n"
	}
	if thisLoopFile not contains jpg,png
	{
	sleep, 1
	msgbox,4096,% a_linenumber, keine jpg dateien gefunden
pause
	;exitapp
	}
;	split := strsplit(thisLoopFile,"`n")  	; ???
	sort, thisLoopFile
	loop, parse,% thisLoopFile, `n
	{
	if !A_LoopField
	continue
	ALoopField := ""
	ALoopField := A_LoopField
	try Words := thisOCR := ocr(ALoopField, "de")
	
	FileAppend,% thisOCR "`n#############`n" 
		, % (ANow "-OcrErgebnis.txt"), UTF-8
; sprachen in windows installieren
; https://support.microsoft.com/de-de/windows/sprachpakete-f%C3%BCr-windows-a5094319-a92d-18de-5b53-1cfc697cfca8
	if !debug
	if (thisOCRBevore = thisOCR) && (thisISOLanguageCodeBevore = thisISOLanguageCode)
	continue
	if (thisOCR)
	{
	thisOCRBevore 			:= thisOCR
	thisISOLanguageCodeBevore 	:= thisISOLanguageCode
;	try thisGoogleTranslate 	:= GoogleTranslate(thisOCR,"iw",(thisISOLanguageCode?thisISOLanguageCode:"de"))
;	msgbox,,% a_linenumber, % thisISOLanguageCode,1
;	translateCounter++
;	try thisGoogleTranslate := GoogleTranslate(thisOCR,    ,"zh-CN") ; persisch
	try thisGoogleTranslate := GoogleTranslate(thisOCR,    ,(thisISOLanguageCode))
;	msgbox % GetISOCodeA(thisISOLanguageCode) a_space thisISOLanguageCode 
	thisXXX :=  	GetISOCodeA(thisISOLanguageCode) 
			? GetISOCodeA(thisISOLanguageCode)
			: GetISOCodeB(thisISOLanguageCode)
			. a_space thisISOLanguageCode 
	FileAppend,% thisGoogleTranslate  "`n#############`n" 
		, % (a_tickcount a_space thisXXX " OcrTranslateErgebnis.txt"), UTF-8
	}
	if !debug
		{
			thisCode := (AhkObj[9, 1, 1])
			res :=  "Translated from: " 
				. thisCode a_space
				. (GetISOCodeA(thisCode) ? "(" GetISOCodeA(thisCode) ")" : "(" GetISOCodeB(thisCode) ")")
				. " into: " 
				. (thisISOLanguageCode) a_space a_space
				. " (" RTRIM(strSplit(combo1,"(",")").1) ")" a_space 
				. ((translateCounter>1) ? (translateCounter " Files") : (translateCounter " File"))
			;	. " (" strreplace(combo1LongnameArr["Longname"],"_", a_space) ")" a_space translateCounter " Pages" 
		;if res
		GuiControl, 1:,	Text1,% strReplace(res,a_space a_space, a_space)
		res =
		}
	comboSelect := " (" RTRIM(strSplit(combo1,"(",")").1) ")"
	thisOCRFULL 		.= "Page: " a_index "`n" thisOCR "`n----------------`n" 
	thisGoogleTranslateFULL .= "Page: " a_index "`n" thisGoogleTranslate "`n----------------`n" 
;thisOCR =
;thisGoogleTranslate =
	if !debug
	{	
	if !(thisGoogleTranslateLast=thisGoogleTranslate)
	{
	thisGoogleTranslateLast := thisGoogleTranslate
;	atickcount := a_tickcount
	GuiControl, 1: ,  			thisTab3,% 	"File" translateCounter
	Gui, Tab,% "File" translateCounter
	Gui, 1: Add, edit,% "vOCREdit" translateCounter " r2" ; ohne r2 funktioniert MoveDraw nicht
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(14.0) ; 
	GuiControl, 1:  Font, 			% "OCREdit" translateCounter 
	GuiControl, 1:  MoveDraw, 		% "OCREdit" translateCounter, 	% thisX(1.5) thisY(1.0) thisW(20.0) thisH(50.0) ;  default
	GuiControl, 1: 	+cBlack, 		% "OCREdit" translateCounter
;	GuiControl, 1: 	+BackgroundRED, 	% "OCREdit" translateCounter
	GuiControl, 1: ,  			% "OCREdit" translateCounter, 	% "File" translateCounter
	GuiControl, 1:  show, 			% "OCREdit" translateCounter
;	GuiControl, 1:  hide, 			% "OCREdit" translateCounter
;	GuiControl, 1:  focus, 			% "OCREdit" translateCounter
;	GuiControl, 1:  disable, 		% "OCREdit" translateCounter
;	GuiControl, 1:  enable, 		% "OCREdit" translateCounter
	thisFilesTab := "File" translateCounter
	GuiControl, 1:, %thisFilesTab%,% thisOCR
	;GuiControl, 1:, ,% thisOCR
	Gui, 1: Add, edit,% "vTranslateEdit" translateCounter " r2" ; ohne r2 funktioniert MoveDraw nicht
	Gui, 1: 	Font, 				% thisZoomFactorFontVerdanaPro(14.0) ; 
	GuiControl, 1:  Font, 			% "TranslateEdit" translateCounter 
	GuiControl, 1:  MoveDraw, 		% "TranslateEdit" translateCounter, 	% thisX(22.0) thisY(1.0) thisW(20.0) thisH(50.0) ;  default
	GuiControl, 1: 	+cBlack, 		% "TranslateEdit" translateCounter
;	GuiControl, 1: 	+BackgroundRED, 	% "TranslateEdit" translateCounter
	GuiControl, 1: ,  			% "TranslateEdit" translateCounter, 	% "File" translateCounter
	GuiControl, 1:  show, 			% "TranslateEdit" translateCounter
;	GuiControl, 1:  hide, 			% "TranslateEdit" translateCounter
;	GuiControl, 1:  focus, 			% "TranslateEdit" translateCounter
;	GuiControl, 1:  disable, 		% "TranslateEdit" translateCounter
;	GuiControl, 1:  enable, 		% "TranslateEdit" translateCounter
	thisFilesTab := "File" translateCounter
	GuiControl, 1:, %thisFilesTab%,% thisGoogleTranslate 
	}} ; debug end
	thisOCR 		:= ""
	thisGoogleTranslate 	:= ""
	if !fileexist(a_scriptdir "\done")
	filecreateDir,% (a_scriptdir "\done")
;	fileMove,% ALoopField,% (a_scriptdir "\done"), 1
	fileCopy,% ALoopField,% (a_scriptdir "\done") ; test
	splitlength := split.length()
		random, rand, 3000, 5000
		sleep,% rand ; translate spamschutz
	} ; ---------------------------------------------------------------------- loopEnd
;	msgbox,4096,% a_linenumber,% thisISOLanguageCode "`n" combo1LongnameArr[combo1]
	combo1LongnameArr["Longname"] :=  ((combo1LongnameArr[combo1]="")
					? thisISOLongnameCode
					: (combo1LongnameArr[combo1]))
	if thisOCRFULL || thisGoogleTranslateFULL
	{
	GuiControl, 1:,	edit2,% thisOCRFULL
	GuiControl, 1:,	edit1,% thisGoogleTranslateFULL
	thisOCRFULL 		:= ""
	thisGoogleTranslateFULL := ""
	}
	if !debug
		{
			thisCode := (AhkObj[9, 1, 1])
			res :=  "Translated from: " 
				. thisCode a_space
				. (GetISOCodeA(thisCode) ? "(" GetISOCodeA(thisCode) ")" : "(" GetISOCodeB(thisCode) ")")
				. " into: " 
				. (thisISOLanguageCode) a_space a_space
				. " (" RTRIM(strSplit(combo1,"(",")").1) ")" a_space 
				. ((translateCounter>1) ? (translateCounter " Files") : (translateCounter " File"))
			;	. " (" strreplace(combo1LongnameArr["Longname"],"_", a_space) ")" a_space translateCounter " Pages" 
		;if res
		GuiControl, 1:,	Text1,% strReplace(res,a_space a_space, a_space)
		res =
		}
	thisOCRFULL 		=
	thisGoogleTranslateFULL =
;	try run,% (ANow "-OcrTranslateErgebnis.txt")
	Gui, Tab, json
	Gui, listview, json
	LV_delete()
	loop, parse,% BeautifyJson(thisjson), `n
	LV_Add("", a_loopfield)	
	Loop % LV_GetCount("Column")
	LV_ModifyCol(A_Index, "AutoHdr")
if debug
msgbox,4096,% a_linenumber " Fertig!",%    "EingabeSprache: " AhkObj[9, 1, 1] "`n"
					 . "Übersetzt in: " thisISOLanguageCode "`n" combo1LongnameArr["Longname"]
	; temporäre tabs schliessen
	;GuiControl, 1: ,  			thisTab3, 	|OCR && Translate|ISOLanguageCodes|json
thisISOLanguageCode =
;exitapp
Return 
 
;------------------------------
;##
For Line, Array In Words
   For Each, Word In Array 
{
if (word.4>100)
msgbox,4096,% a_linenumber,% word.5
}
;Gui, Submit, Nohide
;ControlGet, AusgabeVar, List, , SysListView321
Return 
 
;------------------------------
GuiClose:
;reload
ExitApp
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;--------------------------------------
;combo1:
Button1:
Button2:
gui, submit, nohide
if debug
msgbox,4096,% a_linenumber,%  	"Language Nr.: " combo1 "/" combo1CountryArr.length() 	"`n"
				. combo1CountryArr[combo1]  	"`n"
				. combo1LongnameArr[combo1] 	"`n"
				. combo1CodeArr[combo1] 	"`n"
				. combo1CodeHexArr[combo1]
; thisISOLanguageCode 		:= GetISOLanguageCode(combo1CodeHexArr[combo1]) 	; used windows codes
  thisISOLanguageCode 		:= strSplit(combo1,"(",")").2 				; used google codes
goto	thisrestart
Return 
 
;------------------------------ ; 
;------------------------------------------------------------------
; https://www.autohotkey.com/boards/viewtopic.php?p=393308#p393308  by sobuj53
; Take a 4-digit language code or (if no parameter) the current language code and return the corresponding 2-digit ISO code
GetISOLanguageCode(lang := 0) {
global   
LanguageCodeArray := { 0436: "af" ; Afrikaans
			, 041c: "sq" ; Albanian
			, 0401: "ar" ; Arabic_Saudi_Arabia
			, 0801: "ar" ; Arabic_Iraq
			, 0c01: "ar" ; Arabic_Egypt
			, 1001: "ar" ; Arabic_Libya
			, 1401: "ar" ; Arabic_Algeria
			, 1801: "ar" ; Arabic_Morocco
			, 1c01: "ar" ; Arabic_Tunisia
			, 2001: "ar" ; Arabic_Oman
			, 2401: "ar" ; Arabic_Yemen
			, 2801: "ar" ; Arabic_Syria
			, 2c01: "ar" ; Arabic_Jordan
			, 3001: "ar" ; Arabic_Lebanon
			, 3401: "ar" ; Arabic_Kuwait
			, 3801: "ar" ; Arabic_UAE
			, 3c01: "ar" ; Arabic_Bahrain
			, 042c: "az" ; Azeri_Latin
			, 082c: "az" ; Azeri_Cyrillic
			, 042d: "eu" ; Basque
			, 0423: "be" ; Belarusian
			, 0402: "bg" ; Bulgarian
			, 0403: "ca" ; Catalan
			, 0404: "zh-CN" ; Chinese_Taiwan
			, 0804: "zh-CN" ; Chinese_PRC
			, 0c04: "zh-CN" ; Chinese_Hong_Kong
			, 1004: "zh-CN" ; Chinese_Singapore
			, 1404: "zh-CN" ; Chinese_Macau
			, 041a: "hr" ; Croatian
			, 0405: "cs" ; Czech
			, 0406: "da" ; Danish
			, 0413: "nl" ; Dutch_Standard
			, 0813: "nl" ; Dutch_Belgian
			, 0409: "en" ; English_United_States
			, 0809: "en" ; English_United_Kingdom
			, 0c09: "en" ; English_Australian
			, 1009: "en" ; English_Canadian
			, 1409: "en" ; English_New_Zealand
			, 1809: "en" ; English_Irish
			, 1c09: "en" ; English_South_Africa
			, 2009: "en" ; English_Jamaica
			, 2409: "en" ; English_Caribbean
			, 2809: "en" ; English_Belize
			, 2c09: "en" ; English_Trinidad
			, 3009: "en" ; English_Zimbabwe
			, 3409: "en" ; English_Philippines
			, 0425: "et" ; Estonian
			, 040b: "fi" ; Finnish
			, 040c: "fr" ; French_Standard
			, 080c: "fr" ; French_Belgian
			, 0c0c: "fr" ; French_Canadian
			, 100c: "fr" ; French_Swiss
			, 140c: "fr" ; French_Luxembourg
			, 180c: "fr" ; French_Monaco
			, 0437: "ka" ; Georgian
			, 0407: "de" ; German_Standard
			, 0807: "de" ; German_Swiss
			, 0c07: "de" ; German_Austrian
			, 1007: "de" ; German_Luxembourg
			, 1407: "de" ; German_Liechtenstein
			, 0408: "el" ; Greek
			, 040d: "iw" ; Hebrew
			, 0439: "hi" ; Hindi
			, 040e: "hu" ; Hungarian
			, 040f: "is" ; Icelandic
			, 0421: "id" ; Indonesian
			, 0410: "it" ; Italian_Standard
			, 0810: "it" ; Italian_Swiss
			, 0411: "ja" ; Japanese
			, 0412: "ko" ; Korean
			, 0426: "lv" ; Latvian
			, 0427: "lt" ; Lithuanian
			, 042f: "mk" ; Macedonian
			, 043e: "ms" ; Malay_Malaysia
			, 083e: "ms" ; Malay_Brunei_Darussalam
			, 0414: "no" ; Norwegian_Bokmal
			, 0814: "no" ; Norwegian_Nynorsk
			, 0415: "pl" ; Polish
			, 0416: "pt" ; Portuguese_Brazilian
			, 0816: "pt" ; Portuguese_Standard
			, 0418: "ro" ; Romanian
			, 0419: "ru" ; Russian
			, 081a: "sr" ; Serbian_Latin
			, 0c1a: "sr" ; Serbian_Cyrillic
			, 041b: "sk" ; Slovak
			, 0424: "sl" ; Slovenian
			, 040a: "es" ; Spanish_Traditional_Sort
			, 080a: "es" ; Spanish_Mexican
			, 0c0a: "es" ; Spanish_Modern_Sort
			, 100a: "es" ; Spanish_Guatemala
			, 140a: "es" ; Spanish_Costa_Rica
			, 180a: "es" ; Spanish_Panama
			, 1c0a: "es" ; Spanish_Dominican_Republic
			, 200a: "es" ; Spanish_Venezuela
			, 240a: "es" ; Spanish_Colombia
			, 280a: "es" ; Spanish_Peru
			, 2c0a: "es" ; Spanish_Argentina
			, 300a: "es" ; Spanish_Ecuador
			, 340a: "es" ; Spanish_Chile
			, 380a: "es" ; Spanish_Uruguay
			, 3c0a: "es" ; Spanish_Paraguay
			, 400a: "es" ; Spanish_Bolivia
			, 440a: "es" ; Spanish_El_Salvador
			, 480a: "es" ; Spanish_Honduras
			, 4c0a: "es" ; Spanish_Nicaragua
			, 500a: "es" ; Spanish_Puerto_Rico
			, 0441: "sw" ; Swahili
			, 041d: "sv" ; Swedish
			, 081d: "sv" ; Swedish_Finland
			, 0449: "ta" ; Tamil
			, 041e: "th" ; Thai
			, 041f: "tr" ; Turkish
			, 0422: "uk" ; Ukrainian
			, 0420: "ur" ; Urdu
			, 042a: "vi"} ; Vietnamese
   If(lang)
     Return LanguageCodeArray[lang]
   Else Return LanguageCodeArray[A_Language]
}
;-------------------------------------------------------------
GetISOLongnameCode(lang := 0) {
global   
LanguageLongnameArray := { 0436: "Afrikaans"
			, 041c: "Albanian"
			, 0401: "Arabic_Saudi_Arabia"
			, 0801: "Arabic_Iraq"
			, 0c01: "Arabic_Egypt"
			, 1001: "Arabic_Libya"
			, 1401: "Arabic_Algeria"
			, 1801: "Arabic_Morocco"
			, 1c01: "Arabic_Tunisia"
			, 2001: "Arabic_Oman"
			, 2401: "Arabic_Yemen"
			, 2801: "Arabic_Syria"
			, 2c01: "Arabic_Jordan"
			, 3001: "Arabic_Lebanon"
			, 3401: "Arabic_Kuwait"
			, 3801: "Arabic_UAE"
			, 3c01: "Arabic_Bahrain"
			, 042c: "Azeri_Latin"
			, 082c: "Azeri_Cyrillic"
			, 042d: "Basque"
			, 0423: "Belarusian"
			, 0402: "Bulgarian"
			, 0403: "Catalan"
			, 0404: "Chinese_Taiwan"
			, 0804: "Chinese_PRC"
			, 0c04: "Chinese_Hong_Kong"
			, 1004: "Chinese_Singapore"
			, 1404: "Chinese_Macau"
			, 041a: "Croatian"
			, 0405: "Czech"
			, 0406: "Danish"
			, 0413: "Dutch_Standard"
			, 0813: "Dutch_Belgian"
			, 0409: "English_United_States"
			, 0809: "English_United_Kingdom"
			, 0c09: "English_Australian"
			, 1009: "English_Canadian"
			, 1409: "English_New_Zealand"
			, 1809: "English_Irish"
			, 1c09: "English_South_Africa"
			, 2009: "English_Jamaica"
			, 2409: "English_Caribbean"
			, 2809: "English_Belize"
			, 2c09: "English_Trinidad"
			, 3009: "English_Zimbabwe"
			, 3409: "English_Philippines"
			, 0425: "Estonian"
			, 040b: "Finnish"
			, 040c: "French_Standard"
			, 080c: "French_Belgian"
			, 0c0c: "French_Canadian"
			, 100c: "French_Swiss"
			, 140c: "French_Luxembourg"
			, 180c: "French_Monaco"
			, 0437: "Georgian"
			, 0407: "German_Standard"
			, 0807: "German_Swiss"
			, 0c07: "German_Austrian"
			, 1007: "German_Luxembourg"
			, 1407: "German_Liechtenstein"
			, 0408: "Greek"
			, 040d: "Hebrew"
			, 0439: "Hindi"
			, 040e: "Hungarian"
			, 040f: "Icelandic"
			, 0421: "Indonesian"
			, 0410: "Italian_Standard"
			, 0810: "Italian_Swiss"
			, 0411: "Japanese"
			, 0412: "Korean"
			, 0426: "Latvian"
			, 0427: "Lithuanian"
			, 042f: "Macedonian"
			, 043e: "Malay_Malaysia"
			, 083e: "Malay_Brunei_Darussalam"
			, 0414: "Norwegian_Bokmal"
			, 0814: "Norwegian_Nynorsk"
			, 0415: "Polish"
			, 0416: "Portuguese_Brazilian"
			, 0816: "Portuguese_Standard"
			, 0418: "Romanian"
			, 0419: "Russian"
			, 081a: "Serbian_Latin"
			, 0c1a: "Serbian_Cyrillic"
			, 041b: "Slovak"
			, 0424: "Slovenian"
			, 040a: "Spanish_Traditional_Sort"
			, 080a: "Spanish_Mexican"
			, 0c0a: "Spanish_Modern_Sort"
			, 100a: "Spanish_Guatemala"
			, 140a: "Spanish_Costa_Rica"
			, 180a: "Spanish_Panama"
			, 1c0a: "Spanish_Dominican_Republic"
			, 200a: "Spanish_Venezuela"
			, 240a: "Spanish_Colombia"
			, 280a: "Spanish_Peru"
			, 2c0a: "Spanish_Argentina"
			, 300a: "Spanish_Ecuador"
			, 340a: "Spanish_Chile"
			, 380a: "Spanish_Uruguay"
			, 3c0a: "Spanish_Paraguay"
			, 400a: "Spanish_Bolivia"
			, 440a: "Spanish_El_Salvador"
			, 480a: "Spanish_Honduras"
			, 4c0a: "Spanish_Nicaragua"
			, 500a: "Spanish_Puerto_Rico"
			, 0441: "Swahili"
			, 041d: "Swedish"
			, 081d: "Swedish_Finland"
			, 0449: "Tamil"
			, 041e: "Thai"
			, 041f: "Turkish"
			, 0422: "Ukrainian"
			, 0420: "Urdu"
			, 042a: "Vietnamese"}
   If(lang)
     Return LanguageLongnameArray[lang]
   Else Return LanguageLongnameArray[A_Language]
}
;-----------------------------------------------------------------
GetISOCodeA(lang) {
LanguageCodeArray := { af: "Afrikaans"
	, sq: "Albanisch"
	, am: "Amharisch"
	, ar: "Arabisch"
	, hy: "Armenisch"
	, az: "Aserbaidschanisch"
	, as: "Assamesisch"
	, ay: "Aymara"
	, bm: "Bambara"
	, eu: "Baskisch"
	, be: "Belarussisch"
	, bn: "Bengalisch"
	, bho: "Bhojpuri"
	, my: "Birmanisch"
	, bs: "Bosnisch"
	, bg: "Bulgarisch"
	, ceb: "Cebuano"
	, ny: "Chichewa"
	, zh-TW: "Chinesisch (traditionell)"
	, zh-CN: "Chinesisch (vereinfacht)"
	, da: "Dänisch"
	, de: "Deutsch"
	, dv: "Dhivehi"
	, doi: "Dogri"
	, en: "Englisch"
	, eo: "Esperanto"
	, et: "Estnisch"
	, ee: "Ewe"
	, tl: "Filipino"
	, fi: "Finnisch"
	, fr: "Französisch"
	, fy: "Friesisch"
	, gl: "Galizisch"
	, ka: "Georgisch"
	, el: "Griechisch"
	, gn: "Guarani"
	, gu: "Gujarati"
	, ht: "Haitianisch"
	, ha: "Hausa"
	, haw: "Hawaiisch"
	, iw: "Hebräisch"
	, hi: "Hindi"
	, hmn: "Hmong"
	, ig: "Igbo"
	, ilo: "Ilokano"
	, id: "Indonesisch"
	, ga: "Irisch"
	, is: "Isländisch"
	, it: "Italienisch"
	, ja: "Japanisch"
	, jw: "Javanisch"
	, yi: "Jiddisch"
	, kn: "Kannada"
	, kk: "Kasachisch"
	, ca: "Katalanisch"
	, km: "Khmer"
	, rw: "Kinyarwanda"
	, ky: "Kirgisisch"
	, gom: "Konkani"
	, ko: "Koreanisch"
	, co: "Korsisch"
	, kri: "Krio"
	, hr: "Kroatisch"
	, ku: "Kurdisch (Kurmandschi)"
	, ckb: "Kurdisch (Sorani)"
	, lo: "Lao"
	, la: "Latein"
	, lv: "Lettisch"
	, ln: "Lingala"
	, lt: "Litauisch"}
     Return LanguageCodeArray[lang]
}
;--------------------------------------------
GetISOCodeB(lang) {
LanguageCodeArray := {  lg: "Luganda"
	, lb: "Luxemburgisch"
	, mai: "Maithili"
	, mg: "Malagasy"
	, ml: "Malayalam"
	, ms: "Malaysisch"
	, mt: "Maltesisch"
	, mi: "Maori"
	, mr: "Marathi"
	, mk: "Mazedonisch"
	, mni-Mtei: "Meitei (Manipuri)"
	, lus: "Mizo"
	, mn: "Mongolisch"
	, ne: "Nepalesisch"
	, nl: "Niederländisch"
	, no: "Norwegisch"
	, or: "Odia (Oriya)"
	, om: "Oromo"
	, ps: "Paschtu"
	, fa: "Persisch"
	, pl: "Polnisch"
	, pt: "Portugiesisch"
	, pa: "Punjabi"
	, qu: "Quechua"
	, ro: "Rumänisch"
	, ru: "Russisch"
	, sm: "Samoanisch"
	, sa: "Sanskrit"
	, gd: "Schottisch-Gälisch"
	, sv: "Schwedisch"
	, nso: "Sepedi"
	, sr: "Serbisch"
	, st: "Sesotho"
	, sn: "Shona"
	, sd: "Sindhi"
	, si: "Singhalesisch"
	, sk: "Slowakisch"
	, sl: "Slowenisch"
	, so: "Somali"
	, es: "Spanisch"
	, su: "Sundanesisch"
	, sw: "Swahili"
	, tg: "Tadschikisch"
	, ta: "Tamil"
	, tt: "Tatarisch"
	, te: "Telugu"
	, th: "Thailändisch"
	, ti: "Tigrinya"
	, cs: "Tschechisch"
	, ts: "Tsonga"
	, tr: "Türkisch"
	, tk: "Turkmenisch"
	, ak: "Twi"
	, ug: "Uigurisch"
	, uk: "Ukrainisch"
	, hu: "Ungarisch"
	, ur: "Urdu"
	, uz: "Usbekisch"
	, vi: "Vietnamesisch"
	, cy: "Walisisch"
	, xh: "Xhosa"
	, yo: "Yoruba"
	, zu: "Zulu"}
     Return LanguageCodeArray[lang]
}
;------------------------------------------------------------------
GetGoogleLanguagesAndShortName:
GoogleLanguageCodes =
(
Afrikaans	af
Albanisch	sq
Amharisch	am
Arabisch	ar
Armenisch	hy
Aserbaidschanisch	az
Assamesisch	as
Aymara	ay
Bambara	bm
Baskisch	eu
Belarussisch	be
Bengalisch	bn
Bhojpuri	bho
Birmanisch	my
Bosnisch	bs
Bulgarisch	bg
Cebuano	ceb
Chichewa	ny
Chinesisch_traditionell	zh-TW
Chinesisch_vereinfacht	zh-CN
Dänisch	da
Deutsch	de
Dhivehi	dv
Dogri	doi
Englisch	en
Esperanto	eo
Estnisch	et
Ewe	ee
Filipino	tl
Finnisch	fi
Französisch	fr
Friesisch	fy
Galizisch	gl
Georgisch	ka
Griechisch	el
Guarani	gn
Gujarati	gu
Haitianisch	ht
Hausa	ha
Hawaiisch	haw
Hebräisch	iw
Hindi	hi
Hmong	hmn
Igbo	ig
Ilokano	ilo
Indonesisch	id
Irisch	ga
Isländisch	is
Italienisch	it
Japanisch	ja
Javanisch	jw
Jiddisch	yi
Kannada	kn
Kasachisch	kk
Katalanisch	ca
Khmer	km
Kinyarwanda	rw
Kirgisisch	ky
Konkani	gom
Koreanisch	ko
Korsisch	co
Krio	kri
Kroatisch	hr
Kurdisch_Kurmandschi	ku
Kurdisch_Sorani	ckb
Lao	lo
Latein	la
Lettisch	lv
Lingala	ln
Litauisch	lt
Luganda	lg
Luxemburgisch	lb
Maithili	mai
Malagasy	mg
Malayalam	ml
Malaysisch	ms
Maltesisch	mt
Maori	mi
Marathi	mr
Mazedonisch	mk
Meitei_Manipuri	mni-Mtei
Mizo	lus
Mongolisch	mn
Nepalesisch	ne
Niederländisch	nl
Norwegisch	no
Odia_Oriya	or
Oromo	om
Paschtu	ps
Persisch	fa
Polnisch	pl
Portugiesisch	pt
Punjabi	pa
Quechua	qu
Rumänisch	ro
Russisch	ru
Samoanisch	sm
Sanskrit	sa
Schottisch_Gälisch	gd
Schwedisch	sv
Sepedi	nso
Serbisch	sr
Sesotho	st
Shona	sn
Sindhi	sd
Singhalesisch	si
Slowakisch	sk
Slowenisch	sl
Somali	so
Spanisch	es
Sundanesisch	su
Swahili	sw
Tadschikisch	tg
Tamil	ta
Tatarisch	tt
Telugu	te
Thailändisch	th
Tigrinya	ti
Tschechisch	cs
Tsonga	ts
Türkisch	tr
Turkmenisch	tk
Twi	ak
Uigurisch	ug
Ukrainisch	uk
Ungarisch	hu
Urdu	ur
Usbekisch	uz
Vietnamesisch	vi
Walisisch	cy
Xhosa	xh
Yoruba	yo
Zulu	zu
)
;Chinesisch (traditionell)	zh-TW
;Chinesisch (vereinfacht)	zh-CN
;Kurdisch (Kurmandschi)	ku
;Kurdisch (Sorani)	ckb
;------------------------------------------------------------------
GetISOLanguageCodes:
LanguageCodes =
(
Afrikaans	Afrikaans	af	0436	Afrikaans
Albanian	Albanian	sq	041c	Albanisch
Algeria	Arabic_Algeria	ar	1401	Arabisch
Argentina	Spanish_Argentina	es	2c0a	Spanisch
Australian	English_Australian	en	0c09	Englisch
Austrian	German_Austrian	de	0c07	Deutsch
Azeri	Azeri_Cyrillic	az	082c	Aserbaidschanisch
Azeri	Azeri_Latin	az	042c	Aserbaidschanisch
Bahrain	Arabic_Bahrain	ar	3c01	Arabisch
Basque	Basque	eu	042d	Baskisch
Belarusian	Belarusian	be	0423	Belarussisch
Belgian	French_Belgian	fr	080c	Französisch
Belgian	Dutch_Belgian	nl	0813	Niederländisch
Belize	English_Belize	en	2809	Englisch
Bokmal	Norwegian_Bokmal	no	0414	Norwegisch
Bolivia	Spanish_Bolivia	es	400a	Spanisch
Brazilian	Portuguese_Brazilian	pt	0416	Portugiesisch
Brunei Darussalam	Malay_Brunei_Darussalam	ms	083e	Malaysisch
Bulgarian	Bulgarian	bg	0402	Bulgarisch
Canadian	English_Canadian	en	1009	Englisch
Canadian	French_Canadian	fr	0c0c	Französisch
Caribbean	English_Caribbean	en	2409	Englisch
Catalan	Catalan	ca	0403	Katalanisch
Chile	Spanish_Chile	es	340a	Spanisch
Colombia	Spanish_Colombia	es	240a	Spanisch
Costa Rica	Spanish_Costa_Rica	es	140a	Spanisch
Croatian	Croatian	hr	041a	Kroatisch
Czech	Czech	cs	0405	Tschechisch
Danish	Danish	da	0406	Dänisch
Dominican Republic	Spanish_Dominican_Republic	es	1c0a	Spanisch
Dutch	Dutch_Standard	nl	0413	Niederländisch
Ecuador	Spanish_Ecuador	es	300a	Spanisch
Egypt	Arabic_Egypt	ar	0c01	Arabisch
El Salvador	Spanish_El_Salvador	es	440a	Spanisch
Estonian	Estonian	et	0425	Estnisch
Finland	Swedish_Finland	sv	081d	Schwedisch
Finnish	Finnish	fi	040b	Finnisch
French	French_Standard	fr	040c	Französisch
Georgian	Georgian	ka	0437	Georgisch
German	German_Standard	de	0407	Deutsch
Greek	Greek	el	0408	Griechisch
Guatemala	Spanish_Guatemala	es	100a	Spanisch
Hebrew	Hebrew	iw	040d	Hebräisch
Hindi	Hindi	hi	0439	Hindi
Honduras	Spanish_Honduras	es	480a	Spanisch
Hong Kong	Chinese_Hong_Kong	zh-CN	0c04	Chinesisch (vereinfacht)
Hungarian	Hungarian	hu	040e	Ungarisch
Icelandic	Icelandic	is	040f	Isländisch
Indonesian	Indonesian	id	0421	Indonesisch
Iraq	Arabic_Iraq	ar	0801	Arabisch
Irish	English_Irish	en	1809	Englisch
Italian	Italian_Standard	it	0410	Italienisch
Jamaica	English_Jamaica	en	2009	Englisch
Japanese	Japanese	ja	0411	Japanisch
Jordan	Arabic_Jordan	ar	2c01	Arabisch
Korean	Korean	ko	0412	Koreanisch
Kuwait	Arabic_Kuwait	ar	3401	Arabisch
Latvian	Latvian	lv	0426	Lettisch
Lebanon	Arabic_Lebanon	ar	3001	Arabisch
Libya	Arabic_Libya	ar	1001	Arabisch
Liechtenstein	German_Liechtenstein	de	1407	Deutsch
Lithuanian	Lithuanian	lt	0427	Litauisch
Luxembourg	French_Luxembourg	fr	140c	Deutsch
Luxembourg	German_Luxembourg	de	1007	Französisch
Macau	Chinese_Macau	zh-CN	1404	Chinesisch (vereinfacht)
Macedonian	Macedonian	mk	042f	Mazedonisch
Malaysia	Malay_Malaysia	ms	043e	Malaysisch
Mexican	Spanish_Mexican	es	080a	Spanisch
Modern Sort	Spanish_Modern_Sort	es	0c0a	Spanisch
Monaco	French_Monaco	fr	180c	Französisch
Morocco	Arabic_Morocco	ar	1801	Arabisch
New Zealand	English_New_Zealand	en	1409	Englisch
Nicaragua	Spanish_Nicaragua	es	4c0a	Spanisch
Nynorsk	Norwegian_Nynorsk	no	0814	Norwegisch
Oman	Arabic_Oman	ar	2001	Arabisch
Panama	Spanish_Panama	es	180a	Spanisch
Paraguay	Spanish_Paraguay	es	3c0a	Spanisch
Peoples Republic of China	Chinese_PRC	zh-CN	0804	Chinesisch (vereinfacht)
Peru	Spanish_Peru	es	280a	Spanisch
Philippines	English_Philippines	en	3409	Englisch
Polish	Polish	pl	0415	Polnisch
Portuguese	Portuguese_Standard	pt	0816	Portugiesisch
Puerto Rico	Spanish_Puerto_Rico	es	500a	Spanisch
Romanian	Romanian	ro	0418	Rumänisch
Russian	Russian	ru	0419	Russisch
Saudi Arabia	Arabic_Saudi_Arabia	ar	0401	Arabisch
Serbian	Serbian_Cyrillic	sr	0c1a	Serbisch
Serbian Latin	Serbian_Latin	sr	081a	Serbisch
Singapore	Chinese_Singapore	zh-CN	1004	Chinesisch (vereinfacht)
Slovak	Slovak	sk	041b	Slowakisch
Slovenian	Slovenian	sl	0424	Slowenisch
South Africa	English_South_Africa	en	1c09	Englisch
Spanish	Spanish_Traditional_Sort	es	040a	Spanisch
Swahili	Swahili	sw	0441	Swahili
Swedish	Swedish	sv	041d	Schwedisch
Swiss	French_Swiss	fr	100c	Deutsch
Swiss	German_Swiss	de	0807	Französisch
Swiss	Italian_Swiss	it	0810	Italienisch
Syria	Arabic_Syria	ar	2801	Arabisch
Taiwan	Chinese_Taiwan	zh-CN	0404	Chinesisch (vereinfacht)
Tamil	Tamil	ta	0449	Tamil
Thai	Thai	th	041e	Thailändisch
Trinidad	English_Trinidad	en	2c09	Englisch
Tunisia	Arabic_Tunisia	ar	1c01	Arabisch
Turkish	Turkish	tr	041f	Türkisch
Ukrainian	Ukrainian	uk	0422	Ukrainisch
United Arab Emirates	Arabic_UAE	ar	3801	Arabisch
United Kingdom	English_United_Kingdom	en	0809	Englisch
United States	English_United_States	en	0409	Englisch
Urdu	Urdu	ur	0420	Urdu
Uruguay	Spanish_Uruguay	es	380a	Spanisch
Venezuela	Spanish_Venezuela	es	200a	Spanisch
Vietnamese	Vietnamese	vi	042a	Vietnamesisch
Yemen	Arabic_Yemen	ar	2401	Arabisch
Zimbabwe	English_Zimbabwe	en	3009	Englisch
)
Return 
 
;------------------------------
;------------------------------------------------------------------
ocr(file, lang := "ShowAvailableLanguages")
{
thisOCR := ""
global translateCounter
   static OcrEngineStatics, OcrEngine, MaxDimension, LanguageFactory, Language, CurrentLanguage, BitmapDecoderStatics, GlobalizationPreferencesStatics
   if (OcrEngineStatics = "")
   {
      CreateClass("Windows.Globalization.Language", ILanguageFactory := "{9B0252AC-0C27-44F8-B792-9793FB66C63E}", LanguageFactory)
      CreateClass("Windows.Graphics.Imaging.BitmapDecoder", IBitmapDecoderStatics := "{438CCB26-BCEF-4E95-BAD6-23A822E58D01}", BitmapDecoderStatics)
      CreateClass("Windows.Media.Ocr.OcrEngine", IOcrEngineStatics := "{5BFFA85A-3384-3540-9940-699120D428A8}", OcrEngineStatics)
      DllCall(NumGet(NumGet(OcrEngineStatics+0)+6*A_PtrSize), "ptr", OcrEngineStatics, "uint*", MaxDimension)   ; MaxImageDimension
   }
   if (file = "ShowAvailableLanguages")
   {
      if (GlobalizationPreferencesStatics = "")
         CreateClass("Windows.System.UserProfile.GlobalizationPreferences", IGlobalizationPreferencesStatics := "{01BF4326-ED37-4E96-B0E9-C1340D1EA158}", GlobalizationPreferencesStatics)
      DllCall(NumGet(NumGet(GlobalizationPreferencesStatics+0)+9*A_PtrSize), "ptr", GlobalizationPreferencesStatics, "ptr*", LanguageList)   ; get_Languages
      DllCall(NumGet(NumGet(LanguageList+0)+7*A_PtrSize), "ptr", LanguageList, "int*", count)   ; count
      loop % count
      {
         DllCall(NumGet(NumGet(LanguageList+0)+6*A_PtrSize), "ptr", LanguageList, "int", A_Index-1, "ptr*", hString)   ; get_Item
         DllCall(NumGet(NumGet(LanguageFactory+0)+6*A_PtrSize), "ptr", LanguageFactory, "ptr", hString, "ptr*", LanguageTest)   ; CreateLanguage
         DllCall(NumGet(NumGet(OcrEngineStatics+0)+8*A_PtrSize), "ptr", OcrEngineStatics, "ptr", LanguageTest, "int*", bool)   ; IsLanguageSupported
         if (bool = 1)
         {
            DllCall(NumGet(NumGet(LanguageTest+0)+6*A_PtrSize), "ptr", LanguageTest, "ptr*", hText)
            buffer := DllCall("Combase.dll\WindowsGetStringRawBuffer", "ptr", hText, "uint*", length, "ptr")
            text .= StrGet(buffer, "UTF-16") "`n"
         }
         ObjRelease(LanguageTest)
      }
      ObjRelease(LanguageList)
      return text
   }
   if (lang != CurrentLanguage) or (lang = "FirstFromAvailableLanguages")
   {
      if (OcrEngine != "")
      {
         ObjRelease(OcrEngine)
         if (CurrentLanguage != "FirstFromAvailableLanguages")
            ObjRelease(Language)
      }
      if (lang = "FirstFromAvailableLanguages")
         DllCall(NumGet(NumGet(OcrEngineStatics+0)+10*A_PtrSize), "ptr", OcrEngineStatics, "ptr*", OcrEngine)   ; TryCreateFromUserProfileLanguages
      else
      {
         CreateHString(lang, hString)
         DllCall(NumGet(NumGet(LanguageFactory+0)+6*A_PtrSize), "ptr", LanguageFactory, "ptr", hString, "ptr*", Language)   ; CreateLanguage
         DeleteHString(hString)
         DllCall(NumGet(NumGet(OcrEngineStatics+0)+9*A_PtrSize), "ptr", OcrEngineStatics, ptr, Language, "ptr*", OcrEngine)   ; TryCreateFromLanguage
      }
      if (OcrEngine = 0)
      {
         msgbox Can not use language "%lang%" for OCR, please install language pack.
         ExitApp
      }
      CurrentLanguage := lang
   }
   if (SubStr(file, 2, 1) != ":")
      file := A_ScriptDir "\" file
   if !FileExist(file) or InStr(FileExist(file), "D")
   {
      msgbox File "%file%" does not exist
      ExitApp
   }
   VarSetCapacity(GUID, 16)
   DllCall("ole32\CLSIDFromString", "wstr", IID_RandomAccessStream := "{905A0FE1-BC53-11DF-8C49-001E4FC686DA}", "ptr", &GUID)
   DllCall("ShCore\CreateRandomAccessStreamOnFile", "wstr", file, "uint", Read := 0, "ptr", &GUID, "ptr*", IRandomAccessStream)
   DllCall(NumGet(NumGet(BitmapDecoderStatics+0)+14*A_PtrSize), "ptr", BitmapDecoderStatics, "ptr", IRandomAccessStream, "ptr*", BitmapDecoder)   ; CreateAsync
   WaitForAsync(BitmapDecoder)
   BitmapFrame := ComObjQuery(BitmapDecoder, IBitmapFrame := "{72A49A1C-8081-438D-91BC-94ECFC8185C6}")
   DllCall(NumGet(NumGet(BitmapFrame+0)+12*A_PtrSize), "ptr", BitmapFrame, "uint*", width)   ; get_PixelWidth
   DllCall(NumGet(NumGet(BitmapFrame+0)+13*A_PtrSize), "ptr", BitmapFrame, "uint*", height)   ; get_PixelHeight
   if (width > MaxDimension) or (height > MaxDimension)
   {
      msgbox Image is to big - %width%x%height%.`nIt should be maximum - %MaxDimension% pixels
      ExitApp
   }
   BitmapFrameWithSoftwareBitmap := ComObjQuery(BitmapDecoder, IBitmapFrameWithSoftwareBitmap := "{FE287C9A-420C-4963-87AD-691436E08383}")
   DllCall(NumGet(NumGet(BitmapFrameWithSoftwareBitmap+0)+6*A_PtrSize), "ptr", BitmapFrameWithSoftwareBitmap, "ptr*", SoftwareBitmap)   ; GetSoftwareBitmapAsync
   WaitForAsync(SoftwareBitmap)
   DllCall(NumGet(NumGet(OcrEngine+0)+6*A_PtrSize), "ptr", OcrEngine, ptr, SoftwareBitmap, "ptr*", OcrResult)   ; RecognizeAsync
   WaitForAsync(OcrResult)
   DllCall(NumGet(NumGet(OcrResult+0)+6*A_PtrSize), "ptr", OcrResult, "ptr*", LinesList)   ; get_Lines
   DllCall(NumGet(NumGet(LinesList+0)+7*A_PtrSize), "ptr", LinesList, "int*", count)   ; count
   WordArray := []
   loop % count
   {
      LineIndex := A_Index
      DllCall(NumGet(NumGet(LinesList+0)+6*A_PtrSize), "ptr", LinesList, "int", A_Index-1, "ptr*", OcrLine)
      DllCall(NumGet(NumGet(OcrLine+0)+6*A_PtrSize), "ptr", OcrLine, "ptr*", WordsList)   ; get_Words
      DllCall(NumGet(NumGet(WordsList+0)+7*A_PtrSize), "ptr", WordsList, "int*", WordsCount)   ; Words count
      loop % WordsCount
      {
         DllCall(NumGet(NumGet(WordsList+0)+6*A_PtrSize), "ptr", WordsList, "int", A_Index-1, "ptr*", OcrWord)
         VarSetCapacity(RECT, 16, 0)
         DllCall(NumGet(NumGet(OcrWord+0)+6*A_PtrSize), "ptr", OcrWord, "ptr", &RECT)   ; get_BoundingRect
         DllCall(NumGet(NumGet(OcrWord+0)+7*A_PtrSize), "ptr", OcrWord, "ptr*", hText)   ; get_Text
         buffer := DllCall("Combase.dll\WindowsGetStringRawBuffer", "ptr", hText, "uint*", length, "ptr")
         x := Round(NumGet(&RECT, 0, "float"))
         y := Round(NumGet(&RECT, 4, "float"))
         w := Round(NumGet(&RECT, 8, "float"))
         h := Round(NumGet(&RECT, 12, "float"))
         text := StrGet(buffer, "UTF-16")
         thisOCR .=  text A_Space ; *************************************************************************************
         WordArray[LineIndex, A_Index] := [x, y, w, h, text]
         ObjRelease(OcrWord)
      }
      ObjRelease(WordsList)
      ObjRelease(OcrLine)
   }
   Close := ComObjQuery(IRandomAccessStream, IClosable := "{30D5A829-7FA4-4026-83BB-D75BAE4EA99E}")
   DllCall(NumGet(NumGet(Close+0)+6*A_PtrSize), "ptr", Close)   ; Close
   ObjRelease(Close)
   Close := ComObjQuery(SoftwareBitmap, IClosable := "{30D5A829-7FA4-4026-83BB-D75BAE4EA99E}")
   DllCall(NumGet(NumGet(Close+0)+6*A_PtrSize), "ptr", Close)   ; Close
   ObjRelease(Close)
   ObjRelease(IRandomAccessStream)
   ObjRelease(BitmapDecoder)
   ObjRelease(BitmapFrame)
   ObjRelease(BitmapFrameWithSoftwareBitmap)
   ObjRelease(SoftwareBitmap)
   ObjRelease(OcrResult)
   ObjRelease(LinesList)
/*
clipOld := clipboardall
clipboard := thisOCR
FileAppend,% thisOCR "`n###########################################################`n" 
		, % (ANow "-OcrErgebnis.txt"), UTF-8
 gT()
FileAppend,% clipBoard  "`n###########################################################`n" 
		, % (ANow "-OcrTranslateErgebnis.txt"), UTF-8
clipBoard := clipOld
thisOCR := ""
*/
;	translateCounter++
   return thisOCR
;   return WordArray
}
; ----------------------------------------------------------------------------------------------------------------------
CreateClass(string, interface, ByRef Class)
{
   CreateHString(string, hString)
   VarSetCapacity(GUID, 16)
   DllCall("ole32\CLSIDFromString", "wstr", interface, "ptr", &GUID)
   result := DllCall("Combase.dll\RoGetActivationFactory", "ptr", hString, "ptr", &GUID, "ptr*", Class, "uint")
   if (result != 0)
   {
      if (result = 0x80004002)
         msgbox No such interface supported
      else if (result = 0x80040154)
         msgbox Class not registered
      else
         msgbox error: %result%
      ExitApp
   }
   DeleteHString(hString)
}
; ----------------------------------------------------------------------------------------------------------------------
CreateHString(string, ByRef hString)
{
    DllCall("Combase.dll\WindowsCreateString", "wstr", string, "uint", StrLen(string), "ptr*", hString)
}
; ----------------------------------------------------------------------------------------------------------------------
DeleteHString(hString)
{
   DllCall("Combase.dll\WindowsDeleteString", "ptr", hString)
}
; ----------------------------------------------------------------------------------------------------------------------
WaitForAsync(ByRef Object)
{
   AsyncInfo := ComObjQuery(Object, IAsyncInfo := "{00000036-0000-0000-C000-000000000046}")
   loop
   {
      DllCall(NumGet(NumGet(AsyncInfo+0)+7*A_PtrSize), "ptr", AsyncInfo, "uint*", status)   ; IAsyncInfo.Status
      if (status != 0)
      {
         if (status != 1)
         {
            DllCall(NumGet(NumGet(AsyncInfo+0)+8*A_PtrSize), "ptr", AsyncInfo, "uint*", ErrorCode)   ; IAsyncInfo.ErrorCode
            msgbox AsyncInfo status error: %ErrorCode%
            ExitApp
         }
         ObjRelease(AsyncInfo)
         break
      }
      sleep 10
   }
   DllCall(NumGet(NumGet(Object+0)+8*A_PtrSize), "ptr", Object, "ptr*", ObjectResult)   ; GetResults
   ObjRelease(Object)
   Object := ObjectResult
}
;##################################################
;https://www.autohotkey.com/boards/viewtopic.php?p=381405#p381405 by teadrinker 11. Feb 2021 16:08
/*
text =
(
@teadrinker - I've used your script a minute ago (and now it looks that I've got blocked :shh:) so, time to ask ...
Has your updated script taken the before mentioned condition already into account? I thought about to translate the transcription of YouTube videos so people from abroad will have a chance to better follow its (German) speaker. Higher translation quality would shrink the time of necessarry corrections.
)
arr := SplitText(text, 200)
for k, v in arr
   MsgBox, % v
*/
SplitText(text, max := 5000) {
   chunks := [], text .= ".", pos := 1
   Loop {
      for k, v in ["\.", "!", "\?", ";", ",", ":", "\(", "\)", " ", "$"]
         RegExMatch(SubStr(text, pos, max), "sO).+" . v . "+", m)
      until m.Len
      chunks.Push(m[0])
      pos += m.Len
   } until pos > StrLen(text)
   last := chunks.Pop()
   chunks.Push( SubStr(last, 1, -1) )
   Return chunks
}
; -------------------------------------------------------
;##################################################
;https://www.autohotkey.com/boards/viewtopic.php?p=381432#p381432 by bobo 11. Feb 2021 20:40
;SetWorkingDir,% A_ScriptDir  
;#Include GoogleTranslate().ahk		; Download: https://www.autohotkey.com/boards/viewtopic.php?t=63835 by teadrinker
; gT("input.txt","output.txt")		; eingabe aus datei, ausgabe in datei
; gT("input.txt")			; eingabe aus datei, ausgabe in zwischenablage
; gT()					; eingabe aus zwischenablage, ausgabe in zwischenablage
gT(inFile:="",outFile:="") {
global thisISOLanguageCode
	content := (inFile != "") ? fRead(inFile) : clip()			; auslesen der datei, oder CTRL+C in zwischenablage
	chars := StrSplit(content)						; content in einzelne Zeichen zerlegen
	GetISOLanguageCode := GetISOLanguageCode()
	Loop % chars.count() {
		if	(mod(A_Index,5000) = 0 || A_Index = chars.count()) {	; sobald textblock 5K zeichen erreicht, oder Anzahl restzeichen enthält ...
			trl .= GoogleTranslate(str,"auto",thisISOLanguageCode)	; textblock-übergabe an Google-Translate. Ergebnis konkatenieren.
;			trl .= GoogleTranslate(str,"auto",GetISOLanguageCode())	; textblock-übergabe an Google-Translate. Ergebnis verketten.
			str:=""							; textblock leeren
			}
		Else 
			str .= chars[A_Index]					; textblock befüllen
		}
;	SoundBeep								; feierabendbiersignalindikator
;	Return clipboard := (outFile != "") ? fWrite(outFile,trl) : trl		; schreiben in datei, oder ausgabe in zwischenablage
	Return (outFile != "") ? fWrite(outFile,trl) : trl			; schreiben in datei, oder ausgabe in zwischenablage
	}
clip() {
	Send ^c
	ClipWait
	Return clipboard
	}
fRead(inFile) {
	FileRead, content,% inFile
	Return content
	}
fWrite(outFile,trl) {
	response := (trl = "") ? "Translation failed" : "File created." 
	FileAppend,% trl,% outFile, UTF-8					; https://www.autohotkey.com/docs/commands/FileEncoding.htm
	Return response
	} 
;##################################################
; https://www.autohotkey.com/boards/viewtopic.php?t=63835 by teadrinker
;MsgBox, % GoogleTranslate("今日の天気はとても良いです")
;MsgBox, % GoogleTranslate("Hello, World!", "en", "ru")
GoogleTranslate(str, from := "auto", to := "de") {
   static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")
global   	translateCounter
translateCounter++
   json := SendRequest(JS, str, to, from, proxy := "")
   oJSON := JS.("(" . json . ")")
	thisXXX :=  	GetISOCodeA(to) 
			? GetISOCodeA(to) 
			: GetISOCodeB(to) 
			. a_space to
	fileAppend,% BeautifyJson(json),% a_tickcount a_space thisXXX ".json", UTF-8
	global AhkObj := JsonToAHK(json)
	global thisjson := json
   if !IsObject(oJSON[1]) {
      Loop % oJSON[0].length
         trans .= oJSON[0][A_Index - 1][0]
   }
   else {
      MainTransText := oJSON[0][0][0]
      Loop % oJSON[1].length {
         trans .= "`n+"
         obj := oJSON[1][A_Index-1][1]
         Loop % obj.length {
            txt := obj[A_Index - 1]
            trans .= (MainTransText = txt ? "" : "`n" txt)
         }
      }
   }
   if !IsObject(oJSON[1])
      MainTransText := trans := Trim(trans, ",+`n ")
   else
      trans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")
   from := oJSON[2]
   trans := Trim(trans, ",+`n ")
   Return trans
}
SendRequest(JS, str, tl, sl, proxy) {
   static http
   ComObjError(false)
   if !http
   {
      http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
      ( proxy && http.SetProxy(2, proxy) )
      http.open("GET", "https://translate.google.com", true)
      http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
      http.send()
      http.WaitForResponse(-1)
   }
   http.open("POST", "https://translate.googleapis.com/translate_a/single?client=gtx"
                ; or "https://clients5.google.com/translate_a/t?client=dict-chrome-ex"
      . "&sl=" . sl . "&tl=" . tl . "&hl=" . tl
      . "&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=0&ssel=0&tsel=0&pc=1&kc=1"
      . "&tk=" . JS.("tk").(str), true)
   http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
   http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
   http.send("q=" . URIEncode(str))
   http.WaitForResponse(-1)
   Return http.responsetext
}
URIEncode(str, encoding := "UTF-8")  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &var, encoding)
   while code := NumGet(Var, A_Index - 1, "UChar")  {
      bool := (code > 0x7F || code < 0x30 || code = 0x3D)
      UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)
   }
   Return UrlStr
}
GetJScript()
{
   script =
   (
      var TKK = ((function() {
        var a = 561666268;
        var b = 1526272306;
        return 406398 + '.' + (a + b);
      })());
      function b(a, b) {
        for (var d = 0; d < b.length - 2; d += 3) {
            var c = b.charAt(d + 2),
                c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),
                c = "+" == b.charAt(d + 1) ? a >>> c : a << c;
            a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c
        }
        return a
      }
      function tk(a) {
          for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {
              var c = a.charCodeAt(f);
              128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ?
              (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240,
              g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
          }
          a = h;
          for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");
          a = b(a, "+-3^+b+-f");
          a ^= Number(e[1]) || 0;
          0 > a && (a = (a & 2147483647) + 2147483648);
          a `%= 1E6;
          return a.toString() + "." + (a ^ h)
      }
   )
   Return script
}
CreateScriptObj() {
   static doc, JS, _JS
   if !doc {
      doc := ComObjCreate("htmlfile")
      doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
      JS := doc.parentWindow
      if (doc.documentMode < 9)
         JS.execScript()
      _JS := ObjBindMethod(JS, "eval")
   }
   Return _JS
}
;#####################################################################
JsonToAHK(json, rec := false) {
   static doc := ComObjCreate("htmlfile")
         , __ := doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
         , JS := doc.parentWindow
   if !rec
      obj := %A_ThisFunc%(JS.eval("(" . json . ")"), true)
   else if !IsObject(json)
      obj := json
   else if JS.Object.prototype.toString.call(json) == "[object Array]" {
      obj := []
      Loop % json.length
         obj.Push( %A_ThisFunc%(json[A_Index - 1], true) )
   }
   else {
      obj := {}
      keys := JS.Object.keys(json)
      Loop % keys.length {
         k := keys[A_Index - 1]
         obj[k] := %A_ThisFunc%(json[k], true)
      }
   }
   Return obj
}
;##########################################################################
; https://www.autohotkey.com/boards/viewtopic.php?p=353444#p353444 by teadrinker
;MsgBox, % BeautifyJson(json)
BeautifyJson(json, indent := "    ") {
   static Doc, JS
   if !Doc {
      Doc := ComObjCreate("htmlfile")
      Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
      JS := Doc.parentWindow
   }
  try Return JS.eval("JSON.stringify(" . json . ",'','" . indent . "')")
}
;----------------------------------------------------------------------
Month(thisMonth) {
		Month := strSplit("Jan,Feb,Mrz,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez",",")
		return Month[thisMonth]
}
ConvertToMilliseconds(HHMMSSMS)
{
   Sekunden := A_YYYY . "0101" . StrReplace(SubStr(HHMMSSMS, 1, 8), ":")
   Sekunden -= A_YYYY, S
   Return (Sekunden * 1000) + SubStr(HHMMSSMS, 10)
}
ConvertToHHMMSSMS(Millisekunden)
{
   Zeitstempel := A_YYYY ; nur der Deutlichkeit halber, AHK rechnet auch mit leeren Variablen
   Zeitstempel += % (Millisekunden // 1000), S
   FormatTime, HHMMSS, %Zeitstempel%, HH:mm:ss
   Return (HHMMSS . Format(",{:03}", Mod(Millisekunden, 1000)))
}
;#####################################################################################################
;------------
; zoomfactor:=((A_ScreenWidth/1920)*(96/A_ScreenDPI))
; wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
;-
;-
thisZoomFactorFontVerdanaPro_(factor) {
return (factor*((A_ScreenWidth/1920)*(96/A_ScreenDPI))) " , Verdana Pro"
}
thisZoomFactorBold(factor) {
global
return "s" (factor*zoomfactor) " , Comic Sans MS bold"
}
thisZoomFactorNormal(factor) {
global
;return "s" 10 " , Terminal " 
return "s" (factor*zoomfactor) " , Comic Sans MS" 
}
thisZoomFactorFontVerdanaPro(factor) { ; ab win 10
global
return "s" (factor*zoomfactor) " , Verdana Pro" 
}
thisX(factor) {
global
return	" x" (wa*factor)/xx
}
thisY(factor) {
global
return	" y" (ha*factor)/xx 
}
thisW(factor) {
global
return	" w" (wa*factor)/xx
}
thisH(factor) {
global
return	" h" (ha*factor)/xx 
}
esc::exitapp

effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

29 Feb 2024, 09:51

@garry -dpiscale hatte ich vergessen, ist drin!
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

29 Feb 2024, 10:39

danke, alles OK , weiss nicht ob dies möglich ist dass vom Bild jede Schriftsysteme erkennbar sind ( chinesisch etc )
hier lediglich auch Problem mit den wenigen portugiesische Zeichen :
A recomendação > im EDIT1= A recomendaqäo
( für andere Schriftsysteme > Google-Lens : https://www.google.com/?olud )
;-
... und die erstellten Dateien (txt,json) in einem separaten Unter-Ordner ablegen ( getrennt vom AHK-Skript/Programm )
effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

01 Mar 2024, 23:18

Hallo @garry
garry wrote:
29 Feb 2024, 10:39
weiss nicht ob dies möglich ist dass vom Bild jede Schriftsysteme erkennbar sind ( chinesisch etc )
Das liegt wohl an der OCR() Funktion, diese habe ich nicht selber erstellt, ich glaube das sie, wie du oben schon erwähnt hast evt. nur lateinische Schrift erkennen kann. Aber vielleicht findet sich dazu eine alternative Funktion
... und die erstellten Dateien (txt,json) in einem separaten Unter-Ordner ablegen ( getrennt vom AHK-Skript/Programm )
Das ist erledigt. Die Dateien liegen in \done\timestamp\

Die json Datei wird nicht mehr gespeichert, hatte sie nur zum überprüfen gespeichert. wenn du sie jedoch haben möchtest findest du sie hiermit
fileAppend,% BeautifyJson(json),% a_tickcount a_space thisXXX ".json", UTF-8 im Code

Im Moment bin ich erstmal damit beschäftigt das Layout der GUI zu zeichnen. Macht Spaß aber dauert sicher noch etwas, bis ich fertig bin.

Code ist Updated


So schaut es im Moment aus, passt das noch auf deinem 4K Screen überein?

Ich hoffe das meine Google Translate Übersetzungen für das Layout der GUI so korrekt ist, ansonsten wäre auch hier Kritik willkommen!

797ee65b9104da471ef7e58cab5994419d66f12c.jpg
797ee65b9104da471ef7e58cab5994419d66f12c.jpg (214.25 KiB) Viewed 318 times

Diese Sprachen habe ich meinem Win 10 hinzugefügt:
03_02_24 @5_24_36.PNG
03_02_24 @5_24_36.PNG (42.95 KiB) Viewed 316 times
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

02 Mar 2024, 02:50

@effel
Danke für Deine grosse Arbeit , funktioniert gut , die Details kann ich anpassen.
( betr. GUI, mein letztes Beispiel war Fullsize , habe mit 4K-3840 und FullHD-1920 getestet )
20240302084513_screenshot.png
20240302084513_screenshot.png (592.37 KiB) Viewed 311 times
effel
Posts: 546
Joined: 16 Jan 2018, 13:34

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

02 Mar 2024, 03:06

@garry,

danke für die schnelle Antwort!
Ich sehe das es keine gute Idee war, die beiden Buttons oberhalb des Tab3 zu platzieren, werde sie wieder entfernen.

schönes Wochenende
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: Gelöst! --- Batch OCR & Translate Script dreht extra Runden

02 Mar 2024, 03:53

@effel danke , kein Problem
habe für mich x y w h angepasst
wichtig ist dass das Program funktioniert , kann Dir evtl Privat message senden betreff Grösse/Position ( wobei dies z.T. individuell ist )
20240302094921_screenshot.png
20240302094921_screenshot.png (623.04 KiB) Viewed 304 times

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 62 guests