UnknownWarrior Posted August 2, 2009 Share Posted August 2, 2009 Well I am having problems which my tiredness right now could be the cause of me not figuring this out, but I just can't solve it >< When I call OnAutoItExit it goes to the correct Func, but it will not 'GUICtrlRead' my Label correctly. It keeps saying my label = 0, when I am looking at the GUI at it is clearly 100000. Not much script to show but: Opt("OnExitFunc", "exit") Func exit() $Read = GUICtrlRead($Label8) MsgBox(0, "", $Read) EndFunc I even put the Opt after my GUI form that has $Label8 in it.... Still nothing ><. I want it to eventually send me the users name and current money ($Label8) no matter when/how they dc... If the client disconnects, I want that information. I have it all covered except if they right click the AutoIt logo in the tool tray and exit that way (And I'm hoping this will do the job for me) Also, a quick question... Is there any way of READING the 'current GUI'... I honestly swear I've seen it somewhere, and it probably is VERY simple, but I searched in the HelpFile a little bit and searched a few times on the forums here and can't find what I'm looking for. Is there a specific func to do so? Thanks Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2009 Share Posted August 2, 2009 (edited) There is not enough code to reproduce the error. I hate the guessing game. Make a small code to re-produce the error 8) EDIT: 1st Suggestion, do not use the name "Exit" as a Function because "Exit" is a command name. Edited August 2, 2009 by Valuater Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 2, 2009 Author Share Posted August 2, 2009 There is not enough code to reproduce the error. I hate the guessing game.Make a small code to re-produce the error8)EDIT: 1st Suggestion, do not use the name "Exit" as a Function because "Exit" is a command name.Well, as embarrassing as it is, I have to admit I am at a campground typing this. I bought a day of wi-fi out here when I was camping with my family because the wind was horrendous (can't fish too easily, and can't do any outdoor activities...).... So I don't have my home computer with me xD... Just a labtop I can browse the internet with, and I can still code with. And this isn't labtop I have my script on either (I'm using my bros, the script is on mine which isn't functioning so well atm xD)....ANYWAYS... I don't have easy-access to the code >_<.But anyways, all that I would be able to show you is the GUI that has the Label on it, because I doubt you want to read through 1,700 lines of coding to find me my error xD.I suppose you can't really help me this way either :S... If theres any suggestions you can give me that I can try on my own, that'd be great. Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2009 Share Posted August 2, 2009 Only one that comes to mind... You are probably destroying the GUI before the "Exit" is reading it. Another words, I think you are using GUIDelete($Your_GUI_Name) Before the exit reads the label.... my best guess 8) Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 2, 2009 Author Share Posted August 2, 2009 Only one that comes to mind...You are probably destroying the GUI before the "Exit" is reading it. Another words, I think you are using GUIDelete($Your_GUI_Name)Before the exit reads the label.... my best guess8)Hehe... I wasn't aware there was a GUIDelete function xD (I never use it anyways >_<)I have the GUI close with the script... And even if I had my code with me, I really couldn't show anything that isn't anymore than what I'm telling you now xPBasically I have a TCPSend that sends my server the username of the client, and their money. The server then writes down the money that they had last before shutting down. Then I noticed when I reloaded the client it was at 0 money (when it previously had 10000).... I ran several tests, watching the GUI before shut down and all, and it HAS 10000 at the moment of shut down.... But for some reason, no matter how I changed it up... The GUICtrlRead for the label was not working :S. Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2009 Share Posted August 2, 2009 See... I told you I hate guessing... wait till you can post a "re-productive" code Then we can help! 8) Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 2, 2009 Author Share Posted August 2, 2009 See...I told you I hate guessing... wait till you can post a "re-productive" codeThen we can help!8)Thats the thing... Unless I post all 1,700 lines of my script, there isn't much to post at all... The GUICtrlRead($Label8) works throughout the entire script.... I use it everywhere, beings thats the label that states the amount of money the user has. But for some reason it just will not work at the end. The only script that would be useful in posting is the label itself, but I know that works because I use it in the program before shut down.But I'll hold you to 'we can help'.... I'll be back at home tomorrow so I'll have my desktop to work on and all my scripts there.Thanks >_< Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 2, 2009 Author Share Posted August 2, 2009 Well here it is.... All the necessary info >< expandcollapse popup$Label7 = GUICtrlCreateLabel("Current Money:", 160, 8, 148, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) $Label8 = GUICtrlCreateLabel("0", 328, 8, 262, 24); GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $Label9 = GUICtrlCreateLabel("", 80, 376, 444, 44) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Add $", 608, 72, 57, 25, $WS_GROUP) $Button3 = GUICtrlCreateButton("Cash-Out!", 608, 32, 57, 25, $WS_GROUP) #EndRegion ### END Koda GUI section ### ;------------------ $msg = 0 While 1 $msg = GUIGetMsg() $currentmoney = GUICtrlRead($Label8) If $msg = $GUI_EVENT_CLOSE Then OFF() EndIf ;-------------------- Opt("OnExitFunc", "OFF") Func OFF() MsgBox(0,"", $userL) $currentmoney = GUICtrlRead($Label8) If $userL = "8" Then TCPsend ($Socket, '<DC>^') MsgBox(0, "", "HEYYY") Else MsgBox(0, "", $currentmoney) TCPsend ($Socket, '<DC1>^' & $userL & "^money^" &$currentmoney) EndIf Sleep(2000) TCPShutdown () Exit EndFunc On ordinary shut downs (by pressing the X button in the GUI) the MsgBox: Else MsgBox(0, "", $currentmoney) pops up... But when the Opt is calling it... It just will not read that $Label8 >< Hope you can help >_< Link to comment Share on other sites More sharing options...
Info Posted August 2, 2009 Share Posted August 2, 2009 Well here it is.... All the necessary info >< expandcollapse popup$Label7 = GUICtrlCreateLabel("Current Money:", 160, 8, 148, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) $Label8 = GUICtrlCreateLabel("0", 328, 8, 262, 24); GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $Label9 = GUICtrlCreateLabel("", 80, 376, 444, 44) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Add $", 608, 72, 57, 25, $WS_GROUP) $Button3 = GUICtrlCreateButton("Cash-Out!", 608, 32, 57, 25, $WS_GROUP) #EndRegion ### END Koda GUI section ### ;------------------ $msg = 0 While 1 $msg = GUIGetMsg() $currentmoney = GUICtrlRead($Label8) If $msg = $GUI_EVENT_CLOSE Then OFF() EndIf ;-------------------- Opt("OnExitFunc", "OFF") Func OFF() MsgBox(0,"", $userL) $currentmoney = GUICtrlRead($Label8) If $userL = "8" Then TCPsend ($Socket, '<DC>^') MsgBox(0, "", "HEYYY") Else MsgBox(0, "", $currentmoney) TCPsend ($Socket, '<DC1>^' & $userL & "^money^" &$currentmoney) EndIf Sleep(2000) TCPShutdown () Exit EndFunc On ordinary shut downs (by pressing the X button in the GUI) the MsgBox: Else MsgBox(0, "", $currentmoney) pops up... But when the Opt is calling it... It just will not read that $Label8 >< Hope you can help >_< You forgot your 'WEnd'. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 2, 2009 Author Share Posted August 2, 2009 Hehe, I'm not that noob xD... Thats just the first 15 lines of my While loop... My while loop is hundreds of lines long :S. (Case statements in them) Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2009 Share Posted August 2, 2009 (edited) This... Opt("OnExitFunc", "OFF") goes at the VERY TOP of the script at the beginning .... Maybe use .... Global $Label8 at the top too BTW; I do not need all 1700 lines of code, but I did offer to look at it for you. You have declined numerous times... and that's ok.. but, you need to make a small script that can duplicate the problem before I can help you ... NO MORE GUESSING! 8) Edited August 2, 2009 by Valuater Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 3, 2009 Author Share Posted August 3, 2009 This...Opt("OnExitFunc", "OFF")goes at the VERY TOP of the scriptat the beginning.... Maybe use ....Global $Label8at the top tooBTW; I do not need all 1700 lines of code, but I did offer to look at it for you. You have declined numerous times... and that's ok.. but, you need to make a small script that can duplicate the problem before I can help you... NO MORE GUESSING!8)Check your PM... And I woulda gave the entire script, but I didn't realize you were asking for that. I just didn't think you would want to help ME by sorting through that many lines of coding >< Link to comment Share on other sites More sharing options...
Valuater Posted August 3, 2009 Share Posted August 3, 2009 (edited) 1st...You need to do this.... ... Yes, do this first... in order because your script is missing this orderly format and may crash because of it. expandcollapse popup; Script Format Demonstration. ; 1. Place required include files. ; 2. Set Autoit options, as needed. ; 3. Declare Variables. ; 4. Set Desired Hot Keys. ; 5. Create the GUI. ; 6. Display the GUI. ; 7. Set/Update control information. ; 8. Set the Tray Menu ; 9. Start the Loop, and "Listen" for a message. ; 10. Create the Functions. ; here is an Example ; 1. Includes #include <GuiConstants.au3> #include <String.au3> ; 2. Autoit Options Opt("GUICloseOnESC", 1) ;1 = ESC closes script, 0 = ESC won't close. opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. opt("TrayOnEventMode", 1) ;TraySetClick (16); right click ; 3. Declare Variables use, Dim, Global or Local. Dim $Text, $Cloudy = 1 ; see help for more info. ; 4. Set Hot Keys HotKeySet("{F1}", "About_GUI") ; when F1 is pressed, goto function "About_GUI". ; 5. Create the GUI $Window = GUICreate("My Weather Program") $combo = GUICtrlCreateCombo("", 120, 50, 150, 20) $button = GUICtrlCreateButton("Press here for Daily Weather Report", 100, 300, 200, 40) ; 6. Display the GUI GUISetState() ; 7. Set the control information ; this will split the string called $days, by each comma. $days = StringSplit("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday", ",") ; the return is an array $days[0] is 7, the total ; $days[1] contains "Sunday" ... $days[7] contains "Saturday" ; this will use a for/next loop to set the $combo information with the $days. For $x = 1 to $days[0] GUICtrlSetData( $combo, $days[$x]) Next ; 8. Set the tray menu $About_tray = TrayCreateItem ("About Weather") TrayItemSetOnEvent (-1, "About_GUI") TrayCreateItem ("") $exit_tray = TrayCreateItem ("Exit Weather") TrayItemSetOnEvent (-1, "Set_Exit") TraySetState () ; 9. Start the loop While 1 ; "Listen" for the message $message = GUIGetMsg() If $message = $GUI_EVENT_CLOSE Then Set_Exit() If $message = $button Then ; read the selected day in the combo $Text = GUICtrlRead( $combo ) ; call the function with the info Day_Function($Text) EndIf WEnd ; 10. Create the Functions Func Day_Function($Text) If $Text = "" Then Return ; randomly choose amount of rain $rain = Random(5, 100, 1) ; call another function for clouds Cloud_Function() If $Cloudy = 1 Then $Clouds = "Cloudy" Else $Clouds = "Clear" EndIf ; show the weather information. MsgBox(64, "Your Weather","On " & $Text & " You can expect, " & @CRLF & $Clouds & " skies in the afternoon and evening " & @CRLF & _ "The chance of rain is approximately " & $rain & " percent ") EndFunc Func Cloud_Function() If $Cloudy = 1 Then $Cloudy = 2 ; leave this function now Return EndIf If $Cloudy = 2 Then $Cloudy = 1 Return EndIf EndFunc Func About_GUI() MsgBox(64, "Welcome!", " this is your Weather Service ") EndFunc Func Set_Exit() MsgBox(0,"","Good-Bye!",1) Exit EndFunc ; All of these functions are UDF's, User Defined Functions ; When you have completed a Script use Tidy under "Tools" above to "clean" it up. ; Then make a comment at the top, like this #cs =============================================================================== *AutoIt 1-2-3 ver 1.0.1 - 02.01.2006 Autor: Valuater E-mail: XPCleanMenu@aol.com Language: English OSystem: Windows Xp Requirements: Legal copy of Microsoft Windows Xp Construction: AutoIt 3.1.1+, SciTE 1.64 Features: Automated Program, Reads Text, Runs Scripts, etc - Use = Tutorials, Help Files, Installers, Presentations, etc - ... Thanks to all, Enjoy... #ce =============================================================================== #2 You are not completing "Create" process for the GUI's Place this after the ones you do not want to show right away GUISetState(@SW_HIDE, $GUI_NAME) BEFORE starting the next GUI Create() #3 It seems to me that you are reading ( or setting the Value ) of $Label8 like this $userL = 8 OFF() ... and.... $currentmoney = GUICtrlRead($Label8) If $msg = $GUI_EVENT_CLOSE Then OFF() #3A Let me suggest this... replace the function with Func OFF($Info) If $userL = "8" Then TCPsend ($Socket, '<DC>^') Else TCPsend ($Socket, '<DC1>^' & $userL & "^money^" & $Info) EndIf Sleep(2000) TCPShutdown () Exit EndFunc Do this BEFORE the OFF() Function $Var = GUICtrlRead($Label8) ... The call the function like this... OFF($Var) #4 This will not work because you are not using GUIGetMsg() in the do/until loop Do $g = GUICtrlRead($inputg) $g1 = GUICtrlRead($inputg1) $g2 = GUICtrlRead($inputg2) $g3 = GUICtrlRead($inputg3) Sleep(1000) If $msg = $GUI_EVENT_CLOSE Then; This will not work ... remove OFF() ; remove EndIF; remove Until 8) Edited August 3, 2009 by Valuater Link to comment Share on other sites More sharing options...
UnknownWarrior Posted August 3, 2009 Author Share Posted August 3, 2009 (edited) Ok, I did all of that, but didn't test it yet because... When the Opt is called it doesn't have the $Var = GUICtrlRead($Label8) in it... So Func OFF($Info) wouldn't have that info...... Right? (This meaning that the user shuts the program down by right clicking the tooltray icon and clicking 'Exit') Edit: I also have too many places where it could shut off from... It gave me an error when I hi the red X to close the program saying $Info not declared... >< (When I had correctly done OFF($Var) ) Edited August 3, 2009 by UnknownWarrior 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