Jump to content
Sign in to follow this  
Woosh

Works on XP, but not on Vista

Recommended Posts

Woosh

I don't really have much knoweledge about autoit, and this is my first script with gui. It works fine on my desktop computer with Windows XP SP3, but it doesn't work at all with windows Vista on my laptop.

Here is the source code: http://ampaste.net/m6492875b

The script is supposed to wait, until an image appear on a certain part of the screen, then click on it.

I have checked the script , and apparently, on Vista this statement always returns false: if PixelGetColor ($i , $j) = 6184542.

I am sure that 6184542 is a correct value, so this shouldn't be a problem.

Could someone please tell me what am I doing wrong?

Share this post


Link to post
Share on other sites
Vicate

I, too, have an issue with a program working flawlessly on XP, but not Vista.

Coincidentally, the bulk of my program consists of the PixelGetColor function.

Since I am not the only one experiencing a problem with this, I think it would be worth investing some

time into seeing why the PixelGetColor function doesn't work on Vista.

Below is the code to my program. Again, it works just fine on XP, but I get nothing on Vista.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("TrayIconHide", 1)
$dll = DllOpen("user32.dll")
$status = ''

#Region ###
$Form1_1 = GUICreate("Drumset", 116, 212, 448, 181)
GUISetFont(8, 400, 0, "Arial")
GUISetBkColor(0xFFFFFF)
$Group1 = GUICtrlCreateGroup("Player", 8, 144, 97, 39)
GUICtrlSetColor(-1, 0xC0C0C0)
$On = GUICtrlCreateLabel(" † †On", 14, 160, 41, 15, $WS_GROUP)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-2, 0x000000)
$Off = GUICtrlCreateLabel(" † †Off", 57, 160, 41, 15, $WS_GROUP)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$noplaying = GUICtrlCreatePic("Data\img.gif", 8, 8, 98, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Info = GUICtrlCreateLabel(" † †Info", 36, 188, 41, 15, $WS_GROUP)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### 

Func _z() ;BASS1
    $z = PixelGetColor(198, 54)
        Select
            Case $z = 0x000000
                send("{z down}")
                    Case $z <> 0x000000 And _IsPressed("5A", $dll)
                send("{z up}")
        EndSelect
    EndFunc
    
Func _s() ;BASS2
    $s = PixelGetColor(207, 54)
        Select
            Case $s = 0x000000
                send("{s down}")
                    Case $s <> 0x000000 And _IsPressed("53", $dll)
                send("{s up}")
        EndSelect
    EndFunc
    
Func _x() ;LOWSNARE1
    $x = PixelGetColor(225, 56)
        Select
            Case $x = 0x000000
                send("{x down}")
                    Case $x <> 0x000000 And _IsPressed("58", $dll)
                send("{x up}")
        EndSelect
    EndFunc

Func _d() ;LOWSNARE2
    $d = PixelGetColor(225, 56)
        Select
            Case $d = 0x000000
                send("{d down}")
                    Case $d <> 0x000000 And _IsPressed("44", $dll)
                send("{d up}")
        EndSelect
    EndFunc
    
Func _c() ;SNARE1
    $c = PixelGetColor(216, 54)
        Select
            Case $c = 0x000000
                send("{c down}")
                    Case $c <> 0x000000 And _IsPressed("43", $dll)
                send("{c up}")
        EndSelect
    EndFunc
    
Func _b() ;RIMSHOT1
    $b = PixelGetColor(184, 40)
        Select
            Case $b = 0x000000
                send("{b down}")
                    Case $b <> 0x000000 And _IsPressed("42", $dll)
                send("{b up}")
        EndSelect
    EndFunc

Func _bb() ;RIMSHOT1
    $bb = PixelGetColor(189, 55)
        Select
            Case $bb = 0x000000
                send("{b down}")
                    Case $bb <> 0x000000 And _IsPressed("42", $dll)
                send("{b up}")
        EndSelect
    EndFunc
    
Func _n() ;RIMSHOT2
    $n = PixelGetColor(179, 54)
        Select
            Case $n = 0x000000
                send("{n down}")
                    Case $n <> 0x000000 And _IsPressed("4E", $dll)
                send("{n up}")
        EndSelect
    EndFunc

Func _nb() ;RIMSHOT2
    $nb = PixelGetColor(210, 40)
        Select
            Case $nb = 0x000000
                send("{n down}")
                    Case $nb <> 0x000000 And _IsPressed("4E", $dll)
                send("{n up}")
        EndSelect
    EndFunc
    
Func _g() ;HIHATO1
    $g = PixelGetColor(238, 39)
        Select
            Case $g = 0x000000
                send("{g down}")
                    Case $g <> 0x000000 And _IsPressed("47", $dll)
                send("{g up}")
        EndSelect
    EndFunc
    
Func _h() ;HIHATCL2
    $h = PixelGetColor(247, 39)
        Select
            Case $h = 0x000000
                send("{h down}")
                    Case $h <> 0x000000 And _IsPressed("48", $dll)
                send("{h up}")
        EndSelect
    EndFunc

Func _j() ;HIHATOP1
    $j = PixelGetColor(256, 40)
        Select
            Case $j = 0x000000
                send("{j down}")
                    Case $j <> 0x000000 And _IsPressed("4A", $dll)
                send("{j up}")
        EndSelect
EndFunc

Func _m() ;HIHATOP2
    $m = PixelGetColor(324, 54)
        Select
            Case $m = 0x000000
                send("{m down}")
                    Case $m <> 0x000000 And _IsPressed("4D", $dll)
                send("{m up}")
        EndSelect
    EndFunc

Func _2() ;CLAP
    $2 = PixelGetColor(163, 52)
        Select
            Case $2 = 0x000000
                send("{2 down}")
                    Case $2 <> 0x000000 And _IsPressed("32", $dll)
                send("{2 up}")
        EndSelect
    EndFunc

Func _2b() ;CLAP
    $2b = PixelGetColor(163, 52)
        Select
            Case $2b = 0x000000
                send("{2 down}")
                    Case $2b <> 0x000000 And _IsPressed("32", $dll)
                send("{2 up}")
        EndSelect
EndFunc

Func _2c() ;CLAP
    $2c = PixelGetColor(221, 39)
        Select
            Case $2c = 0x000000
                send("{2 down}")
                    Case $2c <> 0x000000 And _IsPressed("32", $dll)
                send("{2 up}")
        EndSelect
EndFunc

Func _3() ;CRASH
    $3 = PixelGetColor(273, 39)
        Select
            Case $3 = 0x000000
                send("{3 down}")
                    Case $3 <> 0x000000 And _IsPressed("33", $dll)
                send("{3 up}")
        EndSelect
    EndFunc
    
Func _3b() ;CRASH
    $3b = PixelGetColor(305, 55)
        Select
            Case $3b = 0x000000
                send("{3 down}")
                    Case $3b <> 0x000000 And _IsPressed("33", $dll)
                send("{3 up}")
        EndSelect
EndFunc

Func _w() ;CYMBAL2
    $w = PixelGetColor(207, 54)
        Select
            Case $w = 0x000000
                send("{w down}")
                    Case $w <> 0x000000 And _IsPressed("57", $dll)
                send("{w up}")
        EndSelect
EndFunc

Func _e() ;RIDE1
    $e = PixelGetColor(297, 54)
        Select
            Case $e = 0x000000
                send("{e down}")
                    Case $e <> 0x000000 And _IsPressed("45", $dll)
                send("{e up}")
        EndSelect
EndFunc

Func _p() ;RIDE2
    $p = PixelGetColor(284, 41)
        Select
            Case $p = 0x000000
                send("{p down}")
                    Case $p <> 0x000000 And _IsPressed("50", $dll)
                send("{p up}")
        EndSelect
EndFunc

Func _5() ;LOWTOM1
    $5 = PixelGetColor(234, 54)
        Select
            Case $5 = 0x000000
                send("{5 down}")
                    Case $5 <> 0x000000 And _IsPressed("35", $dll)
                send("{5 up}")
        EndSelect
EndFunc

Func _6() ;MEDTOM1
    $6 = PixelGetColor(242, 54)
        Select
            Case $6 = 0x000000
                send("{6 down}")
                    Case $6 <> 0x000000 And _IsPressed("36", $dll)
                send("{6 up}")
        EndSelect
EndFunc

Func _7() ;HIGHTOM1
    $7 = PixelGetColor(253, 54)
        Select
            Case $7 = 0x000000
                send("{7 down}")
                    Case $7 <> 0x000000 And _IsPressed("37", $dll)
                send("{7 up}")
        EndSelect
EndFunc

Func _7b() ;HIGHTOM1
    $7b = PixelGetColor(261, 54)
        Select
            Case $7b = 0x000000
                send("{7 down}")
                    Case $7b <> 0x000000 And _IsPressed("37", $dll)
                send("{7 up}")
        EndSelect
EndFunc

Func _u() ;CRASH
    $u = PixelGetColor(288, 54)
        Select
            Case $u = 0x000000
                send("{u down}")
                    Case $u <> 0x000000 And _IsPressed("55", $dll)
                send("{u up}")
        EndSelect
    EndFunc

Func _ub() ;CRASH
    $ub = PixelGetColor(314, 55)
        Select
            Case $ub = 0x000000
                send("{u down}")
                    Case $ub <> 0x000000 And _IsPressed("55", $dll)
                send("{u up}")
        EndSelect
EndFunc

Func _9() ;HIGHERTOM2
    $9 = PixelGetColor(270, 54)
        Select
            Case $9 = 0x000000
                send("{9 down}")
                    Case $9 <> 0x000000 And _IsPressed("39", $dll)
                send("{9 up}")
        EndSelect
EndFunc

Func _0() ;HIGHERTOM3
    $0 = PixelGetColor(278, 54)
        Select
            Case $0 = 0x000000
                send("{0 down}")
                    Case $0 <> 0x000000 And _IsPressed("30", $dll)
                send("{0 up}")
        EndSelect
EndFunc

Func _brkr() ;COWBELL
    $brkr = PixelGetColor(194, 40)
        Select
            Case $brkr = 0x000000
                send("{] down}")
                    Case $brkr <> 0x000000 And _IsPressed("DD", $dll)
                send("{] up}")
        EndSelect
    EndFunc
    
Func _brkrb() ;COWBELL
    $brkrb = PixelGetColor(310, 41)
        Select
            Case $brkrb = 0x000000
                send("{] down}")
                    Case $brkrb <> 0x000000 And _IsPressed("DD", $dll)
                send("{] up}")
        EndSelect
EndFunc

Func _equal() ;TAMBORINE
    $equal = PixelGetColor(300, 41)
        Select
            Case $equal = 0x000000
                send("{= down}")
                    Case $equal <> 0x000000 And _IsPressed("BB", $dll)
                send("{= up}")
        EndSelect
    EndFunc

Func _equalb() ;TAMBORINE
    $equalb = PixelGetColor(320, 39)
        Select
            Case $equalb = 0x000000
                send("{= down}")
                    Case $equalb <> 0x000000 And _IsPressed("BB", $dll)
                send("{= up}")
        EndSelect
EndFunc



While 1
    $nMsg = GUIGetMsg()
        If $nMsg = $GUI_EVENT_CLOSE Then
            Exit
        EndIf

        If $nMsg = $On or _isPressed("21", $dll) Then
            GUICtrlSetBkColor($On, 0xFFAD08)
            GUICtrlSetBkColor($Off, 0x000000)
            $Status = 'ON'
        EndIf

        If $nMsg = $Off or _isPressed("22", $dll) Then
            GUICtrlSetBkColor($On, 0x000000)
            GUICtrlSetBkColor($Off, 0xFFAD08)
            $Status = 'OFF'
        EndIf

        If $nMsg = $Info Then
            MsgBox(0, "Info", "Text")
        EndIf
        
        If _isPressed("24", $dll) Then
            WinMove("[ACTIVE]", "", 0, 275, 50, 30)
        EndIf
        If _isPressed("23", $dll) Then
            WinMove("[ACTIVE]", "", 0, 275, 450, 450)
        EndIf
        
If $Status = 'ON' then
    _z()
    _s()
    _x()
    _d()
    _c()
    _b()
    _bb()
    _n()
    _nb()
    _g()
    _h()
    _j()
    _m()
    _2()
    _2b()
    _2c()
    _3()
    _3b()
    _w()
    _e()
    _p()
    _5()
    _6()
    _7()
    _7b()
    _u()
    _ub()
    _9()
    _0()
    _brkr()
    _brkrb()
    _equal()
Elseif $Status = 'OFF' then
endif
Wend

Thanks,

Vicate

Share this post


Link to post
Share on other sites
Vicate

Okay, shedding some light on the issue:

After some research, I have learned that when Vista is in the "Aero" theme, PixelGetColor works several times slower.

It is not an AutoIt issue, simply an error in Vista's ability to process the function, I guess.

A solution is to turn off the Aero theme:

The drawback is, well, your display doesn't look "pretty".

- Rightclick on Computer or "My Computer" and choose Properties.

- In the left side menu choose "Advanced System Settings".

- Click "Advanced"-Tab

- Under "Performance" click Settings.

- In "Visual Effects"-Tab is all the settings.

It appears "Enable Desktop Composition" causes a majority of the problem, so you could disable that and see some results.

Or you could be like me, go for the ultimate performance tweak and select "Adjust for best performance".

That makes it non-pretty but PixelGetColor works great that way.

Cheers,

-Vicate

Share this post


Link to post
Share on other sites
Ascend4nt

Instead of doing that manually, why not just do it for the program you are in. Look at these two API calls on MSDN:

DwmIsCompositionEnabled

DwmEnableComposition

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.