
Zog
Members-
Posts
10 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Zog's Achievements

Seeker (1/7)
0
Reputation
-
Ack!!! I just realized the newer posts are on top. Didn't mean to dredge up a 19 year old thread!!!
-
I may not be understanding your question, however, I'll offer this utility we use all the time. Func IsColorAtPos2($x,$y,$color,$colorTolerance=0,$deltaX=0,$deltay=0,$checkTimes=1,$minimumFoundCount=1,$sleepTime=10) ; this function returns true if the color is found at the position specified, false if not ; $x = centroid x coordinate of the area to search ; $y = centroid y coordinate of the area to search ; $color = the decimal color you wish to search for ; $colorTolerance = the decimal color tolerance allowable for the $color you wish to search for. Default: no tolerance ; $deltaX = the plus and minus pixels from the $x centroid to search. Default: no tolerance, only look at the $x centroid pixel ; $deltaY = the plus and minus pixels from the $y centroid to search. Default: no tolerance, only look at the $y centroid pixel ; $checkTimes = how many times to check the area for the $color (w/ tolerance as appropriate). Default: one time ; $minimumFoundCount = minimum number of times the $color (w/ tolerance as appropriate) must be found. Default: one time ; $sleepTime = the msec between checks when using $checkTime. Default: 10 MS If $colorTolerance = 0 AND $deltaX=0 AND $deltaY=0 Then $foundCount = 0 For $i=1 To $checkTimes If PixelGetColor($x,$y)=$color Then $foundCount = $foundCount+1 EndIf Next If $foundCount >= $minimumFoundCount Then Return True Else Return False EndIf Else $foundCount = 0 For $i=1 To $checkTimes $pos=PixelSearch($x-$deltaX,$y-$deltaY,$x+$deltaX,$y+$deltaY,$color,$colorTolerance) If @error Then Else $foundCount=$foundCount+1 EndIf Sleep($sleepTime) Next If $foundCount >= $minimumFoundCount Then Return True Else Return False EndIf EndIf EndFunc ; find out if the color at coordinate (100,100) is white If IsColorAtPos2(100,100,16777215) Then ConsoleWrite("White color found"&@CRLF) Else ConsoleWrite("not white"&@CRLF) EndIf ; find out if the color at coordinate (100 +/- 50,100 +/1 20) is white with a tolerance of 100. Must find at least 5 times within 600 ms. Sample every 75ms If IsColorAtPos2(100,100,16777215,100,50,20,300/75,5,75) Then ConsoleWrite("White found within tolerance at least 5 times"&@CRLF) Else ConsoleWrite("white color not found, or not found enough times"&@CRLF) EndIf
-
@Nine - great idea. Tomorrow I'll run the following on all the different configurations in the testing lab at work: Local $absDiff = 0 Local $cumulativeDiff = 0 Local $signedDiff For $i = 1 To 100 $begin = TimerInit() Sleep(5000) $signedDiff = 5000-TimerDiff($begin) $absDiff = ABS($signedDiff) $cumulativeDiff = $cumulativeDiff+$absDiff ConsoleWrite($i&@TAB&$signedDiff&@TAB&$absDiff&@TAB&$cumulativeDiff&@CRLF) Next ConsoleWrite("--"&@CRLF) ConsoleWrite("Average difference="&$cumulativeDiff/100&@CRLF) Exit Perhaps anyone interested could do that as well and post their results. My home PC is AMD Ryzen 7 5800 8-Core Processor 3.40 GHz. I found the average difference over the 100 tests to be 4.27MS - which doesn't seem too broken to me. I didn't realize this was a 10 year old issue!
-
Is this the right forum to post this question?
-
One of my staff brought to my attention the following quote from the documentation for TimerDiff: We use Autoit for some process control applications and often use TimerInit() and TimerDiff() This is concerning to me. Is there a list of processors know to have problems with TimerDiff()? What is the nature of the problem? Is it off by milliseconds or does it not work at all or what? Thank you in advance.
-
Thank you. I saw this thread as a potential to get the foreman's input. I read through the code but didn't understand how to use it. When I inspect the screen I don't get controls - I believe the entire screen is a control for this software. I can get the name of the window and the window control 'handle' using the Autoit window info tool. However, all the spots where you are supposed to 'press' to activate valves are not showing as controls when I hover over them or click on the 'buttons'. We do not have the source code for this application so I can't dig deeper (or if a deeper dive is possible, I don't know how to do it.) This is proprietary software so my boss doesn't want me to display it anywhere outside the company. Given the cost the bug in the latest software update caused he may soften that stance if I push it and if it is needed somehow. However, in the end it is a window with some display stuff and some 'button' and 'slider bar' icons that respond to the foreman tapping the screen or tapping and sliding their finger (the tap and slide is for a control function we do not currently use so if that can't be captured then no biggie - I was going to model that for completeness but it is really out of scope for the current specs.) The window control info is: Advanced Mode [CLASS:vendorNameWindowClass; INSTANCE:1] ID <blank - no value displayed> Handle 0x0003006C Capturing what the foreman actually does is part 1. Part 2 is then replaying and simulating the touchscreen taps via Autoit. Is that something you have done/can be done? If there is no way to simulate the actual foreman touch actions then the first part of capturing his motions is still useful as I could simulate his actions with 'mouseclick' but it is less desirable than actually simulating the touching of the screen. Thank you in advance for any help you can give!
-
We have a purchased application which is deployed on the shop foremen's Asus laptops. We installed a new version and all hell broke loose because of a bug in the vendor's code. I am tasked with writing an automated regression test script to test the application whenever we upgrade the vendor's software. I can do this with mouseclick but I am told to do the testing like the foremen do with touching of the screen. I don't know if Autoit can do this - it is unclear from the forum threads here (which is probably because I've never needed to automate a touch pad and I am ignorant of what to do.) I have been requested to record what the lead forman does on his touchpad and then use that as input for my regression test scripts. I'd like to get the position (x,y), the press duration, the press down strength, and the size of the press down fingerprint. Once I can do that I'll run an Autoit script on the foreman's laptop and record what he's doing. I'll then edit them into a coherent set of functions calls and write some repeatable testing scripts. However, to meet the plant manager's requirements I need to 'simulate' as if the foreman actually pressed the screen with his finger - that is, run it through the same portion of the vendor's code as would be used on the shop floor. While not a neophyte at Autoit, I really am clueless about touch pads/screens. I've looked at the threads here and either didn't see what I am looking to do or the discussion was above my head and didn't understand it. Any guidance would be very much appreciated. As the vendor bug caused quite a bit of scrap...and as we are expecting a number of upgrades in 4Q22 and 1Q23...this is a priority for my bosses. Thanks in advance!
-
Improper Results for PixelSearch Right-to-Left
Zog replied to Zog's topic in AutoIt General Help and Support
In the staff meeting today the boss said it was not worth going to the lawyers to see if we could send a screenshot of the proprietary software outside the company. We did brainstorm a bit and the guys gave me two good work-around ideas: 1 Look from the left to right as PixelSearch seems to be broken looking right to left. I'll search for the background color instead of the bar color. This was a bit of a <facepalm>Doh</facepalm> moment for me when two of my teammates immediately suggested this. 2. Upon startup find the bar edge location. Then go pixel by pixel down/left (reagent concentrations always decrease after a recharge) until I find the bar. This is slow but the concentrations do not change all that fast. I remain intellectually curious about this. When I get some time I'll try to make up a mock-up of the problem and get it to reproduce reliably then post it here. To allow some discussion on this should I post it on this thread or create a new one? -
Improper Results for PixelSearch Right-to-Left
Zog replied to Zog's topic in AutoIt General Help and Support
I'll ask management if I can post a screenshot tomorrow. However, this seems to be a bug, or my code is somehow messed up. I have used Autoit a lot for automating testing of our own gui-based applications, and I have successfully used PixelSearch on other projects (enough that I created the routine shown in the longer example above: IsColorAtPos($x,$y,$color,$colorTolerance=0,$deltaX=0,$deltay=0,$checkTimes=1,$minimumFoundCount=1,$sleepTime=10) This routine is useful when you want to get a true/false if a color (with/without tolerance) is at or around a spot on the screen. In chemical processing there are lots of display screens that work well for humans - we detect color changes sorta automatically - that I've found more difficult to automate. In industry it is very common to buy control software that you have absolutely no control over and no source code and very often no API giving control information (such as the application I'm working on above.) However for management and/or operator screens I will consolidate this information into a screen(s) so the operator/manager does not need to flip through and learn all the different component software we have bought or legacy software we have created. Depending on the immediacy and/or the difficulty of the task I and/or other programmers have often used Autoit as the 'glue' because it runs with pretty darn good compatibility on both Windows and Unix applications - Autoit doesn't care if the screen I'm looking is running in Unix or Windows...I can look at the screen display either way. I note all this because I want you to know I'm not a neophyte at Autoit and this problem has vexed me and I have read the forums here looking for a solution. My reason for noting that reference to a gamer's question above was to demonstrate that I have read the forums. Wish I hadn't done that now... -
Improper Results for PixelSearch Right-to-Left
Zog posted a topic in AutoIt General Help and Support
I am trying to automate a legacy application we never had the source code for...so I can only look at the output screen and work with that. There are bars that indicate percent reagents. There are minor variations in the color from full to weak concentration as the bar goes from full to weak. The length of the bar gives an estimation of concentration remaining - I know where the LH edge of the bar is and I need to find the RH edge of the bar. Once I have the RH edge of the bar I can then calculate the percent concentration using the current bar length divided by the total bar length when the concentration is 100%. I need the percent concentration remaining to automate some clicks on another system control screen running in another window. None of that is a problem (I'm a programmer and have used Autoit a lot). The problem is getting inconsistent results from PixelSearch. I have taken repeated samples of the bar and found all the various colors. I've determined they vary by up to shade difference of 80 and found the average of all the colors in the bar. The goal is to know what percentage of the bar - which has a known fixed maximum length - is currently colored. Most of the time this works - here is a simplified version of the code to easily see the problem: $pos=PixelSearch(1237,963,1143,963,4054566,80) ; note: this is a RH to LH search since X1 > X2 If @error Then ; do error code Else $percent = (($pos[0]-1143)/(1237-1143))*100 EndIf ; here is some useful debug code $pos=PixelSearch(1237,963,1237,963,4054566,80) If @error Then $full = False Else $full = True EndIf ConsoleWrite("$full="&$full&" $percent="&$percent&@CRLF) Most of the time I'd get displayed something like 'False 89' however randomly I'd get 'False 100' - the bar is not 100% but somehow PixelSearch backwards across a single pixel high area thinks it is finding the RH edge whereas looking for the RH pixel does not (as is actually the case) find a pixel within the color variation. The application moves constantly so I have been testing this with various screenshots of the application - so there is no change between the two PixelSearch calls. I can't reliably reproduce this error, however, once the error occurs I can run the code on the same screenshot repeatedly the error goes away. I can go to other screenshot then back to the 'error' screenshot and now the code works properly...or not...randomly. I tried searching this forum but the only other forum post - describing the exact same thing I think - was shut down because he was trying to automate a game. I am trying to automate an industrial process. I don't know if this forum is active, but any help would be much appreciated. I hope it is just a bit of bad coding on my part and fresh eyes... A snippet from the real code I'm trying to implement: For $i=0 To 4 GetSelectedConcentration($i) Next Exit Func GetSelectedConcentration($vatPos) ; Note: $vatPos = 0 = rightmost selected vat Local $xPos[5][2] $xPos[0][0] = 1237 $xPos[0][1] = 1143 $xPos[1][0] = 1114 $xPos[1][1] = 1019 $xPos[2][0] = 991 $xPos[2][1] = 895 $xPos[3][0] = 867 $xPos[3][1] = 772 $xPos[4][0] = 743 $xPos[4][1] = 649 Local $colorTolerance = 80 Local $avgBarColor = 4054566 ; sometimes doing a nonsense search first will cause this to work $pos=PixelSearch(1,1,1,1,1,1) ; this is the actual search I want to do $pos=PixelSearch($xPos[$vatPos][0],963,$xpos[$vatPos][1],963,$avgBarColor,$colorTolerance) If @error Then ConsoleWrite("vat "&$vatPos&" 0 concentration"&@CRLF) Return 0 Else $percent=Round((($pos[0]-$xPos[$vatPos][1])/($xPos[$vatPos][0]-$xPos[$vatPos][1]))*100) ConsoleWrite("$vatPos="&$vatPos&" = "&$percent&@CRLF) ConsoleWrite("$pos[0]="&$pos[0]&" $pos[1]="&$pos[1]&" IsColorAtPos="&IsColorAtPos($xpos[$vatPos][0],963,$avgBarColor,$colorTolerance,0,0)&@CRLF) ConsoleWrite("---"&@CRLF) Return $percent EndIf EndFunc Func IsColorAtPos($x,$y,$color,$colorTolerance=0,$deltaX=0,$deltay=0,$checkTimes=1,$minimumFoundCount=1,$sleepTime=10) If $colorTolerance = 0 AND $deltaX=0 AND $deltaY=0 Then $foundCount = 0 For $i=1 To $checkTimes If PixelGetColor($x,$y)=$color Then $foundCount = $foundCount+1 EndIf Next If $foundCount >= $minimumFoundCount Then Return True Else Return False EndIf Else $foundCount = 0 For $i=1 To $checkTimes $pos=PixelSearch($x-$deltaX,$y-$deltaY,$x+$deltaX,$y+$deltaY,$color,$colorTolerance) If @error Then Else $foundCount=$foundCount+1 EndIf Sleep($sleepTime) Next If $foundCount >= $minimumFoundCount Then Return True Else Return False EndIf EndIf EndFunc ******** Example where the output is consistent with what is on the control screen ******** $vatPos=0 = 88 $pos[0]=1226 $pos[1]=963 IsColorAtPos=False --- $vatPos=1 = 100 $pos[0]=1114 $pos[1]=963 IsColorAtPos=True --- $vatPos=2 = 70 $pos[0]=962 $pos[1]=963 IsColorAtPos=False --- $vatPos=3 = 88 $pos[0]=856 $pos[1]=963 IsColorAtPos=False --- $vatPos=4 = 100 $pos[0]=743 $pos[1]=963 IsColorAtPos=True --- ********* Weird Output - see vat 1 and vat 2 ********** $vatPos=0 = 99 $pos[0]=1236 $pos[1]=963 IsColorAtPos=True --- $vatPos=1 = 100 $pos[0]=1114 $pos[1]=963 IsColorAtPos=False --- $vatPos=2 = 99 $pos[0]=990 $pos[1]=963 IsColorAtPos=True --- $vatPos=3 = 88 $pos[0]=856 $pos[1]=963 IsColorAtPos=False --- $vatPos=4 = 100 $pos[0]=743 $pos[1]=963 IsColorAtPos=True ---