Choose from list apple script service execution from Safari opens Firefox to display the dialog with list Im trying to use following Apple Script to display a choose from list and perform certain actions based on the choice of selection:
on run {input, parameters}
    set selT to &quot;42&quot;
    set selectedOption to choose from list {&quot;Safari&quot;, &quot;Chrome&quot;, &quot;Firefox&quot;} with prompt &quot;Search with:&quot; without multiple selections allowed and empty selection allowed
    
    global urlToOpen
    set urlToOpen to &quot;na&quot;
    if selectedOption is not false and length of selectedOption is not 0 then
        set urlToOpen to &quot;https://duckduckgo.com/?q=&quot; &amp; selT
    end if
        
    if ((urlToOpen as string) is not equal to &quot;na&quot;) then
        tell application &quot;System Events&quot;
            tell (first application process whose frontmost is true)
                set theActiveApp to name of it
             end tell
        end tell
        activate me 
        
        display dialog theActiveApp
        
        if theActiveApp is &quot;Safari&quot; then
            tell application &quot;Safari&quot;
                tell window 1
                    set current tab to (make new tab with properties {URL:urlToOpen})
                end tell
            end tell
        else if theActiveApp is &quot;firefox&quot; then
            tell application &quot;firefox&quot;
                open location urlToOpen
            end tell
        else if theActiveApp is &quot;Google Chrome&quot; then
            tell application &quot;Google Chrome&quot;
                open location urlToOpen
            end tell
        end if
        
     end if
end run

But, whats happening is; when the Automator service runs, it opens Firefox to display the list of options. It would be a great help to understand this behavior, because Firefox not being the default browser and it is waste of CPU resource to open it.
Firefox is likely opening because the script includes:
tell application &quot;firefox&quot;
    …
end tell

Based on your description, these lines require AppleScript to launch Firefox to determine if the script is correct – even if the involved lines are never run. Firefox needs to be launched for AppleScript to obtain the application's scripting language support.
The other browsers implement AppleScript using a more modern approach. They provide their language support through an embedded Scripting Definition file (SDEF) within the application bundle.
open a URL on macOS
You can avoid this behaviour by using the macOS open command line tool and passing the desired browser's bundle identifier with the URL to open.
This removes the need to write browser specific sections of AppleScript.
Be sure to quote the arguments:
try
    set myURL to &quot;https://duckduckgo.com/?q=&quot; &amp; &quot;42&quot;
    set bundleID to &quot;com.apple.safari&quot;
    do shell script &quot;/usr/bin/open -b &quot; &amp; quoted form of bundleID &amp; &quot; &quot; &amp; quoted form of myURL
on error (e)
    display dialog e
end try

Calling open without a bundle ID will open the URL in the default browser.
Open URL with Safari
 /usr/bin/open -b com.apple.Safari 'https://dssw.co.uk'

Open URL with Chrome
 /usr/bin/open -b com.google.chrome 'https://miln.eu/apps'

Open URL with Firefox
 /usr/bin/open -b org.mozilla.firefox 'https://indie.miln.eu'

| and Error Checking
You could surround the application names with | to defer script error checking from compile time to runtime. See user3439894's answer for this approach.