Results 1 to 9 of 9

Thread: What am I doing wrong?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    What am I doing wrong?

    Loading
    Code:
          ProcessHandle = FindWindow(vbNullString, "Google - Mozilla Firefox")
            ProcessDC = GetDC(0)
    Closing
    Code:
     Call ReleaseDC(0, ProcessDC)
    Timer
    Code:
       On Error Resume Next
            Dim X As Long, Y As Long, PixelColor As Long
            Dim CursorPosition As Point
            Call GetCursorPos(CursorPosition)
            For X = CursorPosition.X - 20 To CursorPosition.X + 20
                For Y = CursorPosition.Y - 20 To CursorPosition.Y + 20
                    PixelColor = GetPixel(ProcessDC, X, Y)
                    If (PixelColor = RGB(255, 0, 0)) Then
         MessageBox.Show("") 'to see if it finds the color
     Exit Sub
                               End If
                Next Y
            Next X
    Theres no MessageBox that pops up, what's wrong?
    Last edited by werido; Nov 25th, 2009 at 01:01 AM.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Why am I doing wrong?

    Put your debugging skills to work. What is PixelColor when you call GetPixel? What do you expect it to be?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Re: Why am I doing wrong?

    Quote Originally Posted by Negative0 View Post
    Put your debugging skills to work. What is PixelColor when you call GetPixel? What do you expect it to be?
    Should X/Y be integer?

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: What am I doing wrong?

    Yes X and Y should be integers and your GetPixel declaration should have them as integers.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Re: What am I doing wrong?

    Quote Originally Posted by Negative0 View Post
    Yes X and Y should be integers and your GetPixel declaration should have them as integers.
    I changed it to integer, and it still doesnt work.

  6. #6
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: What am I doing wrong?

    I'll ask again: What is PixelColor when you call GetPixel? What do you expect it to be?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Re: What am I doing wrong?

    Quote Originally Posted by Negative0 View Post
    I'll ask again: What is PixelColor when you call GetPixel? What do you expect it to be?
    I expect GetPixel to find a color in the window.

  8. #8
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: What am I doing wrong?

    Get pixel simply returns the color at a given pixel. You should be able to test that it is working by giving pixel coordinates where you know what the color is and check that GetPixel is returning the value you expect.

  9. #9
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: What am I doing wrong?

    Quote Originally Posted by werido View Post
    Code:
       On Error Resume Next
    Bad!! bad, bad, bad, bad!!!!!!!!!!!!
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

Posting Permissions

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



Click Here to Expand Forum to Full Width