DNnlee Posted February 12, 2009 Share Posted February 12, 2009 (edited) i have a script that runs as a bot, and i wanted to keep track of what's happening on the GUI. so i want to run the function called Labels() to display what's happening while the Bot keeps going. it runs something like this: GUICreate("MY GUI", 365, 600, 656, 0); creates a box GUISetState(@SW_SHOW) A = 0 Do B = 0 do C = 0 while C < 10 Sleep(1000) mouseClick ( 20,20) C = C + 1 wend SomeFunction() $B = B + 1 until B = 10 $A = A+1 until A = 10 Func Labels() $Label_A= GUICtrlCreateLabel("A: " & $A, 25, 20) $Label_B= GUICtrlCreateLabel("B: " & $B, 25, 100) $Label_C= GUICtrlCreateLabel("C: " & $C, 25, 120) $Label_Status = GUICtrlCreateLabel("Status: " & $Status, 25, 140) EndFunc anyone know of a good way to make a GUI display variable values, while the script does something else like running a bot? edit: well my program is obviously more complex than that, but the main thing is that i wanted the labels function to run often, without sticking Labels() into every part of my program. I wanted this because i wanted to track what the program is doing at the exact moment, such as $Status. Edited February 12, 2009 by DNnlee Link to comment Share on other sites More sharing options...
Spiff59 Posted February 12, 2009 Share Posted February 12, 2009 (edited) Sounds like you'll need to launch your bot as a child process, or split your code into two separate scripts and run them concurrently. Then you have to decide what method of communication between the two will work best for you. Edit: I may be a little confused at what you're trying to do. You want your bot to run independantly, and have another script monitor it's progress, or, you just want to periodically allocate a slice of time where the bot pauses it's activities, spits out some status info, then goes it's merry way. You could probably do either... Edited February 12, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
DNnlee Posted February 12, 2009 Author Share Posted February 12, 2009 Sounds like you'll need to launch your bot as a child process, or split your code into two separate scripts and run them concurrently. Then you have to decide what method of communication between the two will work best for you.so if i split them into 2 separate scripts, does the variable of one script carry on to the the other script?i'm thinking of GUI script and BOT scriptso can the GUI read what is the value of $A from the BOT script? Link to comment Share on other sites More sharing options...
Spiff59 Posted February 12, 2009 Share Posted February 12, 2009 (edited) They can't directly reference each others variables, but there are a bunch of methods of passing data. I have a couple subprograms that pass data between each other, but the calling program basically pauses until the subprogram is complete. So, you're on a path I haven't travelled before. I can think of some possibilities, but maybe someone who has more experience will pipe in with some suggestions. I'm would think some pertinent questions to decide the best method are: How much data do you need to pass, how often do you need to pass the data, and do you need only one-way. or bidirectional. communication. typo Edited February 12, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
Authenticity Posted February 12, 2009 Share Posted February 12, 2009 There is quite same example in the directory "@ProgramFilesDir\AutoIt3\Examples\GUI\Advanced" called _NamedPipes_Client and _NamedPipes_Server, both might be your solution. Another approach would be to use volatile environment variables. Link to comment Share on other sites More sharing options...
DNnlee Posted February 12, 2009 Author Share Posted February 12, 2009 (edited) They can't directly reference each others variables, but there are a bunch of methods of pssing data. I have a couple subprograms that pass data between each other, but the calling program basically pauses until the subprogram is complete. So, you're on a path I haven't traveled before. I can think of some possibilities, but maybe someone who has more experience will pipe in with some suggestions. I'm would think some pertinent questions to decide the best method are: How much data do you need to pass, how often do you need to pass the data, and do you need only one-way. or bidirectional. comunication.only one way, from the bot to the GUI, as the GUI's only function is to display whatever is going onall that's needed is for the GUI to read the $A $B $Status variables within the BOT Script, every 10-30 seconds or soThere is quite same example in the directory "@ProgramFilesDir\AutoIt3\Examples\GUI\Advanced" called _NamedPipes_Client and _NamedPipes_Server, both might be your solution.Another approach would be to use volatile environment variables.thx will look into it Edited February 12, 2009 by DNnlee Link to comment Share on other sites More sharing options...
Spiff59 Posted February 12, 2009 Share Posted February 12, 2009 (edited) Your communications requirements are not very demanding, I would lean to the simple route and go with Authenticity's second method and just have your bot periodically do an EnvSet, and your monitor GUI loop doing EnvGet's. Same thing might work with ClipPut and ClipGet (or a million other ways), but using the environment variables as he suggested sounds good to me. I would avoid any temptation to just write the data to an ini or text file, then read it back. There's no reason to involve slow mechanical hardware in your process. typo (as always0 Edited February 12, 2009 by Spiff59 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