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.

Steps

Note: You can trigger the following script with your standard keyboard if you don't have an Enterpad. If so, just replace the line 1 on step 2 with your hotkey definition. The Enterpad hotkeys are useful for efficiency driven professionals who want to avoid the trouble of dealing with too many Windows hotkeys [learn more].

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 % "The attempt to copy text to the clipboard failed."
      return 
  }
  NewClipboard = %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).