|
-
Aug 2nd, 2001, 10:31 AM
#1
Thread Starter
Frenzied Member
Help!! Is it possible to send a messagebox if a certain color is detected on screen?
Anyone know of a program, or how to make a program that will monitor the users screen and send a message box when a certain color is detected?
-
Aug 2nd, 2001, 10:42 AM
#2
Frenzied Member
Do you mean just when a VB apps backcolor is a certain color, or anything on the screen. If it is the latter, I would assume there would have to be some pretty fancy API code.
-
Aug 2nd, 2001, 10:53 AM
#3
Frenzied Member
Look into the GetPixel and SetPixel API:
http://www.vbapi.com/ref/g/getpixel.html
http://www.vbapi.com/ref/s/setpixel.html
The example code for setpixel goes through every pixel on a form and randomly changes the color.
I'm sure you could adapt this code to check every pixel for a certain color instead.
-
Aug 2nd, 2001, 12:32 PM
#4
Frenzied Member
Try this code. VB kept on crashing lately, so I couldn't debug it:
FORM CODE:
VB Code:
Function NotifyonColor(Color As OLE_COLOR) As Boolean
Dim Colored as Long, X as long, Y as long, MaX as Long, MaY As long, temp as boolean
If OLE_COLOR > &H79999999 Then Colored = GetSysColor(OLE_COLOR - &H80000000) Else Colored = Color
max = me.scalex(screen.width, 1, 3)
may = me.scaley(screen.height, 1, 3)
for x = 0 to max
for y = 0 to may
if getpixel(getdc(0)) = Colored then
temp = True
Exit For
End if
next
next
NotifyonColor = temp
End Sub
MODULE CODE:
VB Code:
Public Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long
Public Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Public Declare Function GetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Aug 2nd, 2001, 01:19 PM
#5
Thread Starter
Frenzied Member
-
Aug 2nd, 2001, 01:22 PM
#6
Member
Well, could you be more clear first? Do you want to know if at least one pixel on the screen is, say, pure red? (#FF0000 or 255 0 0) Or a pixel at a certain location?
-
Aug 2nd, 2001, 02:25 PM
#7
Thread Starter
Frenzied Member
well, i want it to monitor the screen and when the color (RGB: 16,248,0) is found, i get a messagebox informing me..
-
Aug 2nd, 2001, 02:42 PM
#8
Thread Starter
Frenzied Member
anyone know how to do this?
-
Aug 2nd, 2001, 03:07 PM
#9
Thread Starter
Frenzied Member
-
Aug 2nd, 2001, 03:15 PM
#10
Frenzied Member
VB Code:
Option Explicit
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Function NotifyonColor(Color As OLE_COLOR) As Boolean
Dim Colored As Long, x As Long, y As Long, MaX As Long, MaY As Long, temp As Boolean
If Color > &H79999999 Then Colored = GetSysColor(Color - &H80000000) Else Colored = Color
MaX = Me.ScaleX(Screen.Width, 1, 3)
MaY = Me.ScaleY(Screen.Height, 1, 3)
For x = 0 To MaX
For y = 0 To MaY
If GetPixel(GetDC(0), x, y) = Colored Then
temp = True
Exit For
End If
Next
Next
NotifyonColor = temp
End Function
Private Sub Form_Load()
If NotifyonColor(&HC0C0C0) = True Then MsgBox "*"
End Sub
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Aug 2nd, 2001, 03:17 PM
#11
Member
That code will probably take a year to execute, especially on higher resolutions, but short of using something like DirectX there is probably little you can do about it.
-
Aug 2nd, 2001, 03:18 PM
#12
Member
Originally posted by qpabani
well, i want it to monitor the screen and when the color (RGB: 16,248,0) is found, i get a messagebox informing me..
Just because Filburt is bored right now , why do you want to do this? What will your program do in the end?
-
Aug 7th, 2001, 07:45 AM
#13
Thread Starter
Frenzied Member
just need it as a trade enchancement in diablo2, so when i get a message (which will be in green) a messagebox will show so i know i received a message.
however, your code wont work
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
|