deek5 deek5 - 17 days ago 5
Perl Question

Why with Firefox you can not use arguments after opening a URL in applescript, shell script , Perl, ruby?

with Safari or Chrome you can use an argument to open a URL

Example in Applescript in Safari

Open location "https://translate.google.com/#auto/en/" & (the clipboard)


The command lines of Firefox allow the opening url BUT WITHOUT ARGUMENT.
Is there a way to circumvent this failure by a script ???

AppleScript example:

tell application "Safari"
activate
try
open location "translate.google.com/#auto/en/" & (the clipboard)
end try
end tell

Answer

what do you say, since you do not understand the question, you can assume everything. If you don't understand, don't force yourself to invent answers. The script presented in applescript works very well for Safari. The question is simple why with Firefox one can not complete command line with an argument url request. So l) example that works with Safari or Chrome:

*Open location "https://translate.google.com/#auto/en/" & (the clipboard)*

Here the argument is the clipboard that we have of course previously filled with text to translate.

There may be no reason why it works with Firefox. Especially remember that we are talking about Firefox. The script in applescript for Safari works

**Tell application "Safari"
activate
try
Open location "https://translate.google.com/#auto/en/" & (the clipboard)
end try
end tell**

This is the method that works for Firefox. This is not the fastest, because you must first format the text if you want the entire content of the ClipBoard. I have to create the service in Automator without input for it to be in general, applicable everywhere.

In Firefox the problem, which does not exist with Safari or Chrome, is when we call "translate.google.com" and we associate the ClipBoard to it, the text is not formatted on arrival and causes Of the errors 404. So if you do the maneuver in 2 steps of course there is no problem, open the page "translate.google.com" menu edit and paste.

[![** on run {input, parameters}
    tell application "System Events"
        keystroke "c" using command down
    end tell
tell application "Applications/Firefox.app" to activate
tell application "System Events" to tell process "Firefox"
    set frontmost to true
    set sentence to text of (the clipboard)
    set thesentences to paragraphs of sentence
    set thenewsentences to thesentences as string
    set the clipboard to thenewsentences
    keystroke "t" using command down
    keystroke "https://translate.google.com/#auto/fr/" & (the clipboard) & return
end tell
end run **][1]][1]