-
Aug 11th, 2009, 08:31 PM
#1
Thread Starter
Addicted Member
Check pixel at x,y of an app's window (RESOLVED)
We are running an old bbs DOS based (bulletin board system) in a windows environment, occasionally it will crash and we need to detect when that happens (the application does not close or send any windows info that can be detected, instead the app shows a ANSI colored error message within the app window and waits for user's input), the only way we can automatically detect an error is to find a red pixel within a specified area of the window. How would we be do that? It wouldn't be a problem If the app started up at the same place on the screen every time, but that is not the case. All suggestion are welcomed and appreciated.
Last edited by SavedByGrace; Aug 12th, 2009 at 01:11 AM.
Reason: RESOLVED
-
Aug 11th, 2009, 09:51 PM
#2
Re: Check pixel at x,y of an app's window
Originally Posted by SavedByGrace
the only way we can automatically detect an error is to find a red pixel within a specified area of the window. How would we be do that? It wouldn't be a problem If the app started up at the same place on the screen every time, but that is not the case. All suggestion are welcomed and appreciated.
Never really played with a DOS window, so just some ideas that may or may not work.
You can use GetPixel API to find what color is on the screen at a certain x,y position.
You could move the window so it's always in the same position using the MoveWindow API, use FindWindw API to get the windows handle and pass that to MoveWindow with the position you want.
Or if you know the pixel you are looking for is at say (100,100) when DOS window is at say the very top-left of the screen (0,0) , then use GetWindowRect to get the current top & left position of the window and add that to your known pixle position x,y to see if its red or not.
-
Aug 11th, 2009, 09:53 PM
#3
Re: Check pixel at x,y of an app's window
You can use the GetPixel() API function...
- Get hWnd (window handle) of application by its Title using FindWindow or FindWindowEx
- Get the Window's hDC (device context handle) using the GetDC API function
- Use GetPixel on that hDC to get the color value
-
Aug 11th, 2009, 10:27 PM
#4
Thread Starter
Addicted Member
Re: Check pixel at x,y of an app's window
Edgemeal - The app will be starting in our absence at predefined times - so we cannot guarantee a location for the app
DigiRev - Those seem like really good suggestions and I have seen those references for api for this type of issue, unfortunately, I am not very knowledgeable with using api and don't know how to put those to work for this problem.
-
Aug 11th, 2009, 11:03 PM
#5
Re: Check pixel at x,y of an app's window
Not sure this will help but heres a fast way to find a color on the screen, the example also moves the mouse cursor to the position which you can easily remove. See the project in post #25 here, and the last few comments after that.
EDIT Oh I see you are the one who asked that Q in that link, in that case never mind, you've seen that before!
Last edited by Edgemeal; Aug 11th, 2009 at 11:22 PM.
-
Aug 12th, 2009, 12:32 AM
#6
Thread Starter
Addicted Member
Re: Check pixel at x,y of an app's window
Thanks Edgemeal
-
Aug 12th, 2009, 01:10 AM
#7
Thread Starter
Addicted Member
Re: Check pixel at x,y of an app's window
Thank you to those who gave info and advise to my post. I was able to resolve this by heavily modifying http://www.vbforums.com/showthread.p...ndWindow+GetDC Post #11 to suit my needs.
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
|