thelex Posted March 14, 2008 Share Posted March 14, 2008 i created a app to show coords + pixelcolor of the mouse as it moves around, but the thing is: it's flashy.Its annyoing. whatever GUI coontrol i create to view them, it's flashing, and someetimes unreadable.try it yourself:<sub>#include <GUIConstants.au3> #include<WinAPI.au3> GUICreate ("Mouse", 200, 300) While 1 $color = PixelGetColor( _WinAPI_GetMousePosX() , _WinAPI_GetMousePosY() ) Sleep (10) GUICtrlCreateLabel ('x : ' & _WinAPI_GetMousePosX() & " y : " & _WinAPI_GetMousePosY(), 50,10 ,180 , 20) GUICtrlCreateLabel ('Color(RGB):' & $color , 50, 90, 180 , 20) GUICtrlCreateButton ("For later use", 50, 40, 100, 20 ) ;------pos---info---------------------left,top,with,height------------------------------- sleep(10) GUISetState () $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then exit WEnd</sub> Link to comment Share on other sites More sharing options...
DjDeep00 Posted March 14, 2008 Share Posted March 14, 2008 @thelex...Instead of updating the data for the controls..you are creating new controls... First create the controls and then in the while loop use Guictrlsetdata()... Link to comment Share on other sites More sharing options...
thelex Posted March 14, 2008 Author Share Posted March 14, 2008 could you make a example? im new to this.. Link to comment Share on other sites More sharing options...
Aassdd Posted March 14, 2008 Share Posted March 14, 2008 #include <GUIConstants.au3> #include<WinAPI.au3> GUICreate("Mouse", 200, 300) ; GUI Window GUISetState() ; GUI State $color = PixelGetColor( _WinAPI_GetMousePosX(), _WinAPI_GetMousePosY()) ; GUI Controls [Start] $LblPos = GUICtrlCreateLabel("", 50, 10, 180, 20) GUICtrlCreateLabel('Color(RGB):' & $color, 50, 90, 180, 20) GUICtrlCreateButton("For later use", 50, 40, 100, 20) ; GUI Controls [End] While 1 Sleep(10) GUICtrlSetData($LblPos, 'x : ' & _WinAPI_GetMousePosX() & " y : " & _WinAPI_GetMousePosY()) ; Reset the data of the control to the current mouse pos $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Link to comment Share on other sites More sharing options...
thelex Posted March 14, 2008 Author Share Posted March 14, 2008 Awesome! thanks, but i don't get it to do the same with the color .. >< Link to comment Share on other sites More sharing options...
Aassdd Posted March 14, 2008 Share Posted March 14, 2008 (edited) I'll do it now. Also create a new script and try to make the same thing using Koda (Scite > Tools > Koda). It will help you understand how to sort things when you make a gui. (check this post back soon) EDIT: You were trying this, weren't you? expandcollapse popup#include <GUIConstants.au3> #include<WinAPI.au3> GUICreate("Mouse", 200, 300) ; GUI Window GUISetState() ; GUI State $color = PixelGetColor(_WinAPI_GetMousePosX(), _WinAPI_GetMousePosY()) ; GUI Controls [Start] $LblPos = GUICtrlCreateLabel("", 50, 10, 180, 20) $LblClr = GUICtrlCreateLabel("", 50, 90, 180, 20) GUICtrlCreateButton("For later use", 50, 40, 100, 20) ; GUI Controls [End] While 1 Sleep(10) GUICtrlSetData($LblPos, "x : " & _WinAPI_GetMousePosX() & " y : " & _WinAPI_GetMousePosY()) ; Reset the data of the control to the current mouse pos GUICtrlSetData($LblClr, "Color(RGB):" & $color) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEndoÝ÷ Ù8^欢{aj×hzÉ÷öÜ(®H¬mçºÇ°éò¢ç±yËzØ^±Êâ¦Ü!zxël¶a{Múrh®X§z+`zÛ-ç.®·§¶±zW(ÚÚÞ+-z¸¶azg¦¢¼¢Ü(®L¨º¯zÚ zÛaz±zW(Þ½êò¶)êÞjëh×6#include <GUIConstants.au3> #include<WinAPI.au3> GUICreate("Mouse", 200, 300) ; GUI Window GUISetState() ; GUI State ; GUI Controls [Start] $LblPos = GUICtrlCreateLabel("", 50, 10, 180, 20) $LblClr = GUICtrlCreateLabel("", 50, 90, 180, 20) GUICtrlCreateButton("For later use", 50, 40, 100, 20) ; GUI Controls [End] While 1 Sleep(10) GUICtrlSetData($LblPos, "x : " & _WinAPI_GetMousePosX() & " y : " & _WinAPI_GetMousePosY()) ; Reset the data of the control to the current mouse pos GUICtrlSetData($LblClr, "Color(RGB):" & PixelGetColor(_WinAPI_GetMousePosX(), _WinAPI_GetMousePosY())) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Edited March 14, 2008 by Aassdd Link to comment Share on other sites More sharing options...
thelex Posted March 14, 2008 Author Share Posted March 14, 2008 Dude, you are awesome! Thanks a lot for the help! Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 14, 2008 Share Posted March 14, 2008 I've done updates like that before, and the problem is the flicker of the control when you are constantly updating it. To avoid that, I prefer to keep track of the old value, and only update the control if it changed. This is the same script with that implemented: #include <GUIConstants.au3> #include <StaticConstants.au3> Global $avMouse[2] = [0, 0] Global $avMouseOld = $avMouse Global $iPixelColor = 0 Global $iPixelOld = 0 Global $hGUI = GUICreate("Mouse", 300, 200) Global $Label_MousePos = GUICtrlCreateLabel('x: 0 y: 0', 10, 10, 280, 20, $SS_CENTER) Global $Label_Color = GUICtrlCreateLabel('Color(RGB): 0', 10, 40, 280, 20, $SS_CENTER) Global $Button = GUICtrlCreateButton("For later use", 100, 160, 100, 30) GUISetState() While 1 ; Get current values $avMouse = MouseGetPos() $iPixelColor = PixelGetColor($avMouse[0], $avMouse[1]) ; Update GUI if changed If ($avMouse[0] <> $avMouseOld[0]) Or ($avMouse[1] <> $avMouseOld[1]) Or ($iPixelColor <> $iPixelOld) Then $avMouseOld = $avMouse $iPixelOld = $iPixelColor ControlSetText($hGUI, "", $Label_MousePos, 'x: ' & $avMouse[0] & ' y: ' & $avMouse[1]) ControlSetText($hGUI, "", $Label_Color, 'Color(RGB): 0x' & Hex($iPixelColor, 6) & ' = ' & $iPixelColor & ' (Dec)') EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button MsgBox(64, "Mouse", "For later use...") EndSwitch WEnd I think you'll find the GUI looks much more stable without the flickering controls. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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