+ Reply to Thread
Results 1 to 33 of 33

Record Windows paint coordinate?

Hybrid View

  1. #1
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Record Windows paint coordinate?

    I've never seen this kind of feature in any program so..

    You know when you open a picture using windows paint,
    there's a coordinate on the bottom right of the screen right?

    Now, Is it possible to make a macro that records the coordinate everytime i maka a dot using "pencil" feature in paint?

    So everytime i click on a spot in the image (draw a single dot), excel would track the coordinates of these dots and write it vertically in 2 columns (x & y)... the result is something like this :

    x	y
    125	148
    143	180
    152	185
    230	155
    280	186
    280	154
    207	133
    207	70
    246	95
    281	121
    282	94
    337	82
    320	95
    342	100
    356	109
    350	159
    346	202
    I need to do this for 5000 dots so writing down those coordinates manually is gonna take forever, and the error risk is higher too ...

    Or could you reccomend me a program that has such feature?
    I've been googling it but found no such thing...

    thanks.
    Last edited by Kb24; 08-16-2009 at 08:21 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,320

    Re: Record Windows paint coordinate?

    How would you expect Excel to record what you are doing in Paint?
    Can I ask what the purpose is? What do you hope to do with these coordinates afterwards?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    I'm making a googlemap-like j2me application that has "routing" function..

    and creating a route requires coordinates from a map..
    and these are the coordinates from the paint that i was talking about...

    Basically i open the map image and then write down the "nodes" or the spots in the map needed to create the route; one by one...
    Last edited by Kb24; 08-14-2009 at 08:05 AM.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,320

    Re: Record Windows paint coordinate?

    You could load the picture into an Image control (from the Control Toolbox) on the worksheet and then put this code behind the control:
    Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
       With Cells(Rows.Count, "A").End(xlUp).Offset(1)
          .Value = X
          .Offset(0, 1).Value = Y
       End With
       
    End Sub

  5. #5
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Okay... done that.
    So what should i do after that to list the coordinates?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,320

    Re: Record Windows paint coordinate?

    Click on the image!

  7. #7
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Hmmm.. Just click it?
    Thats weird..
    I did that but nothing shows up,

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,320

    Re: Record Windows paint coordinate?

    Assuming you have macros enabled, the coordinates should appear in columns A and B of the sheet. Oh, and the code has to be in the worksheet code module, not a normal module.

  9. #9
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Nope... still doesn't work..
    Here's the file :

    http://ifile.it/49j73hl

    I even changed the Image1_MouseDown into Image1 but it still doesn't work.. Did i miss anything here?

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,320

    Re: Record Windows paint coordinate?

    That doesn't appear to be an Image control. How did you insert it into the worksheet - using the Image control from the Developer tab?

  11. #11
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    From developer Tab -> Insert -> Image Control (the one with mountain pic),
    then i set the Autofit to true, load the image using "..." button next to "Picture" in Properties...
    Did i get it wrong? Now i can't even edit the image

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,320

    Re: Record Windows paint coordinate?

    No, that's correct. Maybe the conversion when I opened it in 2003 screwed it up. I'll test with 2007 later.

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,557

    Re: Record Windows paint coordinate?

    Would this help at all.
    From XL-Logic.com
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    @romperstomper : Please do.. i really need it for my project..

    @jolivanes :
    Hmmm... i don't think it discusses the same subject... mine is coordinates INSIDE the picture.. i think that one is outside coordinates...
    but thanks anyway for your help.

  15. #15
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Btw is it really impossible to "control" paint.exe?
    You just like when you export text files to notepad, you open notepad.exe and write stuff into it?

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    How complex are these images? Can you post an example.

    If you were controling Notepad you would use sendkeys.
    As fas as I can see Paint is pretty much a mouse driven app.
    Cheers
    Andy
    www.andypope.info

  17. #17
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Here's the image that i'm working at :

    http://ifile.it/twou6rg

    It's a B&W image, with around 2000 pixels but i may reduce the quality again later though..

  18. #18
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    I used a chart to hold the image. Format Chart area Pattern > Fill effect > Picture.

    Click the start point and then while still holding the mouse move to the end point and release the button. You should now have 2 sets of x,y values.

    Private m_lngOutputRow As Long
    Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
    
        If Button = 1 Then
            With Worksheets("Sheet1")
                If Len(.Cells(.Rows.Count, 1)) = 0 Then
                    m_lngOutputRow = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
                    .Cells(m_lngOutputRow, 1) = x
                    .Cells(m_lngOutputRow, 2) = y
                Else
                    MsgBox "Full up"
                End If
            End With
        End If
        
    End Sub
    
    
    Private Sub Chart_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
    
        If Button = 1 Then
            With Worksheets("Sheet1")
                .Cells(m_lngOutputRow, 3) = x
                .Cells(m_lngOutputRow, 4) = y
            End With
        End If
    
    End Sub
    
    Private Sub Chart_MouseUp(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
    
        If Button = 1 Then
            With Worksheets("Sheet1")
                .Cells(m_lngOutputRow, 3) = x
                .Cells(m_lngOutputRow, 4) = y
            End With
        End If
        
    End Sub
    I guess the next part is relating the xy data to the actual picture.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Thanks.
    So.. This code will list all the coordinates in the pic? Or just the specific ones? I cant test it coz i dun have my pc right now..
    But i need to list specific points only though.. Thats why i use the mouse to find them one by one.. How do i do that?

  20. #20
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Ah i see now..
    Wow it really works.. thanks :D
    But there's one last problem..
    Where's the option to adjust the width and length of the chart area?
    I got different coordinates with paint because it's stretched..
    I think the width and length of the chart area must be the same with the image..

    Oh and 1 more thing...
    i only need to list dots actually, not lines...
    so i guess only one XY is needed..
    But it's okay i guess i can use the first 2 columns
    Last edited by Kb24; 08-15-2009 at 11:28 AM.

  21. #21
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    As I said this is the hard part as none of the stuff in excel is talking in pixels.

    It's points, twips or some other scaling.

    What you would need to do is get the mouse reported information for topleft and bottom right. You then need the actual pixel widt/height of the image.

    From that information you should be able to work out a scaling factor for x and y values.

  22. #22
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    I see.. I tried to scale it and the result was not too accurate...

    How about changing the column/row width ?
    I looked up in google and found this :
    http://support.microsoft.com/kb/214123
    http://office.microsoft.com/en-us/ex...517241033.aspx

    Or this
    http://www.eggheadcafe.com/software/...ead-for-c.aspx

    somebody there seems to make a similar code to read coordinates, but i can't understand a thing he said

  23. #23
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    http://nielsolson.us/Haversian/2006/...and_chara.html

    Just some more reference that i found about pixels in excel

  24. #24
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    Try this revision which include sizing factor.

    Set image to 100% view
    I started by clicking topleft and bottomright of chart area.

    I moved those 2 sets of values out and added the images dimensions.
    From these figures it's possible to calculate a x and y factor.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Umm.. Sorry but i still don't get it,
    the ratio is somehow inconsistent,
    so even with the factors i still get different result
    i'll use 2 cases as example :

    1. On paint,
    I point the mouse to the tip of dead end road on "Jl. Petak baru" (See attachment pic1, it's the red-circled area),
    and the coordinate is 402 171..
    But when i do the same thing on your chart , it says 541 146..
    So that means X increases and Y decreases

    2. On paint, the top of "Jl. Jambon" is 589, 21 (see pic2)
    But on excel its 777 33.. Now X increases But Y also increases..
    So both of them have different factors..
    Any idea why?
    Attached Images Attached Images

  26. #26
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    There are a couple of reasons for this.

    Firstly the x,y values reported by the mouseover and mousedown events appear to be completely different. So the scaling is out.
    Also you have a different sized image than the one I'm using.

    I have reverted to using the image control as suggested by RS.

    The control is on sheet 2 although the image itself has not be included as it makes the file too large. So you need to set the picture property to the image you are using.
    Use the Autosize property to get the full size of the image.
    Enter the controls width/height in sheet1 along with the images pixel size.

    You should now get a fairly accurate report of the x,y value in the statusbar.
    clicking the image will again append values on sheet1
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    I did all that but.. Nothing happens when i click the image..
    Same case as before.. RS gave me Image chart but nothing happens when i click it..
    Is it because i use Excel 2007?

  28. #28
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    Worked fine in my xl2007 SP2.

    Did you exit design mode once you loaded the image?

    You should get a mouse pointer when moving over the image rather than a NSEW pointer.

  29. #29
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Record Windows paint coordinate?

    Excellent! It really works ! :D

    I almost gave up on this :p
    Thx alot !
    +rep for you

  30. #30
    Registered User
    Join Date
    08-11-2014
    Location
    Las Vegas, NV
    MS-Off Ver
    2010
    Posts
    2

    Re: Record Windows paint coordinate?

    I'm coming in a little late in this conversation, but I am trying to digitize a curve (get the x,y coords) from an image i have in Paint. I would love to just use mouse clicks to record the coords in an excel file. Now I do it manually from the Paint coords.I think your program should do what I need, but i can't get it to work. By the way, I can't seem to convert my pointer on sheet two of excel ro the regular pointer - it's always a '+'.

  31. #31
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,450

    Re: Record Windows paint coordinate?

    Glad you got it working.
    Don't forget romperstomper, he gave you the solution 2 days ago.

  32. #32
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,661

    Re: Record Windows paint coordinate?

    waynert,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1