fusion400 Posted March 29, 2010 Posted March 29, 2010 (edited) Is there any way to determine if 90% of the pixels on screen is white. I have a program that has a very nasty bug that has to be worked around. Sometimes lets say on average every 20th-30th time the software is started it does not start properly but instead shows a white screen with a rectangle. I have included the image of how it looks like. The rectangle could be at a random place on the screen at every startup so specific pixel locations can not be used to be 100% sure there really is a problem. Can this be done with autoit? If it finds that 90% of the pixels are indeed white i want it to be able to kill the process and start it again. This should loop all the time so it can detect the problem when it happens every time. A different solution could also be to somehow find the coordinates for the rectangle on screen and then simulate double click on it as this would make the program run properly. Thanks in advance Edited March 29, 2010 by fusion400
JohnOne Posted March 29, 2010 Posted March 29, 2010 What is the screen supposed to look like ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 What is the screen supposed to look like ?Hi i have attached a picture on my first post so you can see how it looks like.
Tvern Posted March 30, 2010 Posted March 30, 2010 I would make a script that runs in the background when you run this program and use Hotkeyset() to assign a hotkey to it. When you run into the problem you can press the hotkey which triggers the script to click the box. Clicking the box can be done in mutliple ways. Which one is best depends on what information you have. Some functions to look at are "ControlClick(), MouseClick(), and PixelSearch(). The "90%" white method would be very cpu heavy. If you insist in using this method I'd use a For...Step...Next loop to "Pixelgetcolor" a number of pixels and have it sleep for a short amount of time if it fails. (meaning it found non-white pixels) Hope that helps
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 Ok is there anyway to have a function that loads a bitmap image of the rectangle and then tries to find it on the screen and if there is a match then double click this would be the most safe way to do it i think.
JohnOne Posted March 30, 2010 Posted March 30, 2010 Hi i have attached a picture on my first post so you can see how it looks like.Well as far as I can tell, that picture is what it is NOT supposed to look like.If you provide a picture of what it IS supposed to look like on startup, Im sure a solution will quickly come. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 Well as far as I can tell, that picture is what it is NOT supposed to look like.If you provide a picture of what it IS supposed to look like on startup, Im sure a solution will quickly come.Well thats the problem that what comes after could be any kind of picture or movie with no specfic pattern at all.The software is basically a picture and video player. It can also load touch sensitive flash applications.
JohnOne Posted March 30, 2010 Posted March 30, 2010 (edited) Ive use this in the past for something similar, and found it fairly swift.Find the image and make some code to double click it.EDIT: findBMP by junkew. Edited March 30, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 Ive use this in the past for something similar, and found it fairly swift. Find the image and make some code to double click it. I tried the example bmp files that are included in pics.zip to see if i can get a match that the calculator bmp is indeed in fullscreen.bmp and i use the following code: $start = TimerInit() $tResult=findBMP("c:\pics\fullscreen.bmp", "c:\pics\CALCULATOR.bmp", TRUE) ConsoleWrite($tResult & "** Full seven totalmatch time elapsed: " & TimerDiff($start) / 1000 & " seconds" & @LF) But it just gives an "error locking region 1" messagebox as a result so i just don't know what to do or what that means. The console output is False** Full seven totalmatch time elapsed: 1.9490346158473 seconds
JohnOne Posted March 30, 2010 Posted March 30, 2010 (edited) Re you saving the picture to look for as 24bit bitmap ? And try just $tResult=findBMP("c:\pics\fullscreen.bmp", "c:\pics\CALCULATOR.bmp") (without True) Edit: Also, findBMP() returns an array if successful. Edited March 30, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 Re you saving the picture to look for as 24bit bitmap ?And try just $tResult=findBMP("c:\pics\fullscreen.bmp", "c:\pics\CALCULATOR.bmp")(without True)Edit: Also, findBMP() returns an array if successful.Yes i tried without TRUE and i still get "error locking region 1" and the console message is:False** Full seven totalmatch time elapsed: 2.74558375270671 seconds
JohnOne Posted March 30, 2010 Posted March 30, 2010 Dont know what else to tell you mate just tested it again with both 24bit bitmaps in the scriptfolder and FindBMP.au3 in scriptfolder also. This will find the startbutton on my desktop and click it. #include-once #include 'FindBMP.au3' $apos = _FindBMP('FullScreen.bmp', 'StartButton.bmp') MouseClick('Primary',$apos[3],$apos[4]) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 (edited) Dont know what else to tell you mate just tested it again with both 24bit bitmaps in the scriptfolder and FindBMP.au3 in scriptfolder also. This will find the startbutton on my desktop and click it. #include-once #include 'FindBMP.au3' $apos = _FindBMP('FullScreen.bmp', 'StartButton.bmp') MouseClick('Primary',$apos[3],$apos[4]) Hi i've tried this and it does not work at all. It just says Variable used without being declared.: $apos = FindBMP('c:\pics\fullscreen.bmp', 'c:\pics\CALCULATOR.bmp') $apos = FindBMP('c:\pics\fullscreen.bm^ ERROR Edited March 30, 2010 by fusion400
JohnOne Posted March 30, 2010 Posted March 30, 2010 $apos = FindBMP('c:\pics\fullscreen.bmp', 'c:\pics\CALCULATOR.bmp')$apos = FindBMP('c:\pics\fullscreen.bm^ ERRORThat is not pointing to a variable error, it seems to bo pointing to a syntax error. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 That is not pointing to a variable error, it seems to bo pointing to a syntax error. ok the code looks like this #include-once #include 'FindBMP.au3' $apos = FindBMP('c:\pics\fullscreen.bmp', 'c:\pics\CALCULATOR.bmp') MouseClick('Primary',$apos[3],$apos[4]) I have tried also to just have the pictures in the include folder but it made no difference still same error.
JohnOne Posted March 30, 2010 Posted March 30, 2010 Have you tried it with error checking ? #include-once #include 'FindBMP.au3' $apos = _FindBMP('FullScreen.bmp', 'StartButton.bmp') If @error = 1 Then MsgBox(0, "Error", "error with the DLLCall") Exit Else MouseClick('Primary', $apos[3], $apos[4]) EndIf AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 30, 2010 Author Posted March 30, 2010 (edited) Have you tried it with error checking ? #include-once #include 'FindBMP.au3' $apos = _FindBMP('FullScreen.bmp', 'StartButton.bmp') If @error = 1 Then MsgBox(0, "Error", "error with the DLLCall") Exit Else MouseClick('Primary', $apos[3], $apos[4]) EndIf I wonder if there is still some error and if i use the underscore with _FindBMP then it just says unknown function name. Unknown function name.: $apos = _FindBMP('FullScreen.bmp', 'StartButton.bmp') $apos = ^ ERROR Do we really use the same FindBMP.au3 maybe you can attach yours in a file here on the forum ? Edited March 30, 2010 by fusion400
JohnOne Posted March 30, 2010 Posted March 30, 2010 (edited) Sure but I'm pretty certain its the same. EDIT: did it error ?FindBMP.au3 Edited March 30, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
fusion400 Posted March 31, 2010 Author Posted March 31, 2010 Sure but I'm pretty certain its the same.EDIT: did it error ?Hello i am using your FindBMP.au3 but it has a different error do you have the"../ScreenCapture/ScreenCaptureFixed.au3" file i can't seem to find it.The FindBMP.au3 file was not the same. GDI and Screencapturefixed and some variables where included inyour file.
JohnOne Posted March 31, 2010 Posted March 31, 2010 Yes just include #include <GDIPlus.au3> #Include <ScreenCapture.au3> in your code That is shown in the sample code in the link I gave to FindBMP I think both are included with autoit download fixed is specific to another script. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now