randomfox: (Default)
[personal profile] randomfox
This macro (Alt-S) takes a set of coordinates, whether in dd.ddddd format or in dd mm.mmm format, from the clipboard and pastes it into a form in a number of formats. Alt-Shift-S brings up a GUI dialog box allowing you to choose a paste format.


; This variable determines how the converted coordinates will be pasted.
optPasteStyle = 1

; Brings up a GUI to choose how the converted coordinates will be pasted.
!+s::
gui,font,s11 cWhite,ms sans serif
gui,color,Black
gui,+AlwaysOnTop +ToolWindow
gui,add,text,,Choose a coordinates pasting style:
radiochecked:=0
if optPasteStyle=1
    radiochecked:=1
gui,add,Radio,Checked%radiochecked% vPasteStyle gSelectPaste,&Two tabs (Geosnapper)
radiochecked:=0
if optPasteStyle=2
    radiochecked:=1
gui,add,Radio,Checked%radiochecked% gSelectPaste,&One tab (Streets and Trips)
radiochecked:=0
if optPasteStyle=3
    radiochecked:=1
gui,add,Radio,Checked%radiochecked% gSelectPaste,&Space between (Google Maps, Panoramio)
radiochecked:=0
if optPasteStyle=4
    radiochecked:=1
gui,add,Radio,Checked%radiochecked% gSelectPaste,&Comma between (Panoramio)
radiochecked:=0
if optPasteStyle=5
    radiochecked:=1
gui,add,Radio,Checked%radiochecked% gSelectPaste,&Geotag (Flickr)
radiochecked:=0
if optPasteStyle=6
    radiochecked:=1
gui,add,Radio,Checked%radiochecked% gSelectPaste,&Disable
gui,show,,Coordinates pasting options
return

SelectPaste:
Gui,Submit
Gui,Destroy
optPasteStyle := PasteStyle
Sleep 50
; MsgBox,,,You chose button %PasteStyle%
return

GuiClose:
GuiEscape:
Gui,Destroy
return


; 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
    if optPasteStyle = 1
    {
	clipboard := geolat
	SendInput ^a^v
	Sleep 50
	SendInput {tab 2}
	Sleep 50
	clipboard := geolon
	SendInput ^v
	Sleep 50
    }
    else if optPasteStyle = 2
    {
	clipboard := geolat
	SendInput {home}+{end}^v
	Sleep 50
	SendInput {tab}
	Sleep 50
	clipboard := geolon
	SendInput ^v
	Sleep 50
    }
    else if optPasteStyle = 3
    {
	clipboard = %geolat% %geolon%
	SendInput {home}+{end}^v
	Sleep 50
    }
    else if optPasteStyle = 4
    {
	clipboard = %geolat%,%geolon%
	SendInput {home}+{end}^v
	Sleep 50
    }
    else if optPasteStyle = 5
    {
	clipboard = geotagged geo:lat=%geolat% geo:lon=%geolon%
	SendInput +{insert}
	Sleep 50
    }
    else
    {
	SendInput !s
    }	    
    ; Restore the clipboard.
    clipboard := saveclip
    saveclip =
    BlockInput Off
}
else {
    ; No coordinates found. Just pass the keystroke to the application.
    SendInput !s
}
return

From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 26th, 2017 05:34 am
Powered by Dreamwidth Studios