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?
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?
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.
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. :cool:
I'm sure you could adapt this code to check every pixel for a certain color instead. ;)
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
cant get it to work..
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?
well, i want it to monitor the screen and when the color (RGB: 16,248,0) is found, i get a messagebox informing me..
anyone know how to do this?
up
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
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. :(
Just because Filburt is bored right now :rolleyes:, why do you want to do this? What will your program do in the end?Quote:
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 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 :(