Feonixx Posted July 5, 2008 Posted July 5, 2008 Ok, so basically this code is a window with 2 buttons, when one button its clicked it will open another window, in which you can choose a hexidecimal color value from clicking a color on the screen. The other button will exit. Im haveing no problems getting the windows to open, but when i try to engage the Color picker, It says, $input3 was used without being defined. I have it defined within the switch, is that wrong or?? Thanks expandcollapse popup#include <GUIConstantsEx.au3> #Include <Misc.au3> #include <EditConstants.au3> Global $nCont = 0, $xColor = 0x000000, $iRunning = False $Main = GUICreate("Program - Main",150,100) GUISetBkColor(0x000000) $Input = GUICtrlCreateButton("Color Picker",5,10,140,20) $Input2 = GUICtrlCreateButton("Exit",5, 50, 140, 20) MsgBox(0,'Program', "Made By: Feonix") GUISetState(@SW_SHOW, $Main) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3;$GUI_EVENT_CLOSE Exit Case $Input $GUI1 = GUICreate("Color Picker",200,150) GUISetBkColor(0x000000) $Input3 = GUICtrlCreateButton("Choose A Color",50,20,100,20) GUICtrlCreateLabel("",50,50,50,50) GUICtrlCreateInput("",50,100,100,20) GUISetState(@SW_SHOW, $GUI1) Do $Msg2 = GUIGetMsg(1) Until $Msg2[1] = $GUI1 and $Msg2[0] = -3;$GUI_EVENT_CLOSE GUIDelete($GUI1) Case $Input2 Exit EndSwitch Switch $Msg Case $Input3 Do If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1)) GUICtrlSetBkColor($hColor, $xColor) GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6)) EndIf Until _IsPressed(01) If GUIGetMsg() = -3 Then Exit EndIf EndSwitch WEnd
rasim Posted July 5, 2008 Posted July 5, 2008 FeonixxExample:expandcollapse popup#include <GUIConstantsEx.au3> #Include <Misc.au3> #include <EditConstants.au3> Opt("GuiOnEventMode", 1) Global $nCont = 0, $xColor = 0x000000, $iRunning = False $Main = GUICreate("Program - Main",150,100) GUISetBkColor(0x000000) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Input = GUICtrlCreateButton("Color Picker",5,10,140,20) GUICtrlSetOnEvent(-1, "_ColorPick") $Input2 = GUICtrlCreateButton("Exit",5, 50, 140, 20) GUICtrlSetOnEvent(-1, "_Exit") ;================================================================== $GUI1 = GUICreate("Color Picker",200,150, -1, -1, -1, -1, $Main) GUISetBkColor(0x000000) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Input3 = GUICtrlCreateButton("Choose A Color", 50, 20, 100, 20) GUICtrlSetOnEvent(-1, "_PixelGetColor") GUICtrlCreateLabel("",50,50,50,50) GUICtrlCreateInput("",50,100,100,20) GUISetState(@SW_SHOW, $Main) While 1 Sleep(100) WEnd Func _ColorPick() GUISetState(@SW_DISABLE, $Main) GUISetState(@SW_SHOW, $GUI1) EndFunc Func _PixelGetColor() Do If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1)) ;GUICtrlSetBkColor($hColor, $xColor) ;GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6)) EndIf Sleep(10) Until _IsPressed(01) EndFunc Func _Exit() If @GUI_WinHandle = $GUI1 Then GUISetState(@SW_ENABLE, $Main) GUISetState(@SW_HIDE, $GUI1) Return 1 EndIf Exit EndFunc
Kitsune Posted July 5, 2008 Posted July 5, 2008 Here's the explaination. expandcollapse popup#include <GUIConstantsEx.au3> #Include <Misc.au3> #include <EditConstants.au3> Global $nCont = 0, $xColor = 0x000000, $iRunning = False $Main = GUICreate("Program - Main",150,100) GUISetBkColor(0x000000) $Input = GUICtrlCreateButton("Color Picker",5,10,140,20) $Input2 = GUICtrlCreateButton("Exit",5, 50, 140, 20) MsgBox(0,'Program', "Made By: Feonix") GUISetState(@SW_SHOW, $Main) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3;$GUI_EVENT_CLOSE Exit Case $Input $GUI1 = GUICreate("Color Picker",200,150) GUISetBkColor(0x000000) $Input3 = GUICtrlCreateButton("Choose A Color",50,20,100,20) ;^___Variable declared here will only work inside this case, it is strongly recommended to declare outside of the While loop. GUICtrlCreateLabel("",50,50,50,50) GUICtrlCreateInput("",50,100,100,20) GUISetState(@SW_SHOW, $GUI1) Do $Msg2 = GUIGetMsg(1) Until $Msg2[1] = $GUI1 and $Msg2[0] = -3;$GUI_EVENT_CLOSE GUIDelete($GUI1) Case $Input2 Exit EndSwitch Switch $Msg Case $Input3 Do If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1)) GUICtrlSetBkColor($hColor, $xColor) GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6)) EndIf Until _IsPressed(01) If GUIGetMsg() = -3 Then Exit EndIf EndSwitch WEndoÝ÷ Ø ÝêÞj·¦ÊË ë-y×!jx±«¢+Ø¥¹±Õ±ÐíU% ½¹ÍѹÑÍà¹ÔÌÐì(%¹±Õ±Ðí5¥Í¹ÔÌÐì(¥¹±Õ±Ðí¥Ñ ½¹ÍѹÑ̹ÔÌÐì)±½°ÀÌØí¹ ½¹ÐôÀ°ÀÌØíá ½±½ÈôÁàÀÀÀÀÀÀ°ÀÌØí¥IÕ¹¹¥¹ô±Í(ÀÌØí5¥¸ôU% ÉÑ ÅÕ½ÐíAɽɴ´5¥¸ÅÕ½Ðì°ÄÔÀ°ÄÀÀ¤)U%MÑ ½±½È ÁàÀÀÀÀÀÀ¤(ÀÌØí%¹ÁÕÐôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí ½±½ÈA¥ÈÅÕ½Ðì°Ô°ÄÀ°ÄÐÀ°ÈÀ¤(ÀÌØí%¹ÁÕÐÈôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðíá¥ÐÅÕ½Ðì°Ô°ÔÀ°ÄÐÀ°ÈÀ¤((ÀÌØí%¹ÁÕÐÌôÀ(íy}}}]¥±°µÍÕÉÑ¡ÐÙÉ¥±¡Ì¹¼Ù±Õչѥ°¹ÕÐÝ¥±°Éµ¥¸Õͱݥѡ¥¸å½ÕȹѥÉ]¡¥±±½½À¸()5Í ½à À°ÌäíAɽɴÌäì°ÅÕ½Ðí5 äè½¹¥àÅÕ½Ðì¤)U%MÑMÑÑ¡M]}M!=°ÀÌØí5¥¸¤)]¡¥±Ä(ÀÌØí5ÍôU%Ñ5Í ¤(MÝ¥Ñ ÀÌØí5Í( Í´ÌìÀÌØíU%}Y9Q} 1=M(á¥Ð( ÍÀÌØí%¹ÁÕÐ(ÀÌØíU$ÄôU% ÉÑ ÅÕ½Ðí ½±½ÈA¥ÈÅÕ½Ðì°ÈÀÀ°ÄÔÀ¤(U%MÑ ½±½È ÁàÀÀÀÀÀÀ¤(ÀÌØí%¹ÁÕÐÌôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí ¡½½Í ½±½ÈÅÕ½Ðì°ÔÀ°ÈÀ°ÄÀÀ°ÈÀ¤(íy}}}YÉ¥±Ý¥±°ÍÍ¥¹Ñ¡ÁɽÁÈÑåÁ¹Ù±Õ¡É¹åÝä¸(U% Ñɱ ÉÑ1° ÅÕ½ÐìÅÕ½Ðì°ÔÀ°ÔÀ°ÔÀ°ÔÀ¤(U% Ñɱ ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°ÔÀ°ÄÀÀ°ÄÀÀ°ÈÀ¤(U%MÑMÑÑ¡M]}M!=°ÀÌØíU$Ĥ(¼(ÀÌØí5ÍÈôU%Ñ5Í Ä¤(U¹Ñ¥°ÀÌØí5ÍÉlÅtôÀÌØíU$ĹÀÌØí5ÍÉlÁtô´ÌìÀÌØíU%}Y9Q} 1=M(U%±Ñ ÀÌØíU$Ĥ( ÍÀÌØí%¹ÁÕÐÈ(á¥Ð(¹MÝ¥Ñ (MÝ¥Ñ ÀÌØí5Í( ÍÀÌØí%¹ÁÕÐÌ(¼(%A¥á±Ñ ½±½È¡5½ÕÍÑA½Ì À¤°5½ÕÍÑA½Ì Ĥ¤±ÐìÐìÀÌØíá ½±½ÈQ¡¸(ÀÌØíá ½±½ÈôA¥á±Ñ ½±½È¡5½ÕÍÑA½Ì À¤°5½ÕÍÑA½Ì Ĥ¤(U% ÑɱMÑ ½±½È ÀÌØí¡ ½±½È°ÀÌØíá ½±½È¤(U% ÑɱMÑÑ ÀÌØí¡!à°ÅÕ½ÐìÁàÅÕ½ÐìµÀìMÑÉ¥¹I¥¡Ð¡!à ÀÌØíá ½±½È¤°Ø¤¤(¹%(U¹Ñ¥°}%ÍAÉÍÍ ÀĤ(%U%Ñ5Í ¤ô´ÌQ¡¸(á¥Ð(¹%(¹MÝ¥Ñ )]¹ Good Luck muttley
Feonixx Posted July 5, 2008 Author Posted July 5, 2008 (edited) Here's the explaination. expandcollapse popup#include <GUIConstantsEx.au3> #Include <Misc.au3> #include <EditConstants.au3> Global $nCont = 0, $xColor = 0x000000, $iRunning = False $Main = GUICreate("Program - Main",150,100) GUISetBkColor(0x000000) $Input = GUICtrlCreateButton("Color Picker",5,10,140,20) $Input2 = GUICtrlCreateButton("Exit",5, 50, 140, 20) MsgBox(0,'Program', "Made By: Feonix") GUISetState(@SW_SHOW, $Main) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3;$GUI_EVENT_CLOSE Exit Case $Input $GUI1 = GUICreate("Color Picker",200,150) GUISetBkColor(0x000000) $Input3 = GUICtrlCreateButton("Choose A Color",50,20,100,20) ;^___Variable declared here will only work inside this case, it is strongly recommended to declare outside of the While loop. GUICtrlCreateLabel("",50,50,50,50) GUICtrlCreateInput("",50,100,100,20) GUISetState(@SW_SHOW, $GUI1) Do $Msg2 = GUIGetMsg(1) Until $Msg2[1] = $GUI1 and $Msg2[0] = -3;$GUI_EVENT_CLOSE GUIDelete($GUI1) Case $Input2 Exit EndSwitch Switch $Msg Case $Input3 Do If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1)) GUICtrlSetBkColor($hColor, $xColor) GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6)) EndIf Until _IsPressed(01) If GUIGetMsg() = -3 Then Exit EndIf EndSwitch WEnd Good Luck muttley Thanks a lot!! xD in hindsight it was much easier than i was thinking, $input = 0, duhh. Tyvm Edited July 5, 2008 by Feonixx
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