Locked Colour Detection And Press Key

  • Thursday, September 13, 2012 4:58 PM
     
     

    Hello :D

    I am New to VB , Just started to learn it ..
    I am planning to make a Program That can detect colour at a certain Coordinate ..
    2 colour detection part ( same Coordinate)
    If red colour to Grey colour , Press a specific key
    And
    2nd Coordinate if blue colour change to Grey Colour Press a specific key :D
    So 2 colour detection spot and 2 coordinate
    Owh , and teach me how to check what coordinate it is :D please list it simple and make me easy to understand ... :D I am a new learner after all :D
    Thank You :D

All Replies

  • Thursday, September 13, 2012 9:37 PM
     
     

    You will need to spell out your requirement a little more clearly.

    Do you mean that you want to detect the color at a specific location, or do you want to detect the change in color (red to gray and gray to red) from one moment to the next?  Or do you mean that you need to search for a location where the color changes between one pixel and the next adjacent pixel?

    When you say 'press a specific key' do you mean that you want your application to simulate the pressing of a key for another application?  If it's another application, you will need to provide the details of that other application.

    What do you mean 'check what coordinate it is'  Do you mean that the position of pixels to be checked has to be calculated somehow?  What is the rule for finding this coordinate?   What happens if there are several such locations?

  • Friday, September 14, 2012 1:42 PM
     
     

    You will need to spell out your requirement a little more clearly.

    Do you mean that you want to detect the color at a specific location, or do you want to detect the change in color (red to gray and gray to red) from one moment to the next?  Or do you mean that you need to search for a location where the color changes between one pixel and the next adjacent pixel?

    When you say 'press a specific key' do you mean that you want your application to simulate the pressing of a key for another application?  If it's another application, you will need to provide the details of that other application.

    What do you mean 'check what coordinate it is'  Do you mean that the position of pixels to be checked has to be calculated somehow?  What is the rule for finding this coordinate?   What happens if there are several such locations?

    Hi Acamar,

    Thank you for reply:D

    1)The color at a specific location

    2)Simulate the pressing of a key for another application(a game call maplestory)

    3)What is the rule for finding this coordinate?
    Thank you please state it clearly , I am new :D

  • Friday, September 14, 2012 3:15 PM
     
     
    Ask your question on the Maplestory site.
  • Friday, September 14, 2012 10:23 PM
     
     

    1)The color at a specific location

    So you mean that the program will detect whether the color at that location will be Red or Grey?  For instance, if it's red, then press the key, and if it's grey then don't press the key.  This will happen when the user indicates it should happen.  For instance, the user will press a button on your form, the program will look at the color at that location, and press, or not press, the key.

    2)Simulate the pressing of a key for another application(a game call maplestory)

    You need to use the SendKeys command.  See:
    http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

    3)What is the rule for finding this coordinate?

    You need to tell us.  You need to determine the procedure by which this location can be discovered.  Then that procedure can be coded into your program.  For instance, is it always in a fixed position with the window, or does it move?

  • Saturday, September 15, 2012 10:29 AM
     
     

    1)Will be red :D if red Change to grey send a key :D there will be 2 spot one is blue to grey and one is red to grey(2 spot){means It need to detect 2 spot in one time :D)

    3)It is always in a fixed position in the window

    Please State it clearly :D Thank You :D

  • Saturday, September 15, 2012 11:50 AM
     
     Answered

    You will need a timer.  When the timer ticks, use the CopyFromScreen method to get the screen image into a bitmap:
    http://msdn.microsoft.com/en-us/library/fw1kt6f9.aspx

    Your description of the location is still very vague, but I assume you mean the pixel is in a defined location within the window of that other application.  To get that pixel you need the location of that window on the screen. The process class can be used to get the details of that other application:
    http://msdn.microsoft.com/en-us/library/x8b2hzk8.aspx

    Once you have the process, you can get the window handle:
    http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainwindowhandle.aspx

    With the process ID and the window handle you can find the location of the window on the screen using a Win32 API call.  Note that the rectangle format is not what you may be used to:
    http://www.pinvoke.net/default.aspx/user32.getwindowrect

    Since you know the location of the pixel within the window, you can calculate the pixel position within the image from that location offset by the window location.  Then use GetPixel to get the color of the pixel at that location, and determine whether or not it has changed:
    http://msdn.microsoft.com/en-au/library/system.drawing.bitmap.getpixel.aspx

    • Marked As Answer by Lee Jerng Yue Saturday, September 15, 2012 4:14 PM
    •  
  • Saturday, September 15, 2012 5:01 PM
     
     
    Thank you
    Acamar , 
    But I am not familiar with this can you give me a youtube link or a video step by step tut? Please Sorry 
    Anyways TQ:D
  • Saturday, September 15, 2012 9:17 PM
     
     Answered
    You have a very distinct requirement - iI don't know if there would be a tutorial available, but it might be worth searching.
    • Marked As Answer by Lee Jerng Yue Sunday, September 16, 2012 6:49 AM
    •  
  • Saturday, September 15, 2012 9:56 PM
     
     
    You should post to the Maplestory forums.  Finding a color and clicking on it isn't something new.  I'm sure many of the other players have code for it.