veadar
2/12/2015 - 12:46 AM

gistfile1.applescript

on run --for Dialog
	display dialog "Input search word(s)" default answer "" buttons {"OK"} default button 1
	set searchWord to text returned of result
	searchMAS(searchWord)
end run

on alfred_script(searchWord) --for Alfred
	searchMAS(searchWord)
end alfred_script

on handle_string(searchWord) --for LaunchBar
	searchMAS(searchWord)
end handle_string

on searchMAS(searchWord)
	
	tell application "App Store"
		activate
		delay 5 -- wait for it to start
	end tell
	
	tell application "System Events"
		tell window "App Store" of process "App Store"
			
			-- Search for Xcode
			tell text field 1 of group 7 of toolbar 1
				set value to searchWord
				click button 1
				delay 2
			end tell
			
			-- ...
			
		end tell
	end tell
	
end searchMAS