Autohotkey macros for copying coordinates
These two macros take coordinates from the clipboard, whether in dd.ddddd format or in dd mm.mmm format.
Then the first macro pastes dd.ddddd format coordinates into two form fields with 2 tabs separating the fields. The second macro does the same but with 1 tab instead of 2.
Use the first macro for Geosnapper and the second for Streets and Trips.
Then the first macro pastes dd.ddddd format coordinates into two form fields with 2 tabs separating the fields. The second macro does the same but with 1 tab instead of 2.
Use the first macro for Geosnapper and the second for Streets and Trips.
; Finds either dd mm.mmm coordinates or decimal-degree coordinates.
; Returns latitude and longitude in geolat and geolon.
; Returns true if there was a match. Returns false if no match.
CoordMatch(str, ByRef geolat, ByRef geolon)
{
foundpos := RegExMatch(str, "(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)", matches)
if foundpos > 0
{
geolat := matches1 + (matches2 + matches3 / 1000) / 60
geolon := - (matches4 + (matches5 + matches6 / 1000) / 60)
return true
}
else {
foundpos := RegExMatch(str, "^.*?(\d+\.\d+).+?(-\d+\.\d+).*$", matches)
if foundpos > 0
{
geolat := matches1
geolon := matches2
return true
}
}
return false
}
; Copy Topozone URL or dd mm.mmm coordinates to clipboard. Then use this
; macro to fill in Geosnapper coordinates fields.
!s::
KeyWait,Alt
saveclip := ClipboardAll
if CoordMatch(Clipboard, geolat, geolon)
{
BlockInput On
clipboard := geolat
SendInput ^a^v
Sleep 50
SendInput {tab 2}
Sleep 50
clipboard := geolon
SendInput ^v
Sleep 50
; Restore the clipboard.
clipboard := saveclip
saveclip =
BlockInput Off
}
else {
MsgBox,"Can't parse coordinates from clipboard"
}
return
; Copy Topozone URL or dd mm.mmm coordinates to clipboard. Then use this
; macro to fill in decimal degrees into two consecutive form fields in
; Streets and Trips.
!t::
KeyWait,Alt
saveclip := ClipboardAll
if CoordMatch(Clipboard, geolat, geolon)
{
BlockInput On
clipboard := geolat
SendInput {home}+{end}^v
Sleep 50
SendInput {tab}
Sleep 50
clipboard := geolon
SendInput ^v
Sleep 50
; Restore the clipboard.
clipboard := saveclip
saveclip =
BlockInput Off
}
else {
MsgBox,"Can't parse coordinates from clipboard"
}
return