Jump to content

PixelGetColor fast on desktop but slow on any other window


Recommended Posts

I have a problem with PixelGetColor. Speed varies between desktop and any other window. Here is my test code: 

HotKeySet("{u}", "_1")

$aPID = ProcessList("AutoIT3.exe")
For $i = 1 To UBound($aPID, 1) - 1 Step 1
    ProcessSetPriority($aPID[$i][1] , 4)
Next


While 1

    Sleep(100)

WEnd


Func _1()

    $timer = TimerInit()
    $iAx = 200
    $iAy = 200
    $iBx = 400
    $iBy = 400
    $iWidth = $iBx - $iAx
    $iHeight = $iBy - $iAy
    Local $aColorMap[$iHeight][$iWidth]
    For $iRunWidth = 0 To $iWidth - 1
        For $iRunHeight = 0 To $iHeight - 1
            $sColor = Hex(PixelGetColor($iRunWidth + $iAx, $iRunHeight + $iAy))
            $aColorMap[$iRunHeight][$iRunWidth] = $sColor
        Next
    Next
    ConsoleWrite(TimerDiff($timer) & @CRLF)

EndFunc

If I run this function while I'm on my desktop it takes around ~280ms to complete. If I switch to my browser or Photoshop an run the script again it slows down to ~2800ms. So 10x slower then before. I have no clue why this happens. I tried to set the priority to "high" but this didn't speed up the program.

Note: Aero Design is not active. I'm using Windows 7 64Bit 

Edited by SturmGhost
Link to comment
Share on other sites

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...