Jump to content

how to get rid of flickering


Recommended Posts

I don't know what's the problem, I supposed to have 1 of the 4 colors showing if I move my cursor within 1 of the quadrants of the screen, it should shows only 1 color.

But now it seem to have memory, when cursor move between 2 quadrants, it has noise bands of the 2 colors, move among more quadrants, more color noise bands, and the noise bands stay longer as I move my mouse longer before it set at the right color I supposed. Eventually even if I move within 1 quadrant, it shows the color bands shown before.

anyone got ideas why and how to fix it.

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$mainwin = GUICreate("4corners", 200, 200, (@DesktopWidth-200)/2, (@DesktopHeight-200)/2)
$gh=GuiCtrlCreateGraphic(0, 0, 200,200,BitOr($SS_NOTIFY,$SS_BLACKFRAME ))
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked" )
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "mouseco")
WinSetOnTop ("4corners","",1)
GUISetState()

while 1
    Sleep(1000)
WEnd    
Func mouseco()
    $pos = MouseGetPos()
    Select
        Case $pos[0]< @DesktopWidth/2 And $pos[1]< @DesktopHeight/2
        GUICtrlSetGraphic($gh,$GUI_GR_RECT, 0,0, 200,200)
        GUICtrlSetGraphic($gh,$GUI_GR_COLOR, 0xffff00,0xffff00)
        Case $pos[0]< @DesktopWidth/2 And $pos[1]> @DesktopHeight/2
        GUICtrlSetGraphic($gh,$GUI_GR_RECT, 0,0, 200,200)
        GUICtrlSetGraphic($gh,$GUI_GR_COLOR, 0x00ff00,0x00ff00)
        Case $pos[0]> @DesktopWidth/2 And $pos[1]> @DesktopHeight/2
        GUICtrlSetGraphic($gh,$GUI_GR_RECT, 0,0, 200,200)
        GUICtrlSetGraphic($gh,$GUI_GR_COLOR, 0xff0000,0xff0000)
        Case $pos[0]> @DesktopWidth/2 And $pos[1]< @DesktopHeight/2
        GUICtrlSetGraphic($gh,$GUI_GR_RECT, 0,0, 200,200)
        GUICtrlSetGraphic($gh,$GUI_GR_COLOR, 0x0000ff,0x0000ff)
    EndSelect
    GUICtrlSetGraphic ($gh,$GUI_GR_REFRESH)
EndFunc 

Func CLOSEClicked()
    Exit
EndFunc
Link to comment
Share on other sites

try this:

Edit: updated

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$mainwin = GUICreate("4corners", 200, 200, (@DesktopWidth - 200) / 2, (@DesktopHeight - 200) / 2)
$gh = GUICtrlCreateGraphic(0, 0, 200, 200, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "mouseco")
WinSetOnTop("4corners", "", 1)
GUICtrlSetGraphic($gh, $GUI_GR_RECT, 0, 0, 200, 200)
GUICtrlSetBkColor($gh, 0xffff00)
GUISetState()
While 1
    Sleep(1000)
WEnd
Func mouseco()
    $pos = MouseGetPos()
    $win_pos = WinGetPos($mainwin)
    $color = "0x" & Hex(PixelGetColor(($win_pos[0] + $win_pos[2]) - 20, ($win_pos[1] + $win_pos[3]) - 20), 6)
    Select
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] < @DesktopHeight / 2 And $color <> "0xFFFF00"
            GUICtrlSetBkColor($gh, 0xffff00)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] > @DesktopHeight / 2 And $color <> "0x00FF00"
            GUICtrlSetBkColor($gh, 0x00ff00)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] > @DesktopHeight / 2 And $color <> "0xFF0000"
            GUICtrlSetBkColor($gh, 0xff0000)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] < @DesktopHeight / 2 And $color <> "0x0000FF"
            GUICtrlSetBkColor($gh, 0x0000ff)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
    EndSelect
EndFunc  ;==>mouseco

Func CLOSEClicked()
    Exit
EndFunc  ;==>CLOSEClicked
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

try this:

Edit: updated

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$mainwin = GUICreate("4corners", 200, 200, (@DesktopWidth - 200) / 2, (@DesktopHeight - 200) / 2)
$gh = GUICtrlCreateGraphic(0, 0, 200, 200, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "mouseco")
WinSetOnTop("4corners", "", 1)
GUICtrlSetGraphic($gh, $GUI_GR_RECT, 0, 0, 200, 200)
GUICtrlSetBkColor($gh, 0xffff00)
GUISetState()
While 1
    Sleep(1000)
WEnd
Func mouseco()
    $pos = MouseGetPos()
    $win_pos = WinGetPos($mainwin)
    $color = "0x" & Hex(PixelGetColor(($win_pos[0] + $win_pos[2]) - 20, ($win_pos[1] + $win_pos[3]) - 20), 6)
    Select
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] < @DesktopHeight / 2 And $color <> "0xFFFF00"
            GUICtrlSetBkColor($gh, 0xffff00)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] > @DesktopHeight / 2 And $color <> "0x00FF00"
            GUICtrlSetBkColor($gh, 0x00ff00)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] > @DesktopHeight / 2 And $color <> "0xFF0000"
            GUICtrlSetBkColor($gh, 0xff0000)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] < @DesktopHeight / 2 And $color <> "0x0000FF"
            GUICtrlSetBkColor($gh, 0x0000ff)
            GUICtrlSetGraphic($gh, $GUI_GR_REFRESH)
    EndSelect
EndFunc ;==>mouseco

Func CLOSEClicked()
    Exit
EndFunc ;==>CLOSEClicked
This is really brilliant code, thanks! :o
Link to comment
Share on other sites

yw, here's a play on that one

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global Const $Yellow = 0xFFFF00
Global Const $Pale_Goldenrod = 0xEEE8AA
Global Const $Green = 0x00FF00
Global Const $Pale_Green = 0x98FB98
Global Const $Red = 0xFF0000
Global Const $Tomato = 0xFF6347
Global Const $Blue = 0x0000FF
Global Const $Royal_Blue = 0x4169E1

$mainwin = GUICreate("4corners", 201, 201, -1, -1, BitOR($WS_BORDER, $WS_POPUP))
$gh1 = GUICtrlCreateGraphic(0, 0, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh1, $GUI_GR_RECT, 0, 0, 100, 100)
GUICtrlSetBkColor($gh1, $Yellow)
$gh2 = GUICtrlCreateGraphic(101, 0, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh2, $GUI_GR_RECT, 101, 0, 100, 100)
GUICtrlSetBkColor($gh2, $Green)
$gh3 = GUICtrlCreateGraphic(0, 101, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh3, $GUI_GR_RECT, 0, 101, 100, 100)
GUICtrlSetBkColor($gh3, $Red)
$gh4 = GUICtrlCreateGraphic(101, 101, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh4, $GUI_GR_RECT, 101, 101, 100, 100)
GUICtrlSetBkColor($gh4, $Blue)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Escaped")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "mouseco")
WinSetOnTop("4corners", "", 1)
GUISetState()
While 1
    Sleep(1000)
WEnd
Func mouseco()
    $pos = MouseGetPos()
    $win_pos = WinGetPos($mainwin)
    Select
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] < @DesktopHeight / 2
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 50, $win_pos[1] + 50), 6)
            If $color <> $Pale_Goldenrod Then
                GUISetState(@SW_LOCK)
                GUICtrlSetBkColor($gh1, $Pale_Goldenrod)
                GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh2, $Green)
                GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh3, $Red)
                GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh4, $Blue)
                GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
                GUISetState(@SW_UNLOCK)
            EndIf
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] < @DesktopHeight / 2
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 150, $win_pos[1] + 50), 6)
            If $color <> $Pale_Green Then
                GUISetState(@SW_LOCK)
                GUICtrlSetBkColor($gh1, $Yellow)
                GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh2, $Pale_Green)
                GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh3, $Red)
                GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh4, $Blue)
                GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
                GUISetState(@SW_UNLOCK)
            EndIf
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] > @DesktopHeight / 2
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 50, $win_pos[1] + 150), 6)
            If $color <> $Tomato Then
                GUISetState(@SW_LOCK)
                GUICtrlSetBkColor($gh1, $Yellow)
                GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh2, $Green)
                GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh3, $Tomato)
                GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh4, $Blue)
                GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
                GUISetState(@SW_UNLOCK)
            EndIf
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] > @DesktopHeight / 2
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 150, $win_pos[1] + 150), 6)
            If $color <> $Royal_Blue Then
                GUISetState(@SW_LOCK)
                GUICtrlSetBkColor($gh1, $Yellow)
                GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh2, $Green)
                GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh3, $Red)
                GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
                GUICtrlSetBkColor($gh4, $Royal_Blue)
                GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
                GUISetState(@SW_UNLOCK)
            EndIf
    EndSelect
EndFunc  ;==>mouseco

Func _Escaped()
    Exit
EndFunc  ;==>_Escaped
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

If you change the main GUI to: $mainwin = GUICreate("4corners", 200, 200), you can get the changes to be accurate when you cross over the lines in the GUI.

I just thought of something - someone could make this into a simon game. Instead of having the boxes change color when you move the mouse to a certain location, light them up randomly (continuing the pattern, not completely random) and make the user keep track of the pattern as long as they can.

Edited by greenmachine
Link to comment
Share on other sites

If you change the main GUI to: $mainwin = GUICreate("4corners", 200, 200), you can get the changes to be accurate when you cross over the lines in the GUI.

I just thought of something - someone could make this into a simon game. Instead of having the boxes change color when you move the mouse to a certain location, light them up randomly (continuing the pattern, not completely random) and make the user keep track of the pattern as long as they can.

Changed it, also took the caption out, i think it looks better

Not into making games but I think your right.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Changed it, also took the caption out, i think it looks better

Not into making games but I think your right.

I had to change all of these

$pos[0] < @DesktopWidth / 2 And $pos[1] > (@DesktopHeight / 2)-33

to get it to work level with the lines otherwise you had to be quite a bit above the horizontal line before the patch would change

Link to comment
Share on other sites

think this should work a little better:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global Const $Yellow = 0xFFFF00
Global Const $Pale_Goldenrod = 0xEEE8AA
Global Const $Green = 0x00FF00
Global Const $Pale_Green = 0x98FB98
Global Const $Red = 0xFF0000
Global Const $Tomato = 0xFF6347
Global Const $Blue = 0x0000FF
Global Const $Royal_Blue = 0x4169E1

$mainwin = GUICreate("4corners", 201, 201, -1, -1, BitOR($WS_BORDER, $WS_POPUP))
$gh1 = GUICtrlCreateGraphic(0, 0, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh1, $GUI_GR_RECT, 0, 0, 100, 100)
GUICtrlSetBkColor($gh1, $Yellow)
$gh2 = GUICtrlCreateGraphic(101, 0, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh2, $GUI_GR_RECT, 101, 0, 100, 100)
GUICtrlSetBkColor($gh2, $Green)
$gh3 = GUICtrlCreateGraphic(0, 101, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh3, $GUI_GR_RECT, 0, 101, 100, 100)
GUICtrlSetBkColor($gh3, $Red)
$gh4 = GUICtrlCreateGraphic(101, 101, 100, 100, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GUICtrlSetGraphic($gh4, $GUI_GR_RECT, 101, 101, 100, 100)
GUICtrlSetBkColor($gh4, $Blue)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Escaped")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "mouseco")
WinSetOnTop("4corners", "", 1)
GUISetState()
While 1
    Sleep(1000)
WEnd
Func mouseco()
    $pos = MouseGetPos()
    $win_pos = WinGetPos($mainwin)
    Opt("MouseCoordMode", 2)
    $pos2 = MouseGetPos()
    Opt("MouseCoordMode", 1)
    Select
        Case $pos2[0] >= 0 And $pos2[0] <= 100 And $pos2[1] >= 0 And $pos2[1] <= 100
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 50, $win_pos[1] + 50), 6)
            If $color <> $Pale_Goldenrod Then _setYellow()
        Case $pos2[0] >= 101 And $pos2[0] <= 200 And $pos2[1] >= 0 And $pos2[1] <= 100
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 150, $win_pos[1] + 50), 6)
            If $color <> $Pale_Green Then _setGreen()
        Case $pos2[0] >= 0 And $pos2[0] <= 100 And $pos2[1] >= 101 And $pos2[1] <= 200
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 50, $win_pos[1] + 150), 6)
            If $color <> $Tomato Then _setRed()
        Case $pos2[0] >= 101 And $pos2[0] <= 200 And $pos2[1] >= 101 And $pos2[1] <= 200
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 150, $win_pos[1] + 150), 6)
            If $color <> $Royal_Blue Then _setBlue()
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] < $win_pos[1] + 100
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 50, $win_pos[1] + 50), 6)
            If $color <> $Pale_Goldenrod Then _setYellow()
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] < $win_pos[1] + 100
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 150, $win_pos[1] + 50), 6)
            If $color <> $Pale_Green Then _setGreen()
        Case $pos[0] < @DesktopWidth / 2 And $pos[1] > $win_pos[1] + 100
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 50, $win_pos[1] + 150), 6)
            If $color <> $Tomato Then _setRed()
        Case $pos[0] > @DesktopWidth / 2 And $pos[1] > $win_pos[1] + 100
            $color = "0x" & Hex(PixelGetColor($win_pos[0] + 150, $win_pos[1] + 150), 6)
            If $color <> $Royal_Blue Then _setBlue()
    EndSelect
EndFunc  ;==>mouseco

Func _setYellow()
    GUISetState(@SW_LOCK)
    GUICtrlSetBkColor($gh1, $Pale_Goldenrod)
    GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh2, $Green)
    GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh3, $Red)
    GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh4, $Blue)
    GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
    GUISetState(@SW_UNLOCK)
EndFunc  ;==>_setYellow

Func _setGreen()
    GUISetState(@SW_LOCK)
    GUICtrlSetBkColor($gh1, $Yellow)
    GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh2, $Pale_Green)
    GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh3, $Red)
    GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh4, $Blue)
    GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
    GUISetState(@SW_UNLOCK)
EndFunc  ;==>_setGreen

Func _setRed()
    GUISetState(@SW_LOCK)
    GUICtrlSetBkColor($gh1, $Yellow)
    GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh2, $Green)
    GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh3, $Tomato)
    GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh4, $Blue)
    GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
    GUISetState(@SW_UNLOCK)
EndFunc  ;==>_setRed

Func _setBlue()
    GUISetState(@SW_LOCK)
    GUICtrlSetBkColor($gh1, $Yellow)
    GUICtrlSetGraphic($gh1, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh2, $Green)
    GUICtrlSetGraphic($gh2, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh3, $Red)
    GUICtrlSetGraphic($gh3, $GUI_GR_REFRESH)
    GUICtrlSetBkColor($gh4, $Royal_Blue)
    GUICtrlSetGraphic($gh4, $GUI_GR_REFRESH)
    GUISetState(@SW_UNLOCK)
EndFunc  ;==>_setBlue

Func _Escaped()
    Exit
EndFunc  ;==>_Escaped
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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