Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

homeshire

macrumors regular
Original poster
Jul 24, 2002
214
0
Ohio, looking toward Germany
So I cobbled together this script, absolutely none of it original with me. It is mostly Apple sample code. It does all that I want it to do, except one thing. It does not place my cursor ready for typing in a name into the URL. I have to manually place it smack in the middle of the text between the two dots. I am not clever enough to figure out how to place the cursor on run between the two dots. I don't doubt it can be done, and I wondered if anyone out here could suggest it for me. thanks, cause I do love to cobble scripts together and play with them.

display dialog "Enter the URL to open:" default answer "http://www..com" buttons {"Don't do it", "Go"} default button "Go" giving up after 25
if button returned of result = "Go" then
open location (text returned of result)
end if
tell application "Safari"
activate
end tell
tell application "Finder"
if the (count of windows) is not 0 then
set collapsed of every window to true
end if
 

prostuff1

macrumors 65816
Jul 29, 2005
1,482
18
Don't step into the kawoosh...
What i would do would be to not have the http://www. and the .com part in the box to start.

i use this script to create text documents (kinda like in Windows were you can right click and create a new text document.

Code:
on run {input, parameters}
	try
		tell application "Finder" to set the this_folder ¬
			to (folder of the front window) as alias
	on error -- no open folder windows
		set the this_folder to path to desktop folder as alias
	end try
	
	set thefilename to text returned of (display dialog ¬
		"Create file named:" default answer "filename")
	if thefilename does not end with ".txt" then
		set thefullpath to POSIX path of this_folder & thefilename & ".txt"
	else
		set thefullpath to POSIX path of this_folder & thefilename
	end if
	do shell script "touch \"" & thefullpath & "\""
	return input
end run

pay specific attention to:
Code:
if thefilename does not end with ".txt" then
		set thefullpath to POSIX path of this_folder & thefilename & ".txt"
	else
		set thefullpath to POSIX path of this_folder & thefilename
	end if

you can add something like this to your script to check for the http://www. part and the .com part. If neither of them exist then they can be added to the front and back fo the text string.

Hope that helps


Of note: this abover script i put into automator and saved a finder plugin. It works pretty well. The only problem is that if you want to create a txt file on the desktop make sure that no finder windows are open. I have not had a chance to mess with and fix it.
 

homeshire

macrumors regular
Original poster
Jul 24, 2002
214
0
Ohio, looking toward Germany
What i would do would be to not have the http://www. and the .com part in the box to start.

i use this script to create text documents (kinda like in Windows were you can right click and create a new text document.

Code:
on run {input, parameters}
	try
		tell application "Finder" to set the this_folder ¬
			to (folder of the front window) as alias
	on error -- no open folder windows
		set the this_folder to path to desktop folder as alias
	end try
	
	set thefilename to text returned of (display dialog ¬
		"Create file named:" default answer "filename")
	if thefilename does not end with ".txt" then
		set thefullpath to POSIX path of this_folder & thefilename & ".txt"
	else
		set thefullpath to POSIX path of this_folder & thefilename
	end if
	do shell script "touch \"" & thefullpath & "\""
	return input
end run




Hope that helps

thanks for your response, and i'm going to play with this and see what happens. but i have to say, at first glance, it's deep water for me.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.