|
-
Feb 26th, 2006, 12:36 AM
#1
Thread Starter
Addicted Member
[resolved] Test Colour
hey me again ...
I got this code... All mine
VB Code:
Public Function TestColor(Colortest As Long) As String
Dim X As Long, Y As Long, test As Long, wndrect As RECT
GetWindowRect selWnd, wndrect
test = GetDC(selWnd)
TestColor = false
For Y = 0 To (wndrect.Bottom - wndrect.Top)
For X = 0 To (wndrect.Right - wndrect.Left)
If GetPixel(test, X, Y) = Colortest Then
TestColor = true
Exit Function
Exit Function
End If
Next X
Next Y
End Function
but when i type in
if testcolor(255)=true then msgbox "Found it"
if doesnt find it... but if i put in false it does find it....
I know there is a color 255 on my screen but it all screws up....
ive tried reversin the true and false statements but it still works in reverse....
any help?
Last edited by Hack; Mar 3rd, 2006 at 07:25 AM.
-
Feb 26th, 2006, 12:58 AM
#2
Re: Test Colour
You should return a boolean, and you don't need 2 exit function
VB Code:
Public Function TestColor(Colortest As Long) As Boolean
Dim X As Long, Y As Long, test As Long, wndrect As RECT
GetWindowRect selWnd, wndrect
test = GetDC(selWnd)
TestColor = false
For Y = 0 To (wndrect.Bottom - wndrect.Top)
For X = 0 To (wndrect.Right - wndrect.Left)
If GetPixel(test, X, Y) = Colortest Then
TestColor = true
Exit Function
End If
Next X
Next Y
End Function
-
Mar 1st, 2006, 09:41 PM
#3
Thread Starter
Addicted Member
Re: Test Colour
ok let me rephrase that... When i say to find something it wont find it .. eg returen false
even if it is true it just wont find it ... ?!?!
-
Mar 1st, 2006, 09:51 PM
#4
Frenzied Member
Re: Test Colour
maybe this revision of mine could help
VB Code:
Public Function TestColor(Colortest As Long) As Boolean
Dim X As Long, Y As Long, test As Long, wndrect As RECT
GetWindowRect selWnd, wndrect
test = GetDC(selWnd)
For Y = 0 To (wndrect.Bottom - wndrect.Top)
For X = 0 To (wndrect.Right - wndrect.Left)
If GetPixel(test, X, Y) = Colortest Then
TestColor = true
Exit Function
End If
Next
Next
TestColor = false
End Function
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 1st, 2006, 10:52 PM
#5
Addicted Member
Re: Test Colour
i think a pixel is in form of RGB like this &HFFFFFF, which the middle byte is Green, and the left byte is either Red or Blue (sorry forget the sequence)
if you want to compare 255 (i consider you want to compare a white pixel) you should compare with &HFFFFFF rather than 255 decimal.
-
Mar 2nd, 2006, 08:46 PM
#6
Thread Starter
Addicted Member
Re: Test Colour
LOL i found out what the problem was...
i feel so ashamed
when i selected the current window it would find it fine... but when i said find colour then clicked on play it would only do it in the selected window... so i just made it go on a hotkey.. and it worked..
thanks to you all for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|