<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting XY from mouse click using python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288741#M22383</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;David,&lt;BR /&gt;&lt;BR /&gt;While this is the reverse of what you want, I think it should be able to give you some ideas.&amp;nbsp; I will need to do the same as you soon, but just havn't had the opportunity to do so just yet.&lt;BR /&gt;&lt;BR /&gt;I think you will need get the properties of the DataFrame to convert from page units to preferred projected coordinates.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://gis.stackexchange.com/questions/21514/convert-point-xy-to-page-units-xy-using-arcpy" rel="nofollow noopener noreferrer" target="_blank"&gt;http://gis.stackexchange.com/questions/21514/convert-point-xy-to-page-units-xy-using-arcpy&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's what I discovered when using the onMouseDown and onMouseDownMap in a Python add-in.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function onMouseDown will return a set of pixel values showing the coordinates of where you clicked, measured in pixels from the upper left of the map display window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function onMouseDownMap is sensitive to your current view. If you are in data view, it returns coordinates in the map's coordinate system. If you are in layout view, it returns coordinates in page units - but only allows you to click inside the data frame element.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The fix is as suggested by James (Thanks!!). Convert the page coordinates to map coordinates. To do this, I find the lower left page X coordinate and the click point X value and subtract the two. That's how far over from the edge of the data frame I clicked in inches. Then (for feet) divide by twelve and multiply by the scale of the map. That's the distance in map units I am from the edge of the data frame. Then I find the data frame's minimum X value in map units and add the calculated distance. Repeat for Y. Here's the code for a tool in my add-in that lets you click in the map while in layout view and select a feature from a layer called "Cadastre".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;class Sel_Property(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for Notifications_addin.selectproperty (Tool)"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thisMap = arcpy.mapping.MapDocument("CURRENT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_frame = arcpy.mapping.ListDataFrames(thisMap)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; page_x = x
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; page_y = y

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Convert page coordinates to projected coordinates"""

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #get the data frame dimensions in page units
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_page_w = data_frame.elementWidth
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_page_h = data_frame.elementHeight
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_page_x_min = data_frame.elementPositionX
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_page_y_min = data_frame.elementPositionY
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_page_x_max = df_page_w + df_page_x_min
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_page_y_max = df_page_h + df_page_y_min

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #get the data frame projected coordinates
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_min_x = data_frame.extent.XMin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_min_y = data_frame.extent.YMin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_max_x = data_frame.extent.XMax
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_max_y = data_frame.extent.YMax
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_proj_w = data_frame.extent.width
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_proj_h = data_frame.extent.height
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #ensure the coordinates are in the dataframe
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if page_x &amp;lt; df_page_x_min or page_x &amp;gt; df_page_x_max:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ValueError ('X coordinate is not within map portion of the page.')

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if page_y &amp;lt; df_page_y_min or page_y &amp;gt; df_page_y_max:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ValueError ('Y coordinate is not within map portion of the page.')

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #scale the projected coordinates to map units from the lower left of the data frame
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scale = data_frame.scale/12 # converting scale factor to feet per inch
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map_x = df_min_x + ((page_x - df_page_x_min)*scale)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map_y = df_min_y + ((page_y - df_page_y_min)*scale)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pythonaddins.MessageBox("Coordiantes are" + str(map_x) + " and " + str(map_y),"Title")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeom = arcpy.PointGeometry(arcpy.Point(map_x,map_y), thisMap.activeDataFrame.spatialReference)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = arcpy.mapping.ListLayers(thisMap)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in layers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.name == "Cadastre":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(lyr,"INTERSECT",pointGeom)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thisMap.activeView = "PAGE_LAYOUT"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_frame.zoomToSelectedFeatures()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_frame.scale = data_frame.scale * 5.2
&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:57:03 GMT</pubDate>
    <dc:creator>DavidAllen</dc:creator>
    <dc:date>2021-12-11T13:57:03Z</dc:date>
    <item>
      <title>Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288719#M22361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to create a button that captures the location of the next mouse click and displays it in LAT/LONG. I imagine is would have to open a submenu which would be closed when the user is finished getting location information. Is there any way to do this using python?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 15:42:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288719#M22361</guid>
      <dc:creator>MichelleHawks</dc:creator>
      <dc:date>2012-02-03T15:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288720#M22362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In 10.1 I believe Python add-ins will be able to do this, but for 10.0 and earlier you would need to use ArcObjects.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 15:47:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288720#M22362</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2012-02-03T15:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288721#M22363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can get the lat/long locations by creating a tool, but as Logan mentioned, you will most likely need ArcObjects to display the lat/long in a menu.&amp;nbsp; Here is a tool sample that obtains the coordinates from where you click and copies the values to clipboard:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=0BF2E736-1422-2418-3416-5AA910449F6E"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=0BF2E736-1422-2418-3416-5AA910449F6E&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 16:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288721#M22363</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-02-03T16:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288722#M22364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So 10.1 is now here...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm looking for the Python add-ins that will be able to do this neat trick&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Getting XY from mouse click using python": &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Specifically I would like to rewire the Fishnet function in ModelBuilder so &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;that the user can simply click the screen to set both origin_coord &amp;amp; y_axis_coord&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;interactively rather than having to type all coordinates in....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CreateFishnet_management(out_feature_class, origin_coord, y_axis_coord, cell_width, cell_height, number_rows, number_columns, {corner_coord}, {labels}, {template}, {geometry_type})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Very grateful if anybody can point me in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jul 2012 05:15:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288722#M22364</guid>
      <dc:creator>IanThomas1</dc:creator>
      <dc:date>2012-07-28T05:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288723#M22365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The help for addins has exactly this fishnet as an example. I did manage to get it to work, but....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Addins are quite complex and difficult to debug. For each fix you have to recompile the addin, copy the files to the addins directory &lt;/SPAN&gt;&lt;STRONG style="text-decoration: underline;"&gt;and restart ArcGIS every time&lt;/STRONG&gt;&lt;SPAN&gt; because there is no equivalent to the python 'reload' command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you only want to get a couple of points, then do this at the start using the featureset type in the dialog for a normal tool. This is a very flexible input method that can take any feature type (point, line, polygon) to generate a temporary featureclass that is delivered as a parameter to use. You can also add a geoprocessing tool to a menu with a simple icon. These abilities have been available since 9.3 but has not been properly publicised.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Popping up a coordinate in a box can be done in python using the windows message box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import win32ui,win32con
for i in range(32) :
&amp;nbsp;&amp;nbsp;&amp;nbsp; ok = win32ui.MessageBox("type"+str(i),"Message Title",i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Form type",i,"Button",ok&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288723#M22365</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T13:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288724#M22366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did anyone ever figure this out? The link referenced by Jskinn3 refers to getting an coordinate extent, not the X, Y point of a mouse click.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 11:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288724#M22366</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2012-12-07T11:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288725#M22367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi John,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The extent is created from two XY locations from two mouse clicks.&amp;nbsp; If you want the extent, you would click in the lower left corner and the upper right corner for the area of interest.&amp;nbsp; If you just want a single location you would just specify one mouse click and execute the tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 11:35:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288725#M22367</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-12-07T11:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288726#M22368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jskinn,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the quick response. Do you know if there is anyway to do this in Python without requiring the Win32clipboard module. Rather than store the coordinate pair in the clip board, I'm trying to get them into a variable which I can then pass into a Google Map search. I'm essentially trying to rewrite this addin (&lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=48F2BB6C-1422-2418-8822-C06E828584E8"&gt;http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=48F2BB6C-1422-2418-8822-C06E828584E8&lt;/A&gt;&lt;SPAN&gt;) in Python instead of VB&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288726#M22368</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2012-12-07T18:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288727#M22369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could use something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

input = arcpy.GetParameterAsText(0)

cur = arcpy.SearchCursor(input)

for row in cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.Shape
&amp;nbsp;&amp;nbsp;&amp;nbsp; X = geom.centroid.X
&amp;nbsp;&amp;nbsp;&amp;nbsp; Y = geom.centroid.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp; XY = str(X) + ", " + str(Y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
del row, cur

arcpy.AddMessage(XY)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here the X,Y coordinates are stored in a variable XY.&amp;nbsp; For the input parameter, you will want to set the data type as Feature Set.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288727#M22369</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T13:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288728#M22370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch. That's exactly what I did after I started playing with the code on Friday. After I posted the message, it dawned on me that the Win32 modules were just being used for the clipboard. My Code is exactly the same, except I didnt concatenate the X and Y coordinates, I want them seperate so I can pass them into a URL individually.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 16:52:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288728#M22370</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2012-12-10T16:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288729#M22371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have tried to had this as a scipt tool and as an addin but i am not having any look.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could someone please guide me through to create this xy button please?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2013 21:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288729#M22371</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2013-01-16T21:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288730#M22372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the replay but when i replace my exsiting code with what you provided my tool icon indicates it's missing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins

class XYTool(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for xy_addin.XYTool (Tool)"""
&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.cursor=3
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd=arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt=arcpy.PointGeometry(arcpy.Point(x,y))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #ptfeat=arcpy.management.CopyFeatures(pt,r"in_memory\pt")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x,y

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288730#M22372</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-11T13:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288731#M22373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got it to work kind of, i had a syntax error problem. I have fixed it and added the tool button but when i click the button and click on the map nothing happens, nothing is displayed... i am i missing something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 14:44:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288731#M22373</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2013-01-17T14:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288732#M22374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The coordinates will be printed to your Python window.&amp;nbsp; Open that window before executing the tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 14:48:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288732#M22374</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-01-17T14:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288733#M22375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found that out just before i saw your post. Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to popup a message with out having to turn on the python window?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 15:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288733#M22375</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2013-01-17T15:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288734#M22376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do this using the MessageBox in the pythonaddins module.&amp;nbsp; Pass the coordinates to the message property as text.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 23:57:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288734#M22376</guid>
      <dc:creator>DeanCarstens</dc:creator>
      <dc:date>2013-01-17T23:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288735#M22377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got to pop up the message box, but it has NaN Nan at the end.. what is that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Would there be a possible way to add the "Long" &amp;amp; "Lat" text to the beginning or the end of the coordinates?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to display like this,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Latitude = 43.5373, Longitude = -114.2578 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lat = 43.5373, Long = -114.2578&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 13:55:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288735#M22377</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2013-01-18T13:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288736#M22378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You will just need to add &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000021000000" rel="nofollow noopener noreferrer" target="_blank"&gt;pythonaddins.Messagebox&lt;/A&gt;&lt;SPAN&gt; to the end of your code.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins

class XYTool(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for xy_addin.XYTool (Tool)"""
&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.cursor=3
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd=arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt=arcpy.PointGeometry(arcpy.Point(x,y))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #ptfeat=arcpy.management.CopyFeatures(pt,r"in_memory\pt")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x,y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox(str(x) + ", " + str(y), 'Coordinates', 0)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288736#M22378</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T13:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288737#M22379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;my current code;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins

class XY(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for xy_addin.tool (Tool)"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.cursor=3
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd=arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt=arcpy.PointGeometry(arcpy.Point(x,y))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #ptfeat=arcpy.management.CopyFeatures(pt,r"in_memory\pt")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x,y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox (arcpy.Point(x,y) ,'Location','0')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288737#M22379</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-11T13:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting XY from mouse click using python</title>
      <link>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288738#M22380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you JSkinns3!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to figure it out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins

class XY(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for xy_addin.tool (Tool)"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.cursor=3
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd=arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt=arcpy.PointGeometry(arcpy.Point(x,y))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #ptfeat=arcpy.management.CopyFeatures(pt,r"in_memory\pt")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x,y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox("Long" + " " + str(x) + '\n'+ "Lat"+ " " + str(y), 'Coordinates', 0)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-xy-from-mouse-click-using-python/m-p/288738#M22380</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-11T13:56:56Z</dc:date>
    </item>
  </channel>
</rss>

