set focus to display dialog

Hi,

I have a script to make a webloc file from the current open page in firefox, the code works.
But every time I run it my display dialog is behind my firefox screen, is there any way to put it in front?


tell application "Firefox" to activate

tell application "System Events"
	keystroke "l" using {command down} -- Highlight the URL field.
	keystroke "c" using {command down}
end tell

delay 0.5

set theurl to the clipboard

display dialog "Give the file name:" default answer ""
set theName to text returned of result

tell application "Finder" to set webloc to make new internet location file to theurl at desktop with properties {name:theName, location:theurl}

Try:


tell me
	activate
	display dialog "Foo"
end tell

Thanks! that works perfectly

Just to explore all of the options, you could also put the display dialog in the Finder since you are using it already, and just make sure you activate the Finder.

tell application "Finder"
	activate
	display dialog "Give the file name:" default answer ""
	set theName to text returned of result
	
	set webloc to make new internet location file to theurl at desktop with properties {name:theName, location:theurl}
end tell

As FireFox is the frontmost application, why not using FireFox as the target application?


.
set theurl to the clipboard
tell application "Firefox" to display dialog "Give the file name:" default answer ""
set theName to text returned of result
tell application "Finder" to set webloc to make new internet location file to theurl at desktop with properties {name:theName, location:theurl}

Lazymouse does something like this