BALA Posted January 6, 2007 Posted January 6, 2007 (edited) Zenda suggested I edit my code to have a GUICtrlSetData command to save memory. Right now I have my program display the X and Y positions of a coordinate. It continuously creates a new label every time it goes though the loop, using up memory. What I need help with is how I could update the X and Y positions using the GUICtrlSetData since the help file was a little unclear to me. Original script: expandcollapse popup#include <Misc.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $mainwindow = GUICreate("BA-TYPER", 300, 160) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() $position1 = GUICtrlCreateButton("Position", 70, 20, 120) GUICtrlSetOnEvent($position1, "Position") $on = GUICtrlCreateRadio ("On", 40, 60, 40, 20) $off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20) GUICtrlSetState ($off, $GUI_CHECKED) $input = GUICtrlCreateInput("", 80, 70, 180, 20) $checkbox = GUICtrlCreateCheckbox ("Input an 'Enter' after text", 41, 100, 140, 20) $time = GUICtrlCreateInput("5", 210, 127, 40, 20) GUICtrlCreateLabel ("Time between Posts (in seconds)", 40, 130) Dim $Position, $i = 0, $Record[1][2] Global $check = 0 Func CLOSEClicked() Exit EndFunc Func Position() While 1 If _IsPressed("01") Then $Position = MouseGetPos() ReDim $Record[$i + 1][2] $Record[$i][0] = $Position[0] $Record[$i][1] = $position[1] GUICtrlCreateLabel ("x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF, 200, 20) $i += 1 ExitLoop EndIf sleep(10) WEnd EndFunc While 1 If GUICtrlRead($on) = $GUI_CHECKED Then $check = 1 EndIf If GUICtrlRead($off) = $GUI_CHECKED Then $check = 0 EndIf If $check = 1 Then MouseClick("left", $Position[0], $position[1], 1) Send (""&GuiCtrlRead($input)) If GUICtrlRead($checkbox) = $GUI_CHECKED Then Send("{ENTER}") EndIf sleep(1000 * GuiCtrlRead($time)) EndIf sleep(10) WEndoÝ÷ ØÊøu«¢+Ø¥¹±Õ±Ðí5¥Í¹ÔÌÐì(¥¹±Õ±ÐíU% ½¹ÍѹÑ̹ÔÌÐì()=ÁÐ ÅÕ½ÐíU%=¹Ù¹Ñ5½ÅÕ½Ðì°Ä¤(ÀÌØíµ¥¹Ý¥¹½ÜôU% ÉÑ ÅÕ½Ðí µQeAHÅÕ½Ðì°ÌÀÀ°ÄØÀ¤)U%MÑ=¹Ù¹Ð ÀÌØíU%}Y9Q} 1=M°ÅÕ½Ðí 1=M ±¥ÅÕ½Ðì¤)U%MÑMÑÑ ¤((ÀÌØíÁ½Í¥Ñ¥½¸ÄôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½ÐíA½Í¥Ñ¥½¸ÅÕ½Ðì°ÜÀ°ÈÀ°ÄÈÀ¤)U% ÑɱMÑ=¹Ù¹Ð ÀÌØíÁ½Í¥Ñ¥½¸Ä°ÅÕ½ÐíA½Í¥Ñ¥½¸ÅÕ½Ðì¤((í¡ÉÌäíÌÑ¡±°)U% Ñɱ ÉÑ1° ÅÕ½ÐíàôÅÕ½ÐìµÀìÀÌØíI½ÉlÀÌØí¥ulÁtµÀì1µÀìÅÕ½ÐíäôÅÕ½ÐìµÀìÀÌØíI½ÉlÀÌØí¥ulÅtµÀì1°ÈÀÀ°ÈÀ¤((ÀÌØí½¸ôU% Ñɱ ÉÑI¥¼ ÅÕ½Ðí=¸ÅÕ½Ðì°ÐÀ°ØÀ°ÐÀ°ÈÀ¤(ÀÌØí½ôU% Ñɱ ÉÑI¥¼ ÅÕ½Ðí=ÅÕ½Ðì°ÐÀ°àÀ°ÐÀ°ÈÀ¤)U% ÑɱMÑMÑÑ ÀÌØí½°ÀÌØíU%} ! -¤(ÀÌØí¥¹ÁÕÐôU% Ñɱ ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àÀ°ÜÀ°ÄàÀ°ÈÀ¤((ÀÌØí¡½àôU% Ñɱ ÉÑ ¡½à ÅÕ½Ðí%¹ÁÕиÌäí¹ÑÈÌäìÑÈÑáÐÅÕ½Ðì°ÐİÄÀÀ°ÄÐÀ°ÈÀ¤((ÀÌØíÑ¥µôU% Ñɱ ÉÑ%¹ÁÕÐ ÅÕ½ÐìÔÅÕ½Ðì°ÈÄÀ°ÄÈܰÐÀ°ÈÀ¤)U% Ñɱ ÉÑ1° ÅÕ½ÐíQ¥µÑݸA½ÍÑÌ¡¥¸Í½¹Ì¤ÅÕ½Ðì°ÐÀ°ÄÌÀ¤()¥´ÀÌØíA½Í¥Ñ¥½¸°ÀÌØí¤ôÀ°ÀÌØíI½ÉlÅulÉt)±½°ÀÌØí¡¬ôÀ()Õ¹ 1=M ±¥ ¤(á¥Ð)¹Õ¹()Õ¹A½Í¥Ñ¥½¸ ¤(]¡¥±Ä($%%}%ÍAÉÍÍ ÅÕ½ÐìÀÄÅÕ½Ðì¤Q¡¸($$$ÀÌØíA½Í¥Ñ¥½¸ô5½ÕÍÑA½Ì ¤($$%I¥´ÀÌØíI½ÉlÀÌØí¤¬ÅulÉt($$$ÀÌØíI½ÉlÀÌØí¥ulÁtôÀÌØíA½Í¥Ñ¥½¹lÁt($$$ÀÌØíI½ÉlÀÌØí¥ulÅtôÀÌØíÁ½Í¥Ñ¥½¹lÅt($$%U% ÑɱMÑÑ ¤ì!±À¡É($$$ÀÌØí¤¬ôÄ($$%á¥Ñ1½½À($%¹%($%ͱÀ ÄÀ¤(%]¹)¹Õ¹()]¡¥±Ä(%%U% ÑɱI ÀÌØí½¸¤ôÀÌØíU%} ! -Q¡¸($$ÀÌØí¡¬ôÄ(%¹%(%U% ÑɱI ÀÌØí½¤ôÀÌØíU%} ! -Q¡¸($$ÀÌØí¡¬ôÀ(%¹%(%%ÀÌØí¡¬ôÄQ¡¸($%5½ÕÍ ±¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì°ÀÌØíA½Í¥Ñ¥½¹lÁt°ÀÌØíÁ½Í¥Ñ¥½¹lÅt°Ä¤($%M¹ ÅÕ½ÐìÅÕ½ÐìµÀíÕ¥ ÑɱI ÀÌØí¥¹ÁÕФ¤($%%U% ÑɱI ÀÌØí¡½à¤ôÀÌØíU%} ! -Q¡¸($$%M¹ ÅÕ½Ðíí9QIôÅÕ½Ðì¤($%¹%($%ͱÀ ÄÀÀÀ¨Õ¥ ÑɱI ÀÌØíÑ¥µ¤¤(%¹%(%ͱÀ ÄÀ¤)]¹ Edited January 6, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
eynstyne Posted January 6, 2007 Posted January 6, 2007 (edited) #include <Misc.au3> #include <GUIConstants.au3> expandcollapse popupOpt("GUIOnEventMode", 1) $mainwindow = GUICreate("BA-TYPER", 300, 160) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() $position1 = GUICtrlCreateButton("Position", 70, 20, 120) GUICtrlSetOnEvent($position1, "Position") ;Give your label a variable... $label = GUICtrlCreateLabel ("x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF, 200, 20) $on = GUICtrlCreateRadio ("On", 40, 60, 40, 20) $off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20) GUICtrlSetState ($off, $GUI_CHECKED) $input = GUICtrlCreateInput("", 80, 70, 180, 20) $checkbox = GUICtrlCreateCheckbox ("Input an 'Enter' after text", 41, 100, 140, 20) $time = GUICtrlCreateInput("5", 210, 127, 40, 20) GUICtrlCreateLabel ("Time between Posts (in seconds)", 40, 130) Dim $Position, $i = 0, $Record[1][2] Global $check = 0 Func CLOSEClicked() Exit EndFunc Func Position() While 1 If _IsPressed("01") Then $Position = MouseGetPos() ReDim $Record[$i + 1][2] $Record[$i][0] = $Position[0] $Record[$i][1] = $position[1] GUICtrlSetData($label,"x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1]) ; <--- Here $i += 1 ExitLoop EndIf sleep(10) WEnd EndFunc While 1 If GUICtrlRead($on) = $GUI_CHECKED Then $check = 1 EndIf If GUICtrlRead($off) = $GUI_CHECKED Then $check = 0 EndIf If $check = 1 Then MouseClick("left", $Position[0], $position[1], 1) Send (""&GuiCtrlRead($input)) If GUICtrlRead($checkbox) = $GUI_CHECKED Then Send("{ENTER}") EndIf sleep(1000 * GuiCtrlRead($time)) EndIf sleep(10) WEnd Edited January 6, 2007 by eynstyne F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
Helge Posted January 6, 2007 Posted January 6, 2007 GUICtrlCreateLabel returns "the identifier (controlID) of the new control". The first parameter of GUICtrlSetData should be "the control identifier (controlID) as returned by a GUICtrlCreate... function." $id = GUICtrlCreateLabel("initial text", 10, 10, 280, 20) GUICtrlSetData($id, "updated text") Simple.
BALA Posted January 6, 2007 Author Posted January 6, 2007 (edited) Would I just create the label, without any thing in it, and move the text I currently have in the label to the GuiCtrlSetData? I.E. : expandcollapse popup#include <Misc.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $mainwindow = GUICreate("BA-TYPER", 300, 160) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() $position1 = GUICtrlCreateButton("Position", 70, 20, 120) GUICtrlSetOnEvent($position1, "Position") ;here's the label $label = GUICtrlCreateLabel ("", 200, 20) $on = GUICtrlCreateRadio ("On", 40, 60, 40, 20) $off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20) GUICtrlSetState ($off, $GUI_CHECKED) $input = GUICtrlCreateInput("", 80, 70, 180, 20) $checkbox = GUICtrlCreateCheckbox ("Input an 'Enter' after text", 41, 100, 140, 20) $time = GUICtrlCreateInput("5", 210, 127, 40, 20) GUICtrlCreateLabel ("Time between Posts (in seconds)", 40, 130) Dim $Position, $i = 0, $Record[1][2] Global $check = 0 Func CLOSEClicked() Exit EndFunc Func Position() While 1 If _IsPressed("01") Then $Position = MouseGetPos() ReDim $Record[$i + 1][2] $Record[$i][0] = $Position[0] $Record[$i][1] = $position[1] GUICtrlSetData($label, "x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF) ; <--- Moved text here $i += 1 ExitLoop EndIf sleep(10) WEnd EndFunc While 1 If GUICtrlRead($on) = $GUI_CHECKED Then $check = 1 EndIf If GUICtrlRead($off) = $GUI_CHECKED Then $check = 0 EndIf If $check = 1 Then MouseClick("left", $Position[0], $position[1], 1) Send (""&GuiCtrlRead($input)) If GUICtrlRead($checkbox) = $GUI_CHECKED Then Send("{ENTER}") EndIf sleep(1000 * GuiCtrlRead($time)) EndIf sleep(10) WEnd Edited January 6, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
eynstyne Posted January 6, 2007 Posted January 6, 2007 It's your choice to leave it blank or not... Or you can take make your label llook like this x = 0 y = 0 then fill it in after F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
BALA Posted January 6, 2007 Author Posted January 6, 2007 I now have this: expandcollapse popup#include <Misc.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $mainwindow = GUICreate("BA-TYPER", 300, 160) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() $position1 = GUICtrlCreateButton("Position", 70, 20, 120) GUICtrlSetOnEvent($position1, "Position") $label = GUICtrlCreateLabel ("x = " & @LF & "y = "& @LF, 200, 20) $on = GUICtrlCreateRadio ("On", 40, 60, 40, 20) $off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20) GUICtrlSetState ($off, $GUI_CHECKED) $input = GUICtrlCreateInput("", 80, 70, 180, 20) $checkbox = GUICtrlCreateCheckbox ("Input an 'Enter' after text", 41, 100, 140, 20) $time = GUICtrlCreateInput("5", 210, 127, 40, 20) GUICtrlCreateLabel ("Time between Posts (in seconds)", 40, 130) Dim $Position, $i = 0, $Record[1][2] Global $check = 0 Func CLOSEClicked() Exit EndFunc Func Position() While 1 If _IsPressed("01") Then $Position = MouseGetPos() ReDim $Record[$i + 1][2] $Record[$i][0] = $Position[0] $Record[$i][1] = $position[1] GUICtrlSetData($label,"x = "& $Record[$i][0] & @LF & "y = "& $Record[$i][1]) $i += 1 ExitLoop EndIf sleep(10) WEnd EndFunc While 1 If GUICtrlRead($on) = $GUI_CHECKED Then $check = 1 EndIf If GUICtrlRead($off) = $GUI_CHECKED Then $check = 0 EndIf If $check = 1 Then MouseClick("left", $Position[0], $position[1], 1) Send (""&GuiCtrlRead($input)) If GUICtrlRead($checkbox) = $GUI_CHECKED Then Send("{ENTER}") EndIf sleep(1000 * GuiCtrlRead($time)) EndIf sleep(10) WEnd But now it has the numbers under the X or Y How do I make the numbers be like they were in the original script? [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
eynstyne Posted January 6, 2007 Posted January 6, 2007 (edited) Remove the @LF and @CRLF Line feeds You may also want to set a width and height for your label or else it will wrap around $label = GUICtrlCreateLabel ("x = " & " " & "y = "& " ", 200, 20,200,20) ; In place of @LF , " " Edited January 6, 2007 by eynstyne F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
BALA Posted January 6, 2007 Author Posted January 6, 2007 (edited) oh! Forgot to delete that when I copied and pasted EDIT: I don't think that was the problem Edited January 6, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Helge Posted January 6, 2007 Posted January 6, 2007 Like Jesus said to the lonely sheep...specify a width and height on your labels and your problems will be solved.
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