Jump to content

'Application Compatibility' under Win7


KaFu
 Share

Recommended Posts

Hiho,

this post is just for your info and to not let my research go to waste :evil:... since last weekend I'm running Win7 64-bit. Up to now I'm quiet satisfied with look&feel and performance (not like Vista, which I uninstalled with two week ;)). New OS, new questions :idea:. My progam AMT utilizes MPlayer in the background, which automatically disables the Aero effect while running... on/off/on/off/on... not nice, so I searched for a way to disable Aero on programstart and came up with this fix:

; http://msdn.microsoft.com/en-us/library/aa969510%28VS.85%29.aspx
Global Const $DWM_EC_DISABLECOMPOSITION = 0
DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", $DWM_EC_DISABLECOMPOSITION)
sleep(5000)
exit

I found another method, checking the "Disable Desktop Composition" checkbox on the Compatibility tab of the file properties, which will also disable Aero on program start. Before doing any further research I asked Jos if it would be possible to implemnt something like this into the AutoIt3Wrapper...

#AutoIt3Wrapper_Compatibility_Disable_desktop_composition = ;(Y/N) Disable Aero on Vista and Win7. Default=N

Guess his answer... what is being done there :evil:? How can the properties be set?

So I did some further reseach and came up with two solutions. A User context specific method by changing a registy key

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

is mentioned here

http://www.experts-exchange.com/Programming/Installation/InstallShield/Q_23365314.html

In that thread there's also an explanation of how to set the properties machine wide. It's not a file property as such but an entry in an OS database:

"Using ACT by either adding a custom database or using the system databse (WINDOWS\AppPatch\sysmain.sdb) still applies the fixes, but does it system wide, not just in the user registry."

So doing it while installing requiers the "Microsoft Application Compatibility Toolkit" located here

http://www.microsoft.com/downloads/details.aspx?FamilyID=24da89e9-b581-47b0-b45e-492dd6da2971&displaylang=en

to create an executable specifc .sdb file which needs to be merged to the system database during install by something like this

sdbinst.exe -q maintsmart2000.sdb

So sadly it seems to be no job for the AutoIt3Wrapper...

Best Regards

Edit:

Here's an example of setting compatibility mode via the registy in the user context...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=compatibility_test.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.6.1
    Author:         KaFu

    Script Function:
    Setting executable compatibility mode via Regwrite()

    Possible values on Win7:
        VISTASP2|VISTASP1|VISTARTM|WINSRV08SP1|WINSRV03SP1|WINXPSP3|WINXPSP2|WIN2000|NT4SP5|WIN98|WIN95

#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>

If @Compiled Then
    If Not RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptFullPath) Then
        GUICreate("Select compatibility mode", 270, 40)
        $c_compatibility_mode_combo = GUICtrlCreateCombo("VISTASP2", 30, 10, 110, 20)
        GUICtrlSetData(-1, "VISTASP1|VISTARTM|WINSRV08SP1|WINSRV03SP1|WINXPSP3|WINXPSP2|WIN2000|NT4SP5|WIN98|WIN95", "VISTASP2")
        $c_compatibility_mode_button_start = GUICtrlCreateButton("Start", 150, 10, 90, 20)
        GUISetState(@SW_SHOW)
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    GUIDelete()
                    Exit
                Case $c_compatibility_mode_button_start
                    ExitLoop
            EndSwitch
        WEnd
        If Not RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptFullPath, "REG_SZ", GUICtrlRead($c_compatibility_mode_combo)) Then
            MsgBox(16 + 262144, "Error", "Could not access the registry to write compatibility mode flag...")
            GUIDelete()
            Exit
        Else
            GUIDelete()
            Run(@ScriptFullPath)
            Exit
        EndIf
    EndIf
Else
    MsgBox(16 + 262144, "Error", "Setting compatibility via registy only works for compiled scripts...")
    Exit
EndIf

; Your code below

GUICreate("My GUI", 400, 30)
GUICtrlCreateLabel("Running in compatibility mode for @OSVersion: " & @OSVersion, 10, 10, 380)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

; Your code above

If @Compiled Then RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptFullPath)
Edited by KaFu
Link to comment
Share on other sites

  • 5 months later...

i still havent resloved it tryed all the codes above but my app will only work on vista, win7 on xp i just hear the faulty sound in the background and app exits. Setting manualy either disalbe themse or win compiability to win 95 it opens up just fine.

Link to comment
Share on other sites

  • 3 months later...

I think that your research can also be very useful for the people having problems with Pixelgetcolor func in Vista with aero on.

It may be great to do at the beggining of the program something like:

If @OSVersion = "WIN_7" OR "WIN_VISTA" Then

Global Const $DWM_EC_DISABLECOMPOSITION = 0
DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", $DWM_EC_DISABLECOMPOSITION)
Sleep (500)
Endif

Doesn't have any computer with windows 7 or Vista, but it would be great if someone can test that it increase performance.

Here is just a motion capture script with 49 Pixelgetcolor working at time:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START + 100
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW
$WM_CAP_ABORT = $WM_CAP_START + 69
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30
$WM_CAP_END = $WM_CAP_UNICODE_END
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65
$WM_CAP_GET_STATUS = $WM_CAP_START + 54
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82
$WM_CAP_SEQUENCE = $WM_CAP_START + 62
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52
$WM_CAP_SET_SCALE = $WM_CAP_START + 53
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70
$WM_CAP_STOP = $WM_CAP_START + 68
Opt("PixelCoordMode", 2)

Global $range = 2400000; Range  / Sensivity( Default 2400000)

Global $resolucionvertical = 640
Global $resolucionhorizontal = $resolucionvertical * 1.32
Global $posicionpantallaleft= 140
Global $posicionpantallatop= 180
Global $coordenadasX = $resolucionhorizontal / 11
Global $coordenadasY = $resolucionvertical / 11

Global $var0 = PixelGetColor($coordenadasX * 3, $coordenadasY * 3)
Global $var1 = PixelGetColor($coordenadasX * 3, $coordenadasY * 4)
Global $var2 = PixelGetColor($coordenadasX * 3, $coordenadasY * 5)
Global $var3 = PixelGetColor($coordenadasX * 3, $coordenadasY * 6)
Global $var4 = PixelGetColor($coordenadasX * 3, $coordenadasY * 7)
Global $var5 = PixelGetColor($coordenadasX * 3, $coordenadasY * 8)
Global $var6 = PixelGetColor($coordenadasX * 3, $coordenadasY * 9)
Global $var7 = PixelGetColor($coordenadasX * 4, $coordenadasY * 3)
Global $var8 = PixelGetColor($coordenadasX * 4, $coordenadasY * 4)
Global $var9 = PixelGetColor($coordenadasX * 4, $coordenadasY * 5)
Global $var10 = PixelGetColor($coordenadasX * 4, $coordenadasY * 6)
Global $var11 = PixelGetColor($coordenadasX * 4, $coordenadasY * 7)
Global $var12 = PixelGetColor($coordenadasX * 4, $coordenadasY * 8)
Global $var13 = PixelGetColor($coordenadasX * 4, $coordenadasY * 9)
Global $var14 = PixelGetColor($coordenadasX * 5, $coordenadasY * 3)
Global $var15 = PixelGetColor($coordenadasX * 5, $coordenadasY * 4)
Global $var16 = PixelGetColor($coordenadasX * 5, $coordenadasY * 5)
Global $var17 = PixelGetColor($coordenadasX * 5, $coordenadasY * 6)
Global $var18 = PixelGetColor($coordenadasX * 5, $coordenadasY * 7)
Global $var19 = PixelGetColor($coordenadasX * 5, $coordenadasY * 8)
Global $var20 = PixelGetColor($coordenadasX * 5, $coordenadasY * 9)
Global $var21 = PixelGetColor($coordenadasX * 6, $coordenadasY * 3)
Global $var22 = PixelGetColor($coordenadasX * 6, $coordenadasY * 4)
Global $var23 = PixelGetColor($coordenadasX * 6, $coordenadasY * 5)
Global $var24 = PixelGetColor($coordenadasX * 6, $coordenadasY * 6)
Global $var25 = PixelGetColor($coordenadasX * 6, $coordenadasY * 7)
Global $var26 = PixelGetColor($coordenadasX * 6, $coordenadasY * 8)
Global $var27 = PixelGetColor($coordenadasX * 6, $coordenadasY * 9)
Global $var28 = PixelGetColor($coordenadasX * 7, $coordenadasY * 3)
Global $var29 = PixelGetColor($coordenadasX * 7, $coordenadasY * 4)
Global $var30 = PixelGetColor($coordenadasX * 7, $coordenadasY * 5)
Global $var31 = PixelGetColor($coordenadasX * 7, $coordenadasY * 6)
Global $var32 = PixelGetColor($coordenadasX * 7, $coordenadasY * 7)
Global $var33 = PixelGetColor($coordenadasX * 7, $coordenadasY * 8)
Global $var34 = PixelGetColor($coordenadasX * 7, $coordenadasY * 9)
Global $var35 = PixelGetColor($coordenadasX * 8, $coordenadasY * 3)
Global $var36 = PixelGetColor($coordenadasX * 8, $coordenadasY * 4)
Global $var37 = PixelGetColor($coordenadasX * 8, $coordenadasY * 5)
Global $var38 = PixelGetColor($coordenadasX * 8, $coordenadasY * 6)
Global $var39 = PixelGetColor($coordenadasX * 8, $coordenadasY * 7)
Global $var40 = PixelGetColor($coordenadasX * 8, $coordenadasY * 8)
Global $var41 = PixelGetColor($coordenadasX * 8, $coordenadasY * 9)
Global $var42 = PixelGetColor($coordenadasX * 9, $coordenadasY * 3)
Global $var43 = PixelGetColor($coordenadasX * 9, $coordenadasY * 4)
Global $var44 = PixelGetColor($coordenadasX * 9, $coordenadasY * 5)
Global $var45 = PixelGetColor($coordenadasX * 9, $coordenadasY * 6)
Global $var46 = PixelGetColor($coordenadasX * 9, $coordenadasY * 7)
Global $var47 = PixelGetColor($coordenadasX * 9, $coordenadasY * 8)
Global $var48 = PixelGetColor($coordenadasX * 9, $coordenadasY * 9)

Global $firstvar0 = $var0 + $range
Global $lastvar0 = $var0 - $range
Global $firstvar1 = $var1 + $range
Global $lastvar1 = $var1 - $range
Global $firstvar2 = $var2 + $range
Global $lastvar2 = $var2 - $range
Global $firstvar3 = $var3 + $range
Global $lastvar3 = $var3 - $range
Global $firstvar4 = $var4 + $range
Global $lastvar4 = $var4 - $range
Global $firstvar5 = $var5 + $range
Global $lastvar5 = $var5 - $range
Global $firstvar6 = $var6 + $range
Global $lastvar6 = $var6 - $range
Global $firstvar7 = $var7 + $range
Global $lastvar7 = $var7 - $range
Global $firstvar8 = $var8 + $range
Global $lastvar8 = $var8 - $range
Global $firstvar9 = $var9 + $range
Global $lastvar9 = $var9 - $range
Global $firstvar10 = $var10 + $range
Global $lastvar10 = $var10 - $range
Global $firstvar11 = $var11 + $range
Global $lastvar11 = $var11 - $range
Global $firstvar12 = $var12 + $range
Global $lastvar12 = $var12 - $range
Global $firstvar13 = $var13 + $range
Global $lastvar13 = $var13 - $range
Global $firstvar14 = $var14 + $range
Global $lastvar14 = $var14 - $range
Global $firstvar15 = $var15 + $range
Global $lastvar15 = $var15 - $range
Global $firstvar16 = $var16 + $range
Global $lastvar16 = $var16 - $range
Global $firstvar17 = $var17 + $range
Global $lastvar17 = $var17 - $range
Global $firstvar18 = $var18 + $range
Global $lastvar18 = $var18 - $range
Global $firstvar19 = $var19 + $range
Global $lastvar19 = $var19 - $range
Global $firstvar20 = $var20 + $range
Global $lastvar20 = $var20 - $range
Global $firstvar21 = $var21 + $range
Global $lastvar21 = $var21 - $range
Global $firstvar22 = $var22 + $range
Global $lastvar22 = $var22 - $range
Global $firstvar23 = $var23 + $range
Global $lastvar23 = $var23 - $range
Global $firstvar24 = $var24 + $range
Global $lastvar24 = $var24 - $range
Global $firstvar25 = $var25 + $range
Global $lastvar25 = $var25 - $range
Global $firstvar26 = $var26 + $range
Global $lastvar26 = $var26 - $range
Global $firstvar27 = $var27 + $range
Global $lastvar27 = $var27 - $range
Global $firstvar28 = $var28 + $range
Global $lastvar28 = $var28 - $range
Global $firstvar29 = $var29 + $range
Global $lastvar29 = $var29 - $range
Global $firstvar30 = $var30 + $range
Global $lastvar30 = $var30 - $range
Global $firstvar31 = $var31 + $range
Global $lastvar31 = $var31 - $range
Global $firstvar32 = $var32 + $range
Global $lastvar32 = $var32 - $range
Global $firstvar33 = $var33 + $range
Global $lastvar33 = $var33 - $range
Global $firstvar34 = $var34 + $range
Global $lastvar34 = $var34 - $range
Global $firstvar35 = $var35 + $range
Global $lastvar35 = $var35 - $range
Global $firstvar36 = $var36 + $range
Global $lastvar36 = $var36 - $range
Global $firstvar37 = $var37 + $range
Global $lastvar37 = $var37 - $range
Global $firstvar38 = $var38 + $range
Global $lastvar38 = $var38 - $range
Global $firstvar39 = $var39 + $range
Global $lastvar39 = $var39 - $range
Global $firstvar40 = $var40 + $range
Global $lastvar40 = $var40 - $range
Global $firstvar41 = $var41 + $range
Global $lastvar41 = $var41 - $range
Global $firstvar42 = $var42 + $range
Global $lastvar42 = $var42 - $range
Global $firstvar43 = $var43 + $range
Global $lastvar43 = $var43 - $range
Global $firstvar44 = $var44 + $range
Global $lastvar44 = $var44 - $range
Global $firstvar45 = $var45 + $range
Global $lastvar45 = $var45 - $range
Global $firstvar46 = $var46 + $range
Global $lastvar46 = $var46 - $range
Global $firstvar47 = $var47 + $range
Global $lastvar47 = $var47 - $range
Global $firstvar48 = $var48 + $range
Global $lastvar48 = $var48 - $range




$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
$snapfile = @ScriptDir & "\scrshot.bmp"


$gui4 = GUICreate("Camera", $resolucionhorizontal, $resolucionvertical, $posicionpantallaleft, $posicionpantallatop)
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", 0, "int", 0, "int", $resolucionhorizontal, "int", $resolucionvertical, "hwnd", $gui4, "int", 1)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)


GUISetState(@SW_SHOW)
HotKeySet("{INSERT}", "SnapShot"); Press 'Insert' to make a SnapShot !


While 1
    $msg = GUIGetMsg()
    UpdateActiveColors()
    CalculateRange()
    CheckForChange()
    If $msg = $GUI_EVENT_CLOSE Then
        ;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
        ;DllClose($avi)
        DllClose($user)
        Exit
    EndIf
WEnd

Func SnapShot()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile)
EndFunc   ;==>SnapShot


Func UpdateActiveColors()

Global $var0 = PixelGetColor($coordenadasX * 3, $coordenadasY * 3)
Global $var1 = PixelGetColor($coordenadasX * 3, $coordenadasY * 4)
Global $var2 = PixelGetColor($coordenadasX * 3, $coordenadasY * 5)
Global $var3 = PixelGetColor($coordenadasX * 3, $coordenadasY * 6)
Global $var4 = PixelGetColor($coordenadasX * 3, $coordenadasY * 7)
Global $var5 = PixelGetColor($coordenadasX * 3, $coordenadasY * 8)
Global $var6 = PixelGetColor($coordenadasX * 3, $coordenadasY * 9)
Global $var7 = PixelGetColor($coordenadasX * 4, $coordenadasY * 3)
Global $var8 = PixelGetColor($coordenadasX * 4, $coordenadasY * 4)
Global $var9 = PixelGetColor($coordenadasX * 4, $coordenadasY * 5)
Global $var10 = PixelGetColor($coordenadasX * 4, $coordenadasY * 6)
Global $var11 = PixelGetColor($coordenadasX * 4, $coordenadasY * 7)
Global $var12 = PixelGetColor($coordenadasX * 4, $coordenadasY * 8)
Global $var13 = PixelGetColor($coordenadasX * 4, $coordenadasY * 9)
Global $var14 = PixelGetColor($coordenadasX * 5, $coordenadasY * 3)
Global $var15 = PixelGetColor($coordenadasX * 5, $coordenadasY * 4)
Global $var16 = PixelGetColor($coordenadasX * 5, $coordenadasY * 5)
Global $var17 = PixelGetColor($coordenadasX * 5, $coordenadasY * 6)
Global $var18 = PixelGetColor($coordenadasX * 5, $coordenadasY * 7)
Global $var19 = PixelGetColor($coordenadasX * 5, $coordenadasY * 8)
Global $var20 = PixelGetColor($coordenadasX * 5, $coordenadasY * 9)
Global $var21 = PixelGetColor($coordenadasX * 6, $coordenadasY * 3)
Global $var22 = PixelGetColor($coordenadasX * 6, $coordenadasY * 4)
Global $var23 = PixelGetColor($coordenadasX * 6, $coordenadasY * 5)
Global $var24 = PixelGetColor($coordenadasX * 6, $coordenadasY * 6)
Global $var25 = PixelGetColor($coordenadasX * 6, $coordenadasY * 7)
Global $var26 = PixelGetColor($coordenadasX * 6, $coordenadasY * 8)
Global $var27 = PixelGetColor($coordenadasX * 6, $coordenadasY * 9)
Global $var28 = PixelGetColor($coordenadasX * 7, $coordenadasY * 3)
Global $var29 = PixelGetColor($coordenadasX * 7, $coordenadasY * 4)
Global $var30 = PixelGetColor($coordenadasX * 7, $coordenadasY * 5)
Global $var31 = PixelGetColor($coordenadasX * 7, $coordenadasY * 6)
Global $var32 = PixelGetColor($coordenadasX * 7, $coordenadasY * 7)
Global $var33 = PixelGetColor($coordenadasX * 7, $coordenadasY * 8)
Global $var34 = PixelGetColor($coordenadasX * 7, $coordenadasY * 9)
Global $var35 = PixelGetColor($coordenadasX * 8, $coordenadasY * 3)
Global $var36 = PixelGetColor($coordenadasX * 8, $coordenadasY * 4)
Global $var37 = PixelGetColor($coordenadasX * 8, $coordenadasY * 5)
Global $var38 = PixelGetColor($coordenadasX * 8, $coordenadasY * 6)
Global $var39 = PixelGetColor($coordenadasX * 8, $coordenadasY * 7)
Global $var40 = PixelGetColor($coordenadasX * 8, $coordenadasY * 8)
Global $var41 = PixelGetColor($coordenadasX * 8, $coordenadasY * 9)
Global $var42 = PixelGetColor($coordenadasX * 9, $coordenadasY * 3)
Global $var43 = PixelGetColor($coordenadasX * 9, $coordenadasY * 4)
Global $var44 = PixelGetColor($coordenadasX * 9, $coordenadasY * 5)
Global $var45 = PixelGetColor($coordenadasX * 9, $coordenadasY * 6)
Global $var46 = PixelGetColor($coordenadasX * 9, $coordenadasY * 7)
Global $var47 = PixelGetColor($coordenadasX * 9, $coordenadasY * 8)
Global $var48 = PixelGetColor($coordenadasX * 9, $coordenadasY * 9)

EndFunc   ;==>UpdateActiveColors


Func CalculateRange()
    Global $firstvar0 = $var0 + $range
Global $lastvar0 = $var0 - $range
Global $firstvar1 = $var1 + $range
Global $lastvar1 = $var1 - $range
Global $firstvar2 = $var2 + $range
Global $lastvar2 = $var2 - $range
Global $firstvar3 = $var3 + $range
Global $lastvar3 = $var3 - $range
Global $firstvar4 = $var4 + $range
Global $lastvar4 = $var4 - $range
Global $firstvar5 = $var5 + $range
Global $lastvar5 = $var5 - $range
Global $firstvar6 = $var6 + $range
Global $lastvar6 = $var6 - $range
Global $firstvar7 = $var7 + $range
Global $lastvar7 = $var7 - $range
Global $firstvar8 = $var8 + $range
Global $lastvar8 = $var8 - $range
Global $firstvar9 = $var9 + $range
Global $lastvar9 = $var9 - $range
Global $firstvar10 = $var10 + $range
Global $lastvar10 = $var10 - $range
Global $firstvar11 = $var11 + $range
Global $lastvar11 = $var11 - $range
Global $firstvar12 = $var12 + $range
Global $lastvar12 = $var12 - $range
Global $firstvar13 = $var13 + $range
Global $lastvar13 = $var13 - $range
Global $firstvar14 = $var14 + $range
Global $lastvar14 = $var14 - $range
Global $firstvar15 = $var15 + $range
Global $lastvar15 = $var15 - $range
Global $firstvar16 = $var16 + $range
Global $lastvar16 = $var16 - $range
Global $firstvar17 = $var17 + $range
Global $lastvar17 = $var17 - $range
Global $firstvar18 = $var18 + $range
Global $lastvar18 = $var18 - $range
Global $firstvar19 = $var19 + $range
Global $lastvar19 = $var19 - $range
Global $firstvar20 = $var20 + $range
Global $lastvar20 = $var20 - $range
Global $firstvar21 = $var21 + $range
Global $lastvar21 = $var21 - $range
Global $firstvar22 = $var22 + $range
Global $lastvar22 = $var22 - $range
Global $firstvar23 = $var23 + $range
Global $lastvar23 = $var23 - $range
Global $firstvar24 = $var24 + $range
Global $lastvar24 = $var24 - $range
Global $firstvar25 = $var25 + $range
Global $lastvar25 = $var25 - $range
Global $firstvar26 = $var26 + $range
Global $lastvar26 = $var26 - $range
Global $firstvar27 = $var27 + $range
Global $lastvar27 = $var27 - $range
Global $firstvar28 = $var28 + $range
Global $lastvar28 = $var28 - $range
Global $firstvar29 = $var29 + $range
Global $lastvar29 = $var29 - $range
Global $firstvar30 = $var30 + $range
Global $lastvar30 = $var30 - $range
Global $firstvar31 = $var31 + $range
Global $lastvar31 = $var31 - $range
Global $firstvar32 = $var32 + $range
Global $lastvar32 = $var32 - $range
Global $firstvar33 = $var33 + $range
Global $lastvar33 = $var33 - $range
Global $firstvar34 = $var34 + $range
Global $lastvar34 = $var34 - $range
Global $firstvar35 = $var35 + $range
Global $lastvar35 = $var35 - $range
Global $firstvar36 = $var36 + $range
Global $lastvar36 = $var36 - $range
Global $firstvar37 = $var37 + $range
Global $lastvar37 = $var37 - $range
Global $firstvar38 = $var38 + $range
Global $lastvar38 = $var38 - $range
Global $firstvar39 = $var39 + $range
Global $lastvar39 = $var39 - $range
Global $firstvar40 = $var40 + $range
Global $lastvar40 = $var40 - $range
Global $firstvar41 = $var41 + $range
Global $lastvar41 = $var41 - $range
Global $firstvar42 = $var42 + $range
Global $lastvar42 = $var42 - $range
Global $firstvar43 = $var43 + $range
Global $lastvar43 = $var43 - $range
Global $firstvar44 = $var44 + $range
Global $lastvar44 = $var44 - $range
Global $firstvar45 = $var45 + $range
Global $lastvar45 = $var45 - $range
Global $firstvar46 = $var46 + $range
Global $lastvar46 = $var46 - $range
Global $firstvar47 = $var47 + $range
Global $lastvar47 = $var47 - $range
Global $firstvar48 = $var48 + $range
Global $lastvar48 = $var48 - $range

EndFunc   ;==>CalculateRange

Func CheckForChange()
    if ($var0 < $firstvar0 And $var0 > $lastvar0) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var1 < $firstvar1 And $var1 > $lastvar1) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf


    if ($var2 < $firstvar2 And $var2 > $lastvar2) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var3 < $firstvar3 And $var3 > $lastvar3) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var4 < $firstvar4 And $var4 > $lastvar4) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var5 < $firstvar5 And $var5 > $lastvar5) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var6 < $firstvar6 And $var6 > $lastvar6) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var7 < $firstvar7 And $var7 > $lastvar7) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var8 < $firstvar8 And $var8 > $lastvar8) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var9 < $firstvar9 And $var9 > $lastvar9) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var10 < $firstvar10 And $var10 > $lastvar10) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var11 < $firstvar11 And $var11 > $lastvar11) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var12 < $firstvar12 And $var12 > $lastvar12) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var13 < $firstvar13 And $var13 > $lastvar13) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

if ($var14 < $firstvar14 And $var14 > $lastvar14) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var15 < $firstvar15 And $var15 > $lastvar15) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

        if ($var16 < $firstvar16 And $var16 > $lastvar16) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var17 < $firstvar17 And $var17 > $lastvar17) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var18 < $firstvar18 And $var18 > $lastvar18) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

if ($var19 < $firstvar19 And $var19 > $lastvar19) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var20 < $firstvar20 And $var20 > $lastvar20) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var21 < $firstvar21 And $var21 > $lastvar21) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var22 < $firstvar22 And $var22 > $lastvar22) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var23 < $firstvar23 And $var23 > $lastvar23) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

        if ($var24 < $firstvar24 And $var24 > $lastvar24) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var25 < $firstvar25 And $var25 > $lastvar25) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var26 < $firstvar26 And $var26 > $lastvar26) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var27 < $firstvar27 And $var27 > $lastvar27) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var28 < $firstvar28 And $var28 > $lastvar28) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var29 < $firstvar29 And $var29 > $lastvar29) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var30 < $firstvar30 And $var30 > $lastvar30) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var31 < $firstvar31 And $var31 > $lastvar31) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var32 < $firstvar32 And $var32 > $lastvar32) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var33 < $firstvar33 And $var33 > $lastvar33) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

        if ($var34 < $firstvar34 And $var34 > $lastvar34) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var35 < $firstvar35 And $var35 > $lastvar35) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var36 < $firstvar36 And $var36 > $lastvar36) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var37 < $firstvar37 And $var37 > $lastvar37) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var38 < $firstvar38 And $var38 > $lastvar38) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var39 < $firstvar39 And $var39 > $lastvar39) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf
    if ($var40 < $firstvar40 And $var40 > $lastvar40) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var41 < $firstvar41 And $var41 > $lastvar41) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var42 < $firstvar42 And $var42 > $lastvar42) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var43 < $firstvar43 And $var43 > $lastvar43) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

        if ($var44 < $firstvar44 And $var44 > $lastvar44) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var45 < $firstvar45 And $var45 > $lastvar45) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var46 < $firstvar46 And $var46 > $lastvar46) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var47 < $firstvar47 And $var47 > $lastvar47) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

    if ($var48 < $firstvar48 And $var48 > $lastvar48) Then
        UpdateActiveColors()
    Else
        Beep(100, 100)
        UpdateActiveColors()
        CalculateRange()
    EndIf

EndFunc   ;==>CheckForChange

Greets from Barcelona

Link to comment
Share on other sites

I know its a bit late, but good catch KaFu.

I've found the following additional settings can be added in the Registry 'Layers' key value for each program, as long as they are separated by spaces (and the O/S value seems to always come first):

256COLOR

640X480

DISABLETHEMES

DISABLEDWM

HIGHDPIAWARE

RUNASADMIN

ELEVATECREATEPROCESS

DISABLENXSHOWUI

The second-to-last one fixes problems with 'CreateProcess'. This is something that prevents apps requiring elevation UAC prompts from starting under UAC environments (use Run('regedit.exe') as opposed to ShellExecute('regedit.exe'), and you will see the latter one is the only one to work in Vista/2008+ O/S's with UAC active)

The last one, which doesn't appear on the Compatibility tab, disables DEP protection, which *may* help certain programs work, though its very risky of course since that's one thing malware could take advantage of.

I see a few extra ones -> here <- actually that may or may not work in the registry as they are listed. (for example, '256 Color' shouldn't have any spaces in the Registry setting, but might work in the compatibility modes database).

(Sorry if anything is repeated - I don't have access to the experts-exchange forums)

*edit: added ELEVATECREATEPROCESS (see 'Using the ElevateCreateProcess Fix' @ MSDN)

Edited by Ascend4nt
Link to comment
Share on other sites

  • 2 years later...

I had forgotten about this thread, but thought it should be documented that there is a way to work around Windows' tendency to elevate executables (which are not marked as "requireAdministrator") based on one of two situations:

  1. An application manfiest specifies 'highestAvailable', and the current user is in the admin account
  2. Windows heuristics determines the file to require elevation.  This happens for files that have 'setup' or 'install' in their executable name, as well as certain strings detected in the executable - whether it be known 'installer' strings (like "NSIS"), or other trigger strings found in File Descriptions or string resources..

 

There is an environment variable called __COMPAT_LAYER which can be used to force an application to run a certain way and to override Windows heuristics.  Simply setting this  to 'RunAsInvoker' will allow execution of other processes via 'Run' (or CreateProcess).

As a simple example of how this can be used, try running the below code with the 'EnvSet()' line commented out:

EnvSet("__COMPAT_LAYER", "RunAsInvoker")
Run("regedit.exe")

 

Without the EnvSet() command, Run silently fails.  The normal workaround is to use ShellExecute(), which will then provide a UAC prompt and elevate the process.  But we don't always want that behavior!  Especially since Windows heuristics can falsely assume that something needs elevation.

Information on this environment variable is available here:

HOW TO: Script Compatibility Layers in Windows XP (and above)

Note this also works in batch files, which I've been using as a workaround for false positives for a while. Set the environment variable like this:

set __COMPAT_LAYER=RunAsInvoker

(followed by a command to run)

In case anybody is still running XP as a primary O/S, the elevation part above doesn't apply to you (its only for Vista+ operating systems with UAC).

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...