Google Maps from Selection

with AutoHotkey

by Denis Lamarre
last updated February 10, 2016
difficulty.png Easy

by Denis Lamarre

Description

How are you using Google Maps? Do you have to select an address, copy it to the clipboard, find and start Google Maps, paste the address, and finally hit “enter” or click the search icon to get the location? If you are doing this again and again, you could find the following AutoHotkey script useful. Simply select the address, then press your selected Enterpad button (or your selected keyboard hotkey) to get the location.

Note: AutoHotkey has no limits when it comes to automation in Windows, but for many users who may only need simple keyboard shortcuts, installing and learning AutoHotkey, and keeping up to date, can be overkill. ShortKeeper can be used (with and without an Enterpad) to manage an AutoHotkey-based system in a way most non-programmers will find remarkably user-friendly and and effective [learn more].

Steps

1

overlay-um-googlemaps.gifPrepare your overlay
Choose a free key on the Enterpad for which you want to start Google Maps. Name it something relevant. This example uses "Google MAPS".

2

Code installation
Copy/paste the following script in your AutoHotkey script template (Enterpad.ahk) at the chosen key location.

001:
  ClipSaved := ClipboardAll
  Clipboard =
  SendInput, ^c
  ClipWait, 2
  if ErrorLevel 
  {
      MsgBox % "Failed attempt to copy text to clipboard."
      return 
  }
  NewClipboard := Trim(Clipboard)
  StringReplace,NewClipboard,NewClipboard,`n,%A_SPACE%,A
  StringReplace,NewClipboard,NewClipboard,`r,,A
  Clipboard := ClipSaved
  ClipSaved =
  run https://www.google.com/maps/search/%NewClipboard%/
  NewClipboard := 
return

More Info

The selected address (by the user) can be on several lines. Lines 12 and 13 are there to replace new lines with spaces from the clipboard (if Google doesn't do it).

Google.com (USA) is used at line 16. You can use your country's Google instead (e.g., google.ca, google.au).