buzz44 Posted February 22, 2005 Share Posted February 22, 2005 i have a script where an input is constantly being checked to see if it is the same Func _GetHex() $Hex_Red = Hex(GUICtrlRead ($Input_Red), 2) $Hex_Red1 = Hex(GUICtrlRead ($Input_Red), 2) If String($Hex_Red) <> String($Hex_Red1) Then GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red1) EndIf EndFunc because there is no sleep in between $hex_red and $hex_red1 it does it instantaniously .... it checks an updown input .. even if i hold down up the input is changin constantly but it still is too fast if add a sleep Func _GetHex() $Hex_Red = Hex(GUICtrlRead ($Input_Red), 2) Sleep(1) $Hex_Red1 = Hex(GUICtrlRead ($Input_Red), 2) If String($Hex_Red) <> String($Hex_Red1) Then GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red1) EndIf EndFunc it is too slow .... i click the up in the input and the $input_hex value wont change or is delayed... as u can see with sleep is too slow and without it is too fast .... is there another wat i can do this .. this is my "complete script" it is still in development and testing debuggin stages. expandcollapse popup#include <GuiConstants.au3> #include "color.au3" GuiCreate("MyGUI", 162, 81,(@DesktopWidth-162)/2, (@DesktopHeight-81)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Input_Red = GuiCtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER) $Input_Green = GuiCtrlCreateInput("0", 60, 24, 40, 20, $ES_NUMBER) $Input_Blue = GuiCtrlCreateInput("0", 110, 24, 40, 20, $ES_NUMBER) $Input_Hex = GuiCtrlCreateInput("0x000000", 10, 50, 80, 20) $Label_Blue = GuiCtrlCreateLabel("Blue", 110, 10, 30, 13) $Label_Red = GuiCtrlCreateLabel("Red", 10, 10, 40, 11) $Label_Green = GuiCtrlCreateLabel("Green", 60, 10, 40, 14) $Label_Colour = GuiCtrlCreateLabel("", 100, 50, 50, 20) $updown_Red = GUICtrlCreateUpdown($Input_Red,$UDS_ARROWKEYS) $updown_Blue = GUICtrlCreateUpdown($Input_Blue,$UDS_ARROWKEYS) $updown_Green = GUICtrlCreateUpdown($Input_Green,$UDS_ARROWKEYS) GUICtrlSetPos($Input_Red, 10,25, 40, 20 ) GUICtrlSetPos($Input_Green, 60,25, 40, 20 ) GUICtrlSetPos($Input_Blue, 110,25, 40, 20 ) GUICtrlSetLimit($updown_Red, 255, 0) GUICtrlSetLimit($updown_Blue, 255, 0) GUICtrlSetLimit($updown_Green, 255, 0) GuiSetState() While 1 _GetHex() $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _GetHex() $Hex_Red = Hex(GUICtrlRead ($Input_Red), 2) $Hex_Red1 = Hex(GUICtrlRead ($Input_Red), 2) $Hex_Green = Hex(GUICtrlRead ($Input_Green), 2) $Hex_Blue = Hex(GUICtrlRead ($Input_Blue), 2) If String($Hex_Red) <> String($Hex_Red1) Then GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red1 & $Hex_Green & $Hex_Blue) EndIf GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) EndFunc Func _GetRGB() $RGB_Red = _ColorGetRed ($Input_Hex) $RGB_Green = _ColorGetGreen ($Input_Hex) $RGB_Blue = _ColorGetBlue ($Input_Hex) GUICtrlSetData ($Input_Red, $RGB_Red) GUICtrlSetData ($Input_Green, $RGB_Green) GUICtrlSetData ($Input_Blue, $RGB_Blue) GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) EndFunc Func _ReadRGB() $Red = GUICtrlRead(3) Sleep(0) $Red1 = GUICtrlRead(3) $Green = GUICtrlRead($Input_Green) $Blue = GUICtrlRead($Input_Blue) If $Red = $Red1 Then GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) Else GUICtrlSetData ($Input_Hex, Hex($Red1,2)) EndIf EndFunc qq Link to comment Share on other sites More sharing options...
Andre Posted February 22, 2005 Share Posted February 22, 2005 Hi, Perhaps using : ProcessSetPriority may help ? Andre What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel! Link to comment Share on other sites More sharing options...
buzz44 Posted February 22, 2005 Author Share Posted February 22, 2005 ProcessSetPriority ( "autoit3.exe", 4)??? this is newer script .. plz test it so u know(and everyone else) wat i mean .... the Hex is delayed even thou the input still changes. expandcollapse popup#include <GuiConstants.au3> #include "color.au3" ProcessSetPriority ( "autoit3.exe", 4) GuiCreate("MyGUI", 162, 81,(@DesktopWidth-162)/2, (@DesktopHeight-81)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Input_Red = GuiCtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER) $Input_Green = GuiCtrlCreateInput("0", 60, 24, 40, 20, $ES_NUMBER) $Input_Blue = GuiCtrlCreateInput("0", 110, 24, 40, 20, $ES_NUMBER) $Input_Hex = GuiCtrlCreateInput("0x000000", 10, 50, 80, 20) $Label_Blue = GuiCtrlCreateLabel("Blue", 110, 10, 30, 13) $Label_Red = GuiCtrlCreateLabel("Red", 10, 10, 40, 11) $Label_Green = GuiCtrlCreateLabel("Green", 60, 10, 40, 14) $Label_Colour = GuiCtrlCreateLabel("", 100, 50, 50, 20) $updown_Red = GUICtrlCreateUpdown($Input_Red,$UDS_ARROWKEYS) $updown_Blue = GUICtrlCreateUpdown($Input_Blue,$UDS_ARROWKEYS) $updown_Green = GUICtrlCreateUpdown($Input_Green,$UDS_ARROWKEYS) GUICtrlSetPos($Input_Red, 10,25, 40, 20 ) GUICtrlSetPos($Input_Green, 60,25, 40, 20 ) GUICtrlSetPos($Input_Blue, 110,25, 40, 20 ) GUICtrlSetLimit($updown_Red, 255, 0) GUICtrlSetLimit($updown_Blue, 255, 0) GUICtrlSetLimit($updown_Green, 255, 0) GuiSetState() While 1 _GetHex() $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _GetHex() $Hex_Red = Hex(GUICtrlRead ($Input_Red), 2) Sleep(1) $Hex_Red_2 = Hex(GUICtrlRead ($Input_Red), 2) $Hex_Green = Hex(GUICtrlRead ($Input_Green), 2) Sleep(1) $Hex_Green_2 = Hex(GUICtrlRead ($Input_Green), 2) $Hex_Blue = Hex(GUICtrlRead ($Input_Blue), 2) Sleep(1) $Hex_Blue_2 = Hex(GUICtrlRead ($Input_Blue), 2) If String($Hex_Red) <> String($Hex_Red_2) Then GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red_2 & $Hex_Green_2 & $Hex_Blue_2) EndIf If String($Hex_Green) <> String($Hex_Green_2) Then GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red_2 & $Hex_Green_2 & $Hex_Blue_2) EndIf If String($Hex_Blue) <> String($Hex_Blue_2) Then GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red_2 & $Hex_Green_2 & $Hex_Blue_2) EndIf GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) EndFunc Func _GetRGB() $RGB_Red = _ColorGetRed ($Input_Hex) $RGB_Green = _ColorGetGreen ($Input_Hex) $RGB_Blue = _ColorGetBlue ($Input_Hex) GUICtrlSetData ($Input_Red, $RGB_Red) GUICtrlSetData ($Input_Green, $RGB_Green) GUICtrlSetData ($Input_Blue, $RGB_Blue) GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) EndFunc Func _ReadRGB() $Red = GUICtrlRead(3) Sleep(0) $Red1 = GUICtrlRead(3) $Green = GUICtrlRead($Input_Green) $Blue = GUICtrlRead($Input_Blue) If $Red = $Red1 Then GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) Else GUICtrlSetData ($Input_Hex, Hex($Red1,2)) EndIf EndFunc qq Link to comment Share on other sites More sharing options...
Andre Posted February 22, 2005 Share Posted February 22, 2005 Hi, See the help for this : GUI Reference - OnEvent Mode In the OnEvent mode instead of constantly polling the GUI to find out if anything has happened you make the GUI temporarily pause your script and call a pre-defined function to handle the event. For example, if the user clicks Button1 the GUI pauses your main script and calls a previously defined user function that deals with Button1. When the function call is completed the main script is resumed. This mode is similar to the Visual Basic forms method. Andre What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel! Link to comment Share on other sites More sharing options...
buzz44 Posted February 22, 2005 Author Share Posted February 22, 2005 (edited) tried it .. it still delays .. i think even more now .. =( edit: actually not sure if it worked or not .. i forget the remove "_gethex()" from the while loop so it overrided it .... but i cant get it working now ... i have Opt("GUIOnEventMode", 1) $Input_Red = GuiCtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER) $updown_Red = GUICtrlCreateUpdown($Input_Red,$UDS_ARROWKEYS) GUISetOnEvent($Input_Red, "Hello") Func Hello() msgbox(0,"","") ;;;;;$Hex_Red = Hex(GUICtrlRead ($Input_Red), 2) ;;;;;GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red) EndFunc as u can see i cut alota the code out so u can see it easier ...the msgbox doesnt pop up when i click ... i also replaced GUISetOnEvent($Input_Red, "Hello") with GUISetOnEvent($updown_red, "Hello") and still no msg box .. am i doing sumthing wrong ?? or doesnt autoit recognise the "updown" as a button? Edited February 22, 2005 by burrup qq Link to comment Share on other sites More sharing options...
Andre Posted February 22, 2005 Share Posted February 22, 2005 Sorry out of ideas for now. Andre What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel! Link to comment Share on other sites More sharing options...
Developers Jos Posted February 22, 2005 Developers Share Posted February 22, 2005 The way you test changes in the RGB controls doesn't make sence. You are trying to capture the change as it happens which will never work. You should save the current RGB values in global variables and test against these "last know value's" for RGB to see if the current one is different. If it differs you update the controls and save the last values again... Like: expandcollapse popup#include <GuiConstants.au3> #include "color.au3" Global $S_Red Global $S_Green Global $S_Blue ProcessSetPriority("autoit3.exe", 4) GUICreate("MyGUI", 162, 81, (@DesktopWidth - 162) / 2, (@DesktopHeight - 81) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Input_Red = GUICtrlCreateInput("0", 10, 24, 40, 20, $ES_NUMBER) $Input_Green = GUICtrlCreateInput("0", 60, 24, 40, 20, $ES_NUMBER) $Input_Blue = GUICtrlCreateInput("0", 110, 24, 40, 20, $ES_NUMBER) $Input_Hex = GUICtrlCreateInput("0x000000", 10, 50, 80, 20) $Label_Blue = GUICtrlCreateLabel("Blue", 110, 10, 30, 13) $Label_Red = GUICtrlCreateLabel("Red", 10, 10, 40, 11) $Label_Green = GUICtrlCreateLabel("Green", 60, 10, 40, 14) $Label_Colour = GUICtrlCreateLabel("", 100, 50, 50, 20) $updown_Red = GUICtrlCreateUpdown($Input_Red, $UDS_ARROWKEYS) $updown_Blue = GUICtrlCreateUpdown($Input_Blue, $UDS_ARROWKEYS) $updown_Green = GUICtrlCreateUpdown($Input_Green, $UDS_ARROWKEYS) GUICtrlSetPos($Input_Red, 10, 25, 40, 20) GUICtrlSetPos($Input_Green, 60, 25, 40, 20) GUICtrlSetPos($Input_Blue, 110, 25, 40, 20) GUICtrlSetLimit($updown_Red, 255, 0) GUICtrlSetLimit($updown_Blue, 255, 0) GUICtrlSetLimit($updown_Green, 255, 0) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else _GetHex() EndSelect WEnd Exit Func _GetHex() $Hex_Red = Hex(GUICtrlRead($Input_Red), 2) $Hex_Green = Hex(GUICtrlRead($Input_Green), 2) $Hex_Blue = Hex(GUICtrlRead($Input_Blue), 2) If String($Hex_Red) <> String($S_Red) Or String($Hex_Green) <> String($S_Green) Or String($Hex_Blue) <> String($S_Blue) Then GUICtrlSetData($Input_Hex, "0x" & $Hex_Red & $Hex_Green & $Hex_Blue) $S_Blue = $Hex_Blue $S_Green = $Hex_Green $S_Red = $Hex_Red EndIf GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex)) EndFunc ;==>_GetHex Func _GetRGB() $RGB_Red = _ColorGetRed($Input_Hex) $RGB_Green = _ColorGetGreen($Input_Hex) $RGB_Blue = _ColorGetBlue($Input_Hex) GUICtrlSetData($Input_Red, $RGB_Red) GUICtrlSetData($Input_Green, $RGB_Green) GUICtrlSetData($Input_Blue, $RGB_Blue) GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex)) EndFunc ;==>_GetRGB Func _ReadRGB() $Red = GUICtrlRead(3) Sleep(0) $Red1 = GUICtrlRead(3) $Green = GUICtrlRead($Input_Green) $Blue = GUICtrlRead($Input_Blue) If $Red = $Red1 Then GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex)) Else GUICtrlSetData($Input_Hex, Hex($Red1, 2)) EndIf EndFunc ;==>_ReadRGB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
buzz44 Posted February 22, 2005 Author Share Posted February 22, 2005 wow.. it worked .... yeah thats one problem with me .. i dont like using "global/local/dim" .. i should probably start as it would make my life alot easier =) thx andre and jdeb for all ur help qq Link to comment Share on other sites More sharing options...
buzz44 Posted February 22, 2005 Author Share Posted February 22, 2005 (edited) lol got another problem .. it is similiar but ... the reason i wanted to do the above was so that you can edit the RGB values and the HEX value with out anyproblem why does ur way work ... Func _GetHex() $Hex_Red = Hex(GUICtrlRead($Input_Red), 2) $Hex_Green = Hex(GUICtrlRead($Input_Green), 2) $Hex_Blue = Hex(GUICtrlRead($Input_Blue), 2) If String($Hex_Red) <> String($A_Red) Or String($Hex_Green) <> String($A_Green) Or String($Hex_Blue) <> String($A_Blue) Then GUICtrlSetData($Input_Hex, "0x" & $Hex_Red & $Hex_Green & $Hex_Blue) $A_Red = $Hex_Red $A_Green = $Hex_Green $A_Blue = $Hex_Blue EndIf GUICtrlSetBkColor($Label_Colour, GUICtrlRead($Input_Hex)) EndFunc but when i try reverse it ... ie above was for the RGB to hex .. below is for Hex to RGB .. it doesnt work Func _GetRGB() $RGB_Red = _ColorGetRed ($Input_Hex) $RGB_Green = _ColorGetGreen ($Input_Hex) $RGB_Blue = _ColorGetBlue ($Input_Hex) If String($RGB_Red) <> String($B_Red) Or String($RGB_Green) <> String($B_Green) Or String($RGB_Blue) <> String($B_Blue) Then GUICtrlSetData ($Input_Red, $RGB_Red) GUICtrlSetData ($Input_Green, $RGB_Green) GUICtrlSetData ($Input_Blue, $RGB_Blue) $B_Red = $RGB_Red $B_Green = $RGB_Green $B_Blue = $RGB_Blue GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) EndIf EndFunc EDIT:: nvm i figured it out .. i needed to have GUICtrlRead($input_hex) Edited February 22, 2005 by burrup qq 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