bulldog Posted January 2, 2005 Posted January 2, 2005 I'm working on a program right now where I have the need to make a function that when feed the x,y coords of a certain pixel on the screen spits out the RGB number of that pixel. The pixels will lie outside the program so I can't use functions attached to my Form's controls (i.e. find out the pixel is part of a button and use btnStart.get_BackColor()). I'm using J# .NET, and can't really find anything on MSDN or online that deals with this sort of problem (maybe I'm no good at researching). I thought of using a colorpicker dialog, similar to the eyedropper on Photoshop, but can't find one (didn't they have one in Visual J++?), or even PrintScreen and enumerating through the pixels until I get to the one I want, but can't figure out a way to do a screen capture (SendKeys.Send("{PRTSC}") is not yet implemented). As you can tell I don't need an elegant solution, I'm a hardcore hacker at heart. Thanks in advance, this would really help me out a lot. Quote
ThePentiumGuy Posted January 2, 2005 Posted January 2, 2005 Crap. J# doesn't let you do SendKeys? I was going to suggest you do this: Public Function GetScreenCapture(Optional ByVal FullScreen As Boolean = False) As Image ' Captures the current screen and returns as an Image ' object Dim objSK As SendKeys Dim imgCapture As Image If FullScreen = True Then ' Print Screen pressed twice here as some systems ' grab active window "accidentally" on first run objSK.SendWait("{PRTSC 2}") Else objSK.SendWait("%{PRTSC}") End If Dim objData As IDataObject = Clipboard.GetDataObject() Return CType(objData.GetData(DataFormats.Bitmap), Bitmap) End Function Try SendWait then ;). Sorry I can't help you there. -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
bulldog Posted January 3, 2005 Author Posted January 3, 2005 Quote Crap. J# doesn't let you do SendKeys? I was going to suggest you do this: Public Function GetScreenCapture(Optional ByVal FullScreen As Boolean = False) As Image ' Captures the current screen and returns as an Image ' object Dim objSK As SendKeys Dim imgCapture As Image If FullScreen = True Then ' Print Screen pressed twice here as some systems ' grab active window "accidentally" on first run objSK.SendWait("{PRTSC 2}") Else objSK.SendWait("%{PRTSC}") End If Dim objData As IDataObject = Clipboard.GetDataObject() Return CType(objData.GetData(DataFormats.Bitmap), Bitmap) End Function Try SendWait then ;). Sorry I can't help you there. -The Pentium Guy hehe..... umm I feel dumb for saying this, but you were right. In the MSDN documentation it says that the {PRTSC} argument of SendKeys.Send() is reserved for future use, but I went ahead and tried it anyways.... low and behold it works. Thanks for the advice. Quote
ThePentiumGuy Posted January 3, 2005 Posted January 3, 2005 No problem. It looks like Microsoft needs to update their documentation :). Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.