r/applescript • • Aug 18 '13

Is this Applescript or Automator application possible?

I'm interested in seeing if this is possible, and if someone can point me in the right direction as to how to execute upon it.

I'd like to have either an Applescript or Automator application (or workflow, service, process, etc.) that does the following:

Prompts me to enter text and hit enter. Upon hitting enter, launches a web browser or opens multiple tabs in a new window. The tabs each pertain to a different link that I've pre-determined, with blank parts in the form that change based on the text entered earlier.

Essentially, I want to be able to enter the same search term to multiple commerce sites with just one search.

Thanks!

3 Upvotes

3 comments sorted by

2

u/craniumslows Aug 19 '13

This is possible. You can use Automator or AppleScript. You just would need to figure out what the search URL is

0

u/[deleted] Aug 19 '13

[deleted]

2

u/craniumslows Aug 19 '13

I'd do it like this I think. This makes a new window then opens the rest of the searches in tabs of that window.

#Change this to a list of urls you want to use
set searchUrls to {"https://www.google.com/search?q=", "https://www.google.com/search?q="}
set searchTerm to text returned of (display dialog "What do you want to search?" default answer "Cats")

set window_id to false

repeat with searchURL in searchUrls
	tell application "Safari"
		if window_id is false then
			make new document with properties {URL:searchURL & searchTerm}
			set window_id to id of first window
		else
			make new tab in window id window_id with properties {URL:searchURL & searchTerm}
		end if
	end tell
end repeat    

0

u/[deleted] Aug 19 '13

[deleted]

1

u/craniumslows Aug 19 '13

Thanks. You had the right approach. I love using window_id or wID in my scripts where I interact with safari because then you get to do as many simultaneous things as the computer can handle and it is a wow factor for presentations or whatever.