MrChiliCheese Posted June 11, 2009 Share Posted June 11, 2009 Hello, i created a GUI with two pictures, and when the mouse cursor moves over a picture it changes to another picture. Then, when cursor leaves it, the old picture is shown. My problem is, that the image is flickering, i think because the image is set again and again when the mouse is over... Here is my code: #NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $TestGUI = GUICreate("TestGUI", 143, 74, -1, -1, -1,$WS_EX_TOOLWINDOW) $icon_1 = GUICtrlCreatePic("", 5, 5, 64, 64) $icon_2 = GUICtrlCreatePic("", 74, 5, 64, 64) GUICtrlSetImage($icon_1, @ScriptDir & "\icon_1_sw.bmp") GUICtrlSetImage($icon_2, @ScriptDir & "\icon_2_sw.bmp") GUISetState() While 1 $msg = GUIGetMsg() $cursor = GUIGetCursorInfo () If Not @error Then Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $cursor[4] = $icon_1 GUICtrlSetImage ($icon_1, @ScriptDir & "\icon_1_co.bmp") Case $cursor[4] = $icon_2 GUICtrlSetImage ( $icon_2, @ScriptDir & "\icon_2_co.bmp") Case $cursor[4] <> $icon_1 Or $cursor[4] <> $icon_2 GUICtrlSetImage ( $icon_1, @ScriptDir & "\icon_1_sw.bmp") GUICtrlSetImage ( $icon_2, @ScriptDir & "\icon_2_sw.bmp") EndSelect EndIf WEnd Exit I believe my problem could be solved, when the image changes only once when the cursor is over the control and then changes once when it leaves, but i don't have an idea how to do this. Maybe u could help me. Thanks TestGUI.zip Link to comment Share on other sites More sharing options...
martin Posted June 11, 2009 Share Posted June 11, 2009 Hello, i created a GUI with two pictures, and when the mouse cursor moves over a picture it changes to another picture. Then, when cursor leaves it, the old picture is shown. My problem is, that the image is flickering, i think because the image is set again and again when the mouse is over... Here is my code: #NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $TestGUI = GUICreate("TestGUI", 143, 74, -1, -1, -1,$WS_EX_TOOLWINDOW) $icon_1 = GUICtrlCreatePic("", 5, 5, 64, 64) $icon_2 = GUICtrlCreatePic("", 74, 5, 64, 64) GUICtrlSetImage($icon_1, @ScriptDir & "\icon_1_sw.bmp") GUICtrlSetImage($icon_2, @ScriptDir & "\icon_2_sw.bmp") GUISetState() While 1 $msg = GUIGetMsg() $cursor = GUIGetCursorInfo () If Not @error Then Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $cursor[4] = $icon_1 GUICtrlSetImage ($icon_1, @ScriptDir & "\icon_1_co.bmp") Case $cursor[4] = $icon_2 GUICtrlSetImage ( $icon_2, @ScriptDir & "\icon_2_co.bmp") Case $cursor[4] <> $icon_1 Or $cursor[4] <> $icon_2 GUICtrlSetImage ( $icon_1, @ScriptDir & "\icon_1_sw.bmp") GUICtrlSetImage ( $icon_2, @ScriptDir & "\icon_2_sw.bmp") EndSelect EndIf WEnd Exit I believe my problem could be solved, when the image changes only once when the cursor is over the control and then changes once when it leaves, but i don't have an idea how to do this. Maybe u could help me. Thanks TestGUI.zipSomething like this but not tested. expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $TestGUI = GUICreate("TestGUI", 143, 74, -1, -1, -1, $WS_EX_TOOLWINDOW) $icon_1 = GUICtrlCreatePic("", 5, 5, 64, 64) $icon_2 = GUICtrlCreatePic("", 74, 5, 64, 64) GUICtrlSetImage($icon_1, @ScriptDir & "\icon_1_sw.bmp") GUICtrlSetImage($icon_2, @ScriptDir & "\icon_2_sw.bmp") GUISetState() $Icon1UnderCursor = False $Icon2UnderCursor = False While 1 $msg = GUIGetMsg() $cursor = GUIGetCursorInfo() If Not @error Then Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $cursor[4] = $icon_1 And $Icon1UnderCursor = False GUICtrlSetImage($icon_1, @ScriptDir & "\icon_1_co.bmp") $Icon1UnderCursor = True Case $cursor[4] = $icon_2 And $Icon2UnderCursor = False GUICtrlSetImage($icon_2, @ScriptDir & "\icon_2_co.bmp") $Icon2UnderCursor = True Case $cursor[4] <> $icon_1 And $$Icon1UnderCursor GUICtrlSetImage($icon_1, @ScriptDir & "\icon_1_sw.bmp") $Icon1UnderCursor = False Case $cursor[4] <> $icon_2 And $Icon2UnderCursor GUICtrlSetImage($icon_2, @ScriptDir & "\icon_2_sw.bmp") $Icon2UnderCursor = False EndSelect EndIf WEnd Exit Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
MrChiliCheese Posted June 11, 2009 Author Share Posted June 11, 2009 (edited) I'm such an idiot... so easy and i didn't see that... thanks. I improved it, if somebody needs it expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Dim $iHGap = 5, $iVGap = 0, $iCount = 9, $iSize = 48, $iGap = 5, $icon[$iCount + 1], $oIcon[$iCount + 1] $TestGUI = GUICreate("TestGUI", 300, 300, -1, -1, -1, $WS_EX_TOOLWINDOW) GUICtrlCreateGroup("", $iHGap, $iVGap, Ceiling($iCount / 2) * $iSize + (2+(Ceiling($iCount/2)+1) * $iGap), 2 * $iSize + 3 * $iGap+8) For $a = 0 To $iCount $oIcon[$a] = 1 If $a < $iCount / 2 Then $icon[$a] = GUICtrlCreatePic("", $iHGap+$iGap + ($a * $iSize) + ($a * $iGap)+1, $iVGap+2 * $iGap+2, $iSize, $iSize, $BS_BITMAP) Else $b = $a - Ceiling($iCount / 2) $icon[$a] = GUICtrlCreatePic("", $iHGap+$iGap + ($b * $iSize) + ($b * $iGap)+1, $iVGap+3 * $iGap + $iSize+2, $iSize, $iSize, $BS_BITMAP) EndIf GUICtrlSetImage($icon[$a], @ScriptDir & "\icons\icon_" & $a & "b.bmp") Next GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect $cursor = GUIGetCursorInfo() If Not @error Then For $a = 0 To $iCount If $cursor[4] = $icon[$a] And $oIcon[$a] = 1 Then $oIcon[$a] = 0 GUICtrlSetImage($icon[$a], @ScriptDir & "\icons\icon_" & $a & "a.bmp") ElseIf $cursor[4] <> $icon[$a] And $oIcon[$a] = 0 Then $oIcon[$a] = 1 GUICtrlSetImage($icon[$a], @ScriptDir & "\icons\icon_" & $a & "b.bmp") EndIf Next EndIf Sleep (1) WEnd Exit Thank you martin Edited June 11, 2009 by yetrael UritOR 1 Link to comment Share on other sites More sharing options...
UritOR Posted September 10, 2016 Share Posted September 10, 2016 How to do it in ONEvent mode? Link to comment Share on other sites More sharing options...
AutoBert Posted September 11, 2016 Share Posted September 11, 2016 same way, you can delete the line with guigetmsg and delete the case node for $GUI_EVENT_CLOSE. Don't forget the needed Sleep! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now