Jump to content

Mileage Tracker


Recommended Posts

So I'm trying to come up with a way to track my daily mileage. Assuming I have addresses stored in Contacts.app, here's how I envision it working:

 

- Using the home addresses as the reference, I want to select two contact cards and send them into Google Maps and have it return the mileage back into Alfred.

 

The typical Google Maps search looks like this: https://maps.google.com/maps?q={query}

 

My goal is to have something that looks more like this: https://maps.google.com/maps?saddr={query1}&daddr={query2} where {query1} is the starting address and {query2} is the destination address.

 

So far I've tried:

- Creating a contacts action that sends the address to Google Maps. This gets me 1/3rd of the way.

- Copying the first address to my clipboard and then performing option one (Contacts action) on the second address and then pasting the first address into maps when it pops up. This doesn't save me nearly enough time.

 

First: is this even remotely possible?

Second: I'd love to know how to do something like this, I'm not really interested in having someone do this for me. I'm an absolute beginner when it comes to scripting of any kind, but I'd love to learn.

 

What am I missing or not considering?

 

Thanks!

 

-Andrew

 

 

Link to comment

If you're the only one using this, and you always leave from the same place, you could just hard code the first address :)

 

Great idea! I hadn't thought of that. So it would look something like this?

 

https://maps.google.com/maps?saddr={my address}&daddr={query} where query is the destination?

 

That will definitely work, but what if I want to start from somewhere other than my home address?

Link to comment

I'd look at the first example here: http://www.alfredforum.com/topic/1283-how-to-script-filters-reusing-a-single-script-filter-or-chaining-multiple-together/

 

It inputs last name, writes it to a temporary file, calls a second search action that inputs first name, reads last name from the temporary file, deletes the temporary file, and finally outputs first name last name.

 

You'd just need to modify it to get the addresses from contacts instead of user input (which it sounds like you've figured out already), and change the echo  command in the 2nd bash script to include all the necessary bits for the google maps URL, then replace the Post Notification with a Open URL.

Link to comment

I'd look at the first example here: http://www.alfredforum.com/topic/1283-how-to-script-filters-reusing-a-single-script-filter-or-chaining-multiple-together/

 

It inputs last name, writes it to a temporary file, calls a second search action that inputs first name, reads last name from the temporary file, deletes the temporary file, and finally outputs first name last name.

 

You'd just need to modify it to get the addresses from contacts instead of user input (which it sounds like you've figured out already), and change the echo  command in the 2nd bash script to include all the necessary bits for the google maps URL, then replace the Post Notification with a Open URL.

 

You're giving me way too much credit :-P

 

I completely understand the concepts and logic behind using the second bash script (I barely even know what a bash script is) to achieve what I want, but I have absolutely no idea how to modify it to force me to choose addresses instead of user input.

 

Where do I look for next steps or what should I be changing?

Link to comment

Here is how to do the hardcoded version (i.e. select destination only).  3 elements
 
1) Contact Action


linked to

 

2) a one line bash script (escaping everything except spaces) - this removes line breaks from the address:

 

echo "{query}" | tr "\n" " "

 

linked to 

 

3) a one line bash script (escaping everything except spaces):

 

open "http://maps.google.com/maps?saddr=yourstartingaddress&daddr={query}"

Edited by dfay
Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...