Windows Services & Other Stuff

Developed or developing a new product in PureBasic? Tell the world about it.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Hi Wolf,

You are most welcome.

-------------------------------------------

Updated:
- numerous improvements, bug fixes, and a few additions since my last post

NB*: See the first post for a complete list of examples.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Updated:
- numerous updates and some bug fixes

Since the release of PureBasic 5.72 LTS Beta 1 (thank you Fred, Freak & Team) I proceeded to test every example, updating and patching as required.

NB*: Some examples may not work in older versions of PureBasic.

-----------------------------------------

Updated:
- added \Other_Stuff\OtherStuff\CommandConsole\ReadOutput.pb
- added \Other_Stuff\OtherStuff\GoogleTranslate.pb
- added \Other_Stuff\OtherStuff\WindowsMagnificationAPI.pb

Read Output: Based on a question posted by tatanas.
Google Translate: Based on a question posted by ricardo.
Windows Magnification API: Based on a question posted by BarryG.
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Windows Services & Other Stuff

Post by ricardo »

JHPJHP wrote:Updated:
- numerous updates and some bug fixes

Since the release of PureBasic 5.72 LTS Beta 1 (thank you Fred, Freak & Team) I proceeded to test every example, updating and patching as required.

NB*: Some examples may not work in older versions of PureBasic.

-----------------------------------------

Updated:
- added \Other_Stuff\OtherStuff\CommandConsole\ReadOutput.pb
- added \Other_Stuff\OtherStuff\GoogleTranslate.pb
- added \Other_Stuff\OtherStuff\WindowsMagnificationAPI.pb

Read Output: Based on a question posted by tatanas.
Google Translate: Based on a question posted by ricardo.
Windows Magnification API: Based on a question posted by BarryG.

Dont find ther translate in the ohterstuff zip :(

You are the man!!
ARGENTINA WORLD CHAMPION
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Windows Services & Other Stuff

Post by ricardo »

JHPJHP wrote:Updated:
- numerous updates and some bug fixes

Since the release of PureBasic 5.72 LTS Beta 1 (thank you Fred, Freak & Team) I proceeded to test every example, updating and patching as required.

NB*: Some examples may not work in older versions of PureBasic.

-----------------------------------------

Updated:
- added \Other_Stuff\OtherStuff\CommandConsole\ReadOutput.pb
- added \Other_Stuff\OtherStuff\GoogleTranslate.pb
- added \Other_Stuff\OtherStuff\WindowsMagnificationAPI.pb

Read Output: Based on a question posted by tatanas.
Google Translate: Based on a question posted by ricardo.
Windows Magnification API: Based on a question posted by BarryG.

Great job man!!

I only find some little problems.
Because it does not reacts when browser finish downloading new page, someitmes if it takes some time to translate because a bigger text, it fails.

Also the regex gives some problems sometimes.

Thanks in advance, you are doing a great job. I will donate soon :)
ARGENTINA WORLD CHAMPION
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Hi ricardo,
ricardo wrote:I only find some little problems.
Because it does not reacts when browser finish downloading new page, someitmes if it takes some time to translate because a bigger text, it fails.

Also the regex gives some problems sometimes.
The Problems you reported should now be fixed.
- SetLanguageURL: Used to set the Start Language and Translate Language.
- SetTranslateText: Used to set the text to be translated.

Depending on the size of the text to be translated, you may need to increase the #MAX_TIMEOUT constant located at the top of the example.

NB*: Example has been moved to \Other_Stuff\OtherStuff\GoogleTranslate\GoogleTranslate.pb

----------------------------------------

Updated Google Translate:
- added ListenToText Procedure
- modified SetTranslateText Procedure

ListenToText Procedure
The default action is to play the translated text.
Set StartLanguage option #True to play the original text.

SetTranslateText Procedure
Added CopyToClipboard option (default: #False).
Last edited by JHPJHP on Sun Jun 07, 2020 5:10 pm, edited 1 time in total.
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Windows Services & Other Stuff

Post by ricardo »

I find another problem.

Imagine that i want to load one file and translate it... and then translate to another language NOT the text from ther file, but the translation i just do, something like:

Code: Select all

SetTranslateURL(Dispatch, "auto", "de")
Text$ = SetTranslateText(Dispatch, Text$)

SetTranslateURL(Dispatch, "auto", "fr")
Text$ = SetTranslateText(Dispatch, Text$)
But sometimes, from time to time, i get your random text as a result.

Code: Select all

RandomText.s = Chr(Random(90, 65))
Best Regards my friend, you are downing something great sharing all your knowledge and codes, THANKS!!
ARGENTINA WORLD CHAMPION
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Hi ricardo,

It looks like you're using an older version of the example; see my previous post.
Download the latest version and let me know if it solves the problem.
ricardo wrote:But sometimes, from time to time, i get your random text as a result.

I ran the following code 5 consecutive times without a problem.

Code: Select all

SetLanguageURL("auto", "fr")
Debug SetTranslateText("Disturbed: Down With the Sickness")
SetLanguageURL("auto", "de")
Debug SetTranslateText("Disturbed: Down With the Sickness")
SetLanguageURL("auto", "en")
Debug SetTranslateText("Disturbed: Down With the Sickness")
This may also have been a timeout issue; the code has been updated.
- you should notice a marked speed improvements

-------------------------------------

Updated Google Translate:
- added ClearTranslateText Procedure
- some minor improvements
Last edited by JHPJHP on Sun Jun 07, 2020 5:11 pm, edited 1 time in total.
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Windows Services & Other Stuff

Post by ricardo »

JHPJHP wrote:Hi ricardo,

It looks like you're using an older version of the example; see my previous post.
Download the latest version and let me know if it solves the problem.
ricardo wrote:But sometimes, from time to time, i get your random text as a result.

I ran the following code 5 consecutive times without a problem.

Code: Select all

SetLanguageURL("auto", "fr")
Debug SetTranslateText("Disturbed: Down With the Sickness")
SetLanguageURL("auto", "de")
Debug SetTranslateText("Disturbed: Down With the Sickness")
SetLanguageURL("auto", "en")
Debug SetTranslateText("Disturbed: Down With the Sickness")
This may also have been a timeout issue; the code has been updated.
- you should notice a marked speed improvements

-------------------------------------

Updated:
- added ClearTranslateText Procedure
- some minor improvements
Hi,

I think its working, i mam testing it :)

What is the usage of ListenToText()?

Bet Regards
ARGENTINA WORLD CHAMPION
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Hi ricardo,
ricardo wrote:What is the usage of ListenToText()?
Listen to text is optional, but may be useful to some users; for example, a person with vision impairment, learning a new language, general communication, etc.

------------------------------------------

Updated Google Translate:
- made various code improvements
- added a couple new commands
- squashed a few bugs

New Commands:
- ExecuteCommand("listen-to-text", "translate-language")
-- start-language or translate-language
- ExecuteCommand("clear-translate-text")
Last edited by JHPJHP on Sun Jun 07, 2020 5:09 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Updated Google Translate:
- added a DLL example
- couple code improvements
- squashed a bug

DLL Example: GoogleTranslate_DLL.pb

NB*: Google Translate examples have been moved to \Other_Stuff\GoogleTranslate\

--------------------------------

Updated:
- see this post; based on a question by coffee
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Windows Services & Other Stuff

Post by JHPJHP »

Updated Google Translate:
- improved the DLL example
- includes 32 bit and 64 bit versions

DLL Example
Included script from another example to determine the calling process.
- \Other_Stuff\ProcessStuff\CallingProcess\
Passing translate data using an array for faster bulk translations.
Last edited by JHPJHP on Mon Nov 23, 2020 8:52 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Updated:
- various updates and improvements over time

Depending on when the package was previously downloaded will determine the number of changes.

NOTES:
All downloads require an access key.
Access key is emailed after a one time $20 CAD donation.
Good for all current and future scripts, programs, and updates.
Last edited by JHPJHP on Tue Aug 31, 2021 6:09 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Updated Google Translate:
- improved both examples
- added TranslateURL option
- added additional error checking
Last edited by JHPJHP on Wed Nov 25, 2020 3:21 am, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Windows Services & Other Stuff

Post by JHPJHP »

Updated Google Translate:
- improved both examples

Main Improvements.
1. Convert HTML entity codes.
2. Expanded to 100,000 characters.
3. Auto-clear IE cache under certain error conditions.

NB*: The Google Translate examples are now more user-friendly.

Script Example:

Code: Select all

IncludeFile "includes\GoogleTranslate.pbi"

If InitGoogleTranslate()
  If SetLanguageURL("auto", "fr", "https://translate.google.com")
    Debug "---------------------"
    Debug SetTranslateText("Disturbed: Down With The Sickness")
    Debug "---------------------"
    Debug SetTranslateText("testfiles\Disturbed.txt", 4500, #True)
  EndIf

  If SetLanguageURL("auto", "de", "https://translate.google.com")
    Debug "---------------------"
    Debug SetTranslateText("Grandmaster Flash & the Furious Five: The Message")
    Debug "---------------------"
    Debug SetTranslateText("testfiles\Grandmaster.txt", 4500, #True)
  EndIf
  QuitGoogleTranslate()
EndIf
DLL Example:

Code: Select all

IncludeFile "includes\GoogleTranslateDLL.pbi"

If InitGoogleTranslate()
  Dim td.TRANSLATE_DATA(2)
  td(0)\SourceLanguage = "auto"
  td(0)\TargetLanguage = "fr"
  td(0)\TranslateURL = "https://translate.google.com"
  td(0)\TranslateText = "Disturbed: Down With The Sickness."
  td(1)\SourceLanguage = "auto"
  td(1)\TargetLanguage = "fr"
  td(1)\TranslateURL = "https://translate.google.com"
  td(1)\TranslateText = "testfiles\Disturbed.txt"
  td(1)\TimeoutLength = 4500
  td(1)\SaveToFile = #True
  TranslationTotal = ArraySize(td())
  *TextTranslation = GoogleTranslate(@td(), TranslationTotal)

  If *TextTranslation
    Dim TextTranslation.s(TranslationTotal)
    CopyMemory(*TextTranslation, @TextTranslation(), SizeOf(*TextTranslation) * TranslationTotal)

    For rtnCount = 0 To TranslationTotal - 1
      Debug TextTranslation(rtnCount)
      Debug "---------------------" 
    Next
  EndIf
  QuitGoogleTranslate()
EndIf
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Windows Services & Other Stuff

Post by ricardo »

JHPJHP wrote:Updated Google Translate:
- improved both examples

Main Improvements.
1. Convert HTML entity codes.
2. Expanded to 100,000 characters.
3. Auto-clear IE cache under certain error conditions.

NB*: The Google Translate examples are now more user-friendly.

Script Example:

Code: Select all

IncludeFile "includes\GoogleTranslate.pbi"

If InitGoogleTranslate()
  If SetLanguageURL("auto", "fr", "https://translate.google.com")
    Debug "---------------------"
    Debug SetTranslateText("Disturbed: Down With The Sickness")
    Debug "---------------------"
    Debug SetTranslateText("testfiles\Disturbed.txt", 4500, #True)
  EndIf

  If SetLanguageURL("auto", "de", "https://translate.google.com")
    Debug "---------------------"
    Debug SetTranslateText("Grandmaster Flash & the Furious Five: The Message")
    Debug "---------------------"
    Debug SetTranslateText("testfiles\Grandmaster.txt", 4500, #True)
  EndIf
  QuitGoogleTranslate()
EndIf
DLL Example:

Code: Select all

IncludeFile "includes\GoogleTranslateDLL.pbi"

If InitGoogleTranslate()
  Dim td.TRANSLATE_DATA(2)
  td(0)\SourceLanguage = "auto"
  td(0)\TargetLanguage = "fr"
  td(0)\TranslateURL = "https://translate.google.com"
  td(0)\TranslateText = "Disturbed: Down With The Sickness."
  td(1)\SourceLanguage = "auto"
  td(1)\TargetLanguage = "fr"
  td(1)\TranslateURL = "https://translate.google.com"
  td(1)\TranslateText = "testfiles\Disturbed.txt"
  td(1)\TimeoutLength = 4500
  td(1)\SaveToFile = #True
  TranslationTotal = ArraySize(td())
  *TextTranslation = GoogleTranslate(@td(), TranslationTotal)

  If *TextTranslation
    Dim TextTranslation.s(TranslationTotal)
    CopyMemory(*TextTranslation, @TextTranslation(), SizeOf(*TextTranslation) * TranslationTotal)

    For rtnCount = 0 To TranslationTotal - 1
      Debug TextTranslation(rtnCount)
      Debug "---------------------" 
    Next
  EndIf
  QuitGoogleTranslate()
EndIf
I donate.

I am getting en error running the example pb file telling me that there are a communication error.
ARGENTINA WORLD CHAMPION
Locked