Jump to content

PixelGetColor 20 times slower on Vista Aero ?


Recommended Posts

Hi !

This is my first post and i don't speak very good English.

I come from the french Forum, and this is my problem :

When I use the function "PixelGetColor" (who return the color of one pixel) on Windows XP, the function takes ~0,3 ms,

On windows Vista or Seven, the function takes ~20,3 MS for 1 Pixel ! When i disable the Aero theme and replace it with Windows Classique Theme

I get the same result as in XP. how can I do to get better results with Vista Aero ?

Sorry for my English

Posted Image

Thank you in advance, and thanks to Google translation

Link to comment
Share on other sites

Aero is that slow on GDI+ on certain functions, there is nothing you can do about it. Either tell whoever is gonna run your script to disable it manually or run this code to do it automatically while the script is running:

DllCall("dwmapi.dll", "uint", "DwmEnableComposition", "int", 0)

Edit: BTW it's not really Aero that's causing the slowliness, it's DWM. But whatever, usually both are activated.

Edited by AdmiralAlkex
Link to comment
Share on other sites

Thanks a lot >_<

But how can i know if the user have the "GDI +" enabled ?

I would do this :

If "Gdi Enabled" Then

Msgbox("omg, would you like to disable the GDI ?")

If Yes DllCall ( "dwmapi.dll", "uint", "DwmEnableComposition", "int", 0)

If No

Endif

Thanks

Link to comment
Share on other sites

Maybe like this?

(only tested very quickly)

#include <GUIConstantsEx.au3>

GUICreate(1024, 768)
GUISetState()

If _DwmIsEnabled() = True Then
    $Text = "By turning off DWM this script will be much much faster." & @CRLF & "Would you like me to turn off DWM for you?? (will be activated again when script end)"
    If MsgBox(4+32+262144, "It seems like you have DWM running.", $Text) = 6 Then _DwmEnable(False)
EndIf

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _DwmIsEnabled()
    If FileExists("dwmapi.dll") Then
        Local $Bool
        $aTemp = DllCall("dwmapi.dll", "uint", "DwmIsCompositionEnabled", "int*", $Bool)
        If $aTemp[1] = True Then
            Return 1
        Else
            Return SetError(1)
        EndIf
    Else
        Return SetError(2)
    EndIf
EndFunc

Func _DwmEnable($WhatToDo)
    DllCall("dwmapi.dll", "uint", "DwmEnableComposition", "int", $WhatToDo)
EndFunc
Link to comment
Share on other sites

I see the problem (I think). Does this work better?

#include <GUIConstantsEx.au3>

GUICreate(1024, 768)
GUISetState()

If _DwmIsEnabled() = True Then
    $Text = "By turning off DWM this script will be much much faster." & @CRLF & "Would you like me to turn off DWM for you?? (will be activated again when script end)"
    If MsgBox(4+32+262144, "It seems like you have DWM running.", $Text) = 6 Then _DwmEnable(False)
EndIf

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _DwmIsEnabled()
    If FileExists(@SystemDir & "\dwmapi.dll") Then
        $Receiver = DllStructCreate("int")
        $aTemp = DllCall("dwmapi.dll", "uint", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($Receiver, 1))

        $Receiver2 = DllStructCreate("int", $aTemp[1])
        If DllStructGetData($Receiver2, 1) = True Then
            Return 1
        Else
            Return SetError(1, 0, 0)
        EndIf
    Else
        Return SetError(2, 0, 0)
    EndIf
EndFunc

Func _DwmEnable($WhatToDo)
    DllCall("dwmapi.dll", "uint", "DwmEnableComposition", "int", $WhatToDo)
EndFunc
Link to comment
Share on other sites

  • 4 months later...

Hi, sorry for the date, but i have detected a problem, on Windows Seven its perfect, but on Windows Vista, The Aero theme turns off, and reactivates immediately. How do to for made like Seven ?

Thanks

The code should work, I'm not sure why that is happening.

Maybe you should choose another method to disable DWM. One of the easiest ways would be to right-click the exe-file for your script (or whatever you're botting), press Properties, go to the tab "Compatibility", and check the checkbox that says "Disable desktop composition". That will disable dwm while the process is running.

Link to comment
Share on other sites

  • 4 years later...

I see the problem (I think). Does this work better?

 

#include <GUIConstantsEx.au3>

GUICreate(1024, 768)
GUISetState()

If _DwmIsEnabled() = True Then
    $Text = "By turning off DWM this script will be much much faster." & @CRLF & "Would you like me to turn off DWM for you?? (will be activated again when script end)"
    If MsgBox(4+32+262144, "It seems like you have DWM running.", $Text) = 6 Then _DwmEnable(False)
EndIf

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _DwmIsEnabled()
    If FileExists(@SystemDir & "\dwmapi.dll") Then
        $Receiver = DllStructCreate("int")
        $aTemp = DllCall("dwmapi.dll", "uint", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($Receiver, 1))

        $Receiver2 = DllStructCreate("int", $aTemp[1])
        If DllStructGetData($Receiver2, 1) = True Then
            Return 1
        Else
            Return SetError(1, 0, 0)
        EndIf
    Else
        Return SetError(2, 0, 0)
    EndIf
EndFunc

Func _DwmEnable($WhatToDo)
    DllCall("dwmapi.dll", "uint", "DwmEnableComposition", "int", $WhatToDo)
EndFunc

 

That's works perfect for me, shuts down aero, but it left one question.

How can I make to stay on that state? I mean: If I switching off the DWM, it will switch itself back when the script ends. What can I do to keep in that state?

Thank You!

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...