Vindicator209 Posted August 5, 2008 Share Posted August 5, 2008 (edited) Okay, I don't know how many of you have ever tried using a program in a foreign language(that your not familiar with). Well, for me, its impossible. In my case it was a german program called Game Jack. And all the buttons and labels and stuff, it was ALL german! So I figured since I had time, I'd build a program that would search up all those controls, translate their text using google, and shove them right back in. and this was the result(please read bottom(of this post) also before using): expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <Array.au3> #include <IE.au3> $Form1 = GUICreate("Englishize it!", 240, 140, 193, 125) $Group1 = GUICtrlCreateGroup("Step 1: Choose the Window", 10, 10, 220, 50) $Combo1 = GUICtrlCreateCombo("-Select a Window-", 20, 30, 200, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Step 2: Englishize it!", 10, 65, 220, 60) $Button3 = GUICtrlCreateButton("Do it!", 20, 85, 200, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) $win = WinList() _ArraySort($win, 0, 1, $win[0][0], 2) For $i = 1 To $win[0][0] If $win[$i][0] <> "" And IsVisible($win[$i][1]) Then GUICtrlSetData($Combo1, $win[$i][0]) EndIf Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button3 $prevclip = ClipGet() $Edits = 0 $Buttons = 0 $ComboBoxes = 0 $Statics = 0 $classlist = WinGetClassList(GUICtrlRead($Combo1), "") $controls = StringSplit($classlist, @LF) $newline = "" $conts = "" For $i = 1 To $controls[0] If $controls[$i] = "Edit" Then $Edits += 1 $newline = $newline & "\Edit" & $Edits EndIf If $controls[$i] = "Button" Then $Buttons += 1 $newline = $newline & "\Button" & $Buttons EndIf If $controls[$i] = "ComboBox" Then $ComboBoxes += 1 $newline = $newline & "\ComboBox" & $ComboBoxes EndIf If $controls[$i] = "Static" Then $Statics += 1 $newline = $newline & "\Static" & $Statics EndIf Next $newline = StringTrimLeft($newline, 1) For $w = 1 To $Edits $conts = $conts & "\" & ControlGetText(GUICtrlRead($Combo1), "", "Edit" & $w) Next $conts = $conts & "[x]" For $w = 1 To $Buttons $conts = $conts & "\" & ControlGetText(GUICtrlRead($Combo1), "", "Button" & $w) Next $conts = $conts & "[x]" For $w = 1 To $ComboBoxes $conts = $conts & "\" & ControlGetText(GUICtrlRead($Combo1), "", "ComboBox" & $w) Next $conts = $conts & "[x]" For $w = 1 To $Statics $conts = $conts & "\" & ControlGetText(GUICtrlRead($Combo1), "", "Static" & $w) Next $conts = StringReplace($conts, "&", "") $oIE = _IECreate("http://translate.google.com/translate_t?sl=auto&tl=en", 0, 1) $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetObjByName($oForm, "text") _IEFormElementSetValue($oQuery, $conts) Send("{TAB}{TAB}{TAB}{ENTER}") _IELoadWait($oIE) $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetObjByName($oForm, "text") _IEFormElementSetValue($oQuery, "") Sleep(1000) Send("{TAB}^a^c") $rawclip = ClipGet() $rawclip = StringSplit($rawclip, @LF) $trans = $rawclip[9] $trans = StringSplit($trans, "[x]", 1) $rep = StringSplit($trans[1], "\") For $i = 1 To $rep[0] ControlSetText(GUICtrlRead($Combo1), "", "Edit" & $i - 1, $rep[$i]) Next $rep = StringSplit($trans[2], "\") For $i = 1 To $rep[0] ControlSetText(GUICtrlRead($Combo1), "", "Button" & $i - 1, $rep[$i]) Next $rep = StringSplit($trans[3], "\") For $i = 1 To $rep[0] ControlSetText(GUICtrlRead($Combo1), "", "ComboBox" & $i - 1, $rep[$i]) Next $rep = StringSplit($trans[4], "\") For $i = 1 To $rep[0] ControlSetText(GUICtrlRead($Combo1), "", "Static" & $i - 1, $rep[$i]) Next ClipPut($prevclip) _IEQuit($oIE) MsgBox(64, "Complete", "has been sucessfully translated to english." & @CRLF & @CRLF & @CRLF & "Note that this program used Google's Translator, and can only translate whatever" & @CRLF & "languages Google can recognize." & @CRLF & "Also note that this program only works for Edits, Buttons, Combo Boxes, and Statics.") Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible I know it's a bit rough, using IE and macroing the tabs & copying, but it gets the job done. Basically it grabs all the text in the window(buttons, edits, combo boxes, and statics, to be exact) strings them all together, opens up google translator, where it sends(well, technically "settext"s) the string of text into the box, presses translate(using TAB and ENTEr), copies all the text, extracts the translation, divides the translated text up, and puts them back in their rightful place. It took me quite a while because I was trying to find ways of avoiding "macroing" out the keys (tab, ctrl + A, stuff like that) but I ended up not caring because it's midnight and all I want to really do is play my dang game using game jack. It can only translate the languages that Google recognizes ...so don't come to me if it can't translate Arabic... EDIT: CRAP I think someone might've already done this.... Edit: scratch the last edit, the other ones I found were just regular ol' translators Edited August 5, 2008 by VindicatorOmega [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Distrophy Posted August 5, 2008 Share Posted August 5, 2008 Hey, thats a really cool idea. Good work. Link to comment Share on other sites More sharing options...
Valuater Posted August 5, 2008 Share Posted August 5, 2008 Needs a little love, but.... Great Idea!!! 8) Link to comment Share on other sites More sharing options...
SxyfrG Posted August 5, 2008 Share Posted August 5, 2008 Nice idea, maybe this could come in handy with my printer ... it's help dialog is all in an Asian language (i think thai) My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website Link to comment Share on other sites More sharing options...
Vindicator209 Posted August 5, 2008 Author Share Posted August 5, 2008 Needs a little love, but.... Great Idea!!!And by "love", I assume refining? Yea, I'll get on that, I was a bit rushed because it was getting late and I won't have time the next day... [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now