• Home
  • Index
  • Search
  • Download
  • Server Rules
  • House Roleplay Laws
  • Player Utilities
  • Player Help
  • Forum Utilities
  • Returning Player?
  • Toggle Sidebar
Interactive Nav-Map
Tutorials
New Wiki
ID reference
Restart reference
Players Online
Player Activity
Faction Activity
Player Base Status
Discord Help Channel
DarkStat
Server public configs
POB Administration
Missing Powerplant
Stuck in Connecticut
Account Banned
Lost Ship/Account
POB Restoration
Disconnected
Member List
Forum Stats
Show Team
View New Posts
View Today's Posts
Calendar
Help
Archive Mode




Hi there Guest,  
Existing user?   Sign in    Create account
Login
Username:
Password: Lost Password?
 
  Discovery Gaming Community Welcome Help & Support Tutorials & Tools Community Activity Guides Tutorial: Google Translate and Super Setmsg

Server Time (24h)

Players Online

Active Events - Scoreboard

Latest activity

Tutorial: Google Translate and Super Setmsg
Offline darkwind
01-18-2020, 07:05 PM, (This post was last modified: 09-02-2020, 08:55 PM by darkwind.)
#1
Frontier Sheriff
Posts: 1,158
Threads: 138
Joined: Oct 2019
Staff roles:
Coding Developer

Inspired by this guide I wished to improve things, to make using Google Translator even easier
Plus having setmsg working across all characters, instead of binding every time phrases for every account.

As in the guide which me inspired, you need to install this program

Basically, you create notepad file named Something.ahk
you insert code there, slightly redacting it, Right Click at file and choose "Run Script", your program is running.



If you wish to have setmsg working across all characters, you make something like this. All those phrases are working, when I write .g1 or .w1 or .s1 in chat. They are automatically replaced with what is written there.
[+]Setmsg
Code:
Hotstring("EndChars", "")
:*:.g1::You phrase number 1
:*:.g2::You phrase number 2
:*:.g3::You phrase number 3

:*:.s1::You phrase number 4
:*:.s2::You phrase number 5

:*:.w1::You phrase number 6
:*:.w2::You phrase number 7
Due to being external, it works across all characters.
+You can have as much setmsg phrases as you wish. Feel free to use from .s1 to .s9, from .g1 to .g9, and e.t.c.



Next thing enables Ctrl+V also knows as Paste, copying text from buffer/clipboard to Freelancer chat (you can insert things into the clipboard by selecting something in Google Translate and pressing Ctrl+C or right-click and copy and e.t.c.)
[+]Working Ctrl V
Code:
#IfWinActive Freelancer
^v::
  Temp := StrReplace(clipboard, "`r`n", " ")
  SendInput, %Temp%
  return
Two differences from guide I used as inspiration. Mine works faster due to SendInput usage(1000 times faster), and if you have newlines, they are automatically replaced to whitespaces to not have auto pressing mistakes.



Also I made thing which copies six last phrases from chat. Which you can insert immediately into Google Translate! Without opening log file. Resolves problem of not having ability to copy from chat
[+]Copying and Pasting last six phrases from log file
Code:
Extractor()
{
Array := Array()
    Loop, read, %A_MyDocuments%\My Games\Freelancer\DSAce.log
    {
        last_line := A_LoopReadLine

        numberWhere := RegExMatch(last_line, "^.*\d{2}\].(?!(Death:))(?!(Tip:))[^\s]+.: .*$")
        if (numberWhere > 0)
        {    
            Array.InsertAt(0,last_line)
            RemovedValue := Array.RemoveAt(6)
        }
    }
    
    Counter:=5
    While(Counter >= 0)
    {
        Temp := Array[Counter]
        SendInput, %Temp%`r
        Counter--
    }
    return
}    

#IfWinNotActive Freelancer
!v::
  Extractor()
  return    

:*:.log::
  Extractor()
  return
It's activated by pressing Alt+V or by writing .log
to work correctly this C:\Users\User\Documents\My Games\Freelancer\DSAce.log address should be leading to your log file, correct it if it's wrong.



And the last thing I tried, to make an automated thing, what you write in chat to be translated into the English language on its own. It works slightly weird, but it works.

You write .gt in your ingame chat, which makes it dissapear(You can replace it to something different, to your language letters), then write in your language phrases, and press Esc canceling phrase(or pressing Enter) to send it, it will translate anyway.
It requires for you to have Freelancer working in window, and then it opens Google Chrome, automatically translates, copies from there, and returns to game to copy into chat. You remain ability to press Enter to send it or not to send it.
[+]Write while translating
Code:
:*:.gt::
  Input, Temp, V, {Esc}{Enter}.
  Run, Chrome.exe
  Sleep, 1000
  IfWinNotActive, Freelancer
  {
    Temp := StrReplace(Temp, A_Space, "%20")
    SendInput, {Raw}

https://translate.google.com/#view=home&op=translate&sl=auto&tl=en&text=%Temp%
    SendInput, {Enter}
    Sleep, 5000
    SendInput, ^+s
    Sleep, 500
    SendInput, {F6}
    Sleep, 500
    SendInput, ^c
    SendInput, ^{F4}
    Sleep, 500
    FoundPos := InStr(clipboard, "text=") + 5
    Temp := SubStr(clipboard,FoundPos)
    Temp := StrReplace(Temp, "%20", " ")
    Temp := StrReplace(Temp, "%2C", ",")
    Temp := StrReplace(Temp, "%3F", "?")
    SendInput, {Esc}{Enter}%Temp%
  }
  
  return



Anyway, all those things combined into one scripting file
[+]Full Code
Code:
#IfWinActive Freelancer
#MaxThreadsPerHotkey 255
Hotstring("EndChars", "")

Extractor()
{
Array := Array()
    Loop, read, C:\Users\User\Documents\My Games\Freelancer\DSAce.log
    {
        last_line := A_LoopReadLine

        numberWhere := RegExMatch(last_line, "^.*\d{2}\].(?!(Death:))(?!(Tip:))[^\s]+.: .*$")
        if (numberWhere > 0)
        {    
            Array.InsertAt(0,last_line)
            RemovedValue := Array.RemoveAt(6)
        }
    }
    
    Counter:=5
    While(Counter >= 0)
    {
        Temp := Array[Counter]
        SendInput, %Temp%`r
        Counter--
    }
    return
}    

:*:.g1::You phrase number 1
:*:.g2::You phrase number 2
:*:.g3::You phrase number 3

:*:.s1::You phrase number 4
:*:.s2::You phrase number 5

:*:.w1::You phrase number 6
:*:.w2::You phrase number 7

:*:btw::by the way
return

:*:.gt::
  Input, Temp, V, {Esc}{Enter}.
  Run, Chrome.exe
  Sleep, 1000
  IfWinNotActive, Freelancer
  {
    Temp := StrReplace(Temp, A_Space, "%20")
    SendInput, {Raw}

https://translate.google.com/#view=home&op=translate&sl=auto&tl=en&text=%Temp%
    SendInput, {Enter}
    Sleep, 5000
    SendInput, ^+s
    Sleep, 500
    SendInput, {F6}
    Sleep, 500
    SendInput, ^c
    SendInput, ^{F4}
    Sleep, 500
    FoundPos := InStr(clipboard, "text=") + 5
    Temp := SubStr(clipboard,FoundPos)
    Temp := StrReplace(Temp, "%20", " ")
    Temp := StrReplace(Temp, "%2C", ",")
    Temp := StrReplace(Temp, "%3F", "?")
    SendInput, {Esc}{Enter}%Temp%
  }
  
  return
  

^v::
  Temp := StrReplace(clipboard, "`r`n", " ")
  SendInput, %Temp%
  return

#IfWinNotActive Freelancer
!v::
  Extractor()
  return    

:*:.log::
  Extractor()
  return

All except for "Write while translating" works very well, last thing is working too, but it just... you know, slightly less certain thing to use due to windows switching.

Perhaps it is possible to improve the last thing, but I need to find free API which would be translating it for me.

P.S. For people who have a hard time to follow this guide. Configured exe to enable CtrlV only. You can download here.


Interstellar Autogit Ctrl-V Encryptor Discovery At Linux
Dark Tools DarkBot DarkLint DarkStat DarkMap
Reply  


Messages In This Thread
Tutorial: Google Translate and Super Setmsg - by darkwind - 01-18-2020, 07:05 PM
RE: Tutorial: Google Translate and Super Setmsg - by Liberty.In - 01-18-2020, 07:32 PM
RE: Tutorial: Google Translate and Super Setmsg - by Dom!no - 07-12-2020, 05:33 PM
RE: Tutorial: Google Translate and Super Setmsg - by Groshyr - 07-12-2020, 05:36 PM
RE: Tutorial: Google Translate and Super Setmsg - by Dom!no - 07-12-2020, 05:52 PM
RE: Tutorial: Google Translate and Super Setmsg - by Save My Soul - 07-12-2020, 05:55 PM
RE: Tutorial: Google Translate and Super Setmsg - by Shiki - 07-12-2020, 05:57 PM
RE: Tutorial: Google Translate and Super Setmsg - by Dom!no - 07-12-2020, 05:57 PM
RE: Tutorial: Google Translate and Super Setmsg - by Groshyr - 07-12-2020, 06:03 PM
RE: Tutorial: Google Translate and Super Setmsg - by Corile - 07-12-2020, 08:15 PM
RE: Tutorial: Google Translate and Super Setmsg - by Champ - 07-12-2020, 11:46 PM
RE: Tutorial: Google Translate and Super Setmsg - by Dom!no - 07-13-2020, 10:08 PM
RE: Tutorial: Google Translate and Super Setmsg - by darkwind - 08-04-2020, 07:27 PM

  • View a Printable Version
  • Subscribe to this thread


Users browsing this thread:
1 Guest(s)



Powered By MyBB, © 2002-2025 MyBB Group. Theme © 2014 iAndrew & DiscoveryGC
  • Contact Us
  •  Lite mode
Linear Mode
Threaded Mode