Scripting Custom Messages to other objects?
from
WinCustomize Forums
I have an edit control window. I have a button. The button runs a script that say pings a machine in the network. It redirects the output of that command to a text file.
Now currently I have a 2nd button. When I click on that it sends a custom state (refreshresults) to the editbox (resultsbox)
So I click on one button to execute the script and pipe it to a file. Another button reads the file and displays it in the editbox.
What I want to do is have it so that when I click on the execute button IT reads the text file and sends the message to the edit box.
Now the obvious way to do this is what I have set up: On mouse down the script executes. On mouse up, or Command Executed it sends the message to the editbox.
This does not seem to work right, however.
Sometimes the script takes time to execute. So the "command Executed" event has ocurred. However, the script itself is still running, which means that it has not written to the file yet, so you dump nothing to the edit box.
I tried putting a Object.Sleep(5000) in the On_ScriptExit subroutine, but that seemns to do nothing really...
If I have several scripts they all write to the same results file.
So If I run ping 10.10.10.10 I get nothing dumped to the screen. I hit the refresh button and I then get the results in the editbox.
But lets say I didn't hit the refresh button. I execute the ping. Nothing in text/editbox.
Then I execute netstat -a
What happens is that when I click on the execute script button, it sends the message to the EditBox script to read in the text file. However, since netstat -a had not yet written to the text file, what gets dumped to the screen are the results from the PREVIOUSLY executed commands (ping in this case).
Refresh button works fine. I just want the execute button to wait a decent amount of time after it runs the script, and before it sends the resultsrefresh message to the resultsbox object. Again, putting a sleep in the exit routine doesn't do anything. Does the "Command Executed" state ocurr BEFORE the exit subroutine? That would explain my results.
The best solution here is for me to send the message in the script rather than via the properties. could I somehow do this ins the exit sub
Object.Sleep(5000)
DesktopX.ScriptObject("ResultsBox").State = "RefreshResults"
???
What is the right syntax? I get an error when I put in that code.
I also tried
Now currently I have a 2nd button. When I click on that it sends a custom state (refreshresults) to the editbox (resultsbox)
So I click on one button to execute the script and pipe it to a file. Another button reads the file and displays it in the editbox.
What I want to do is have it so that when I click on the execute button IT reads the text file and sends the message to the edit box.
Now the obvious way to do this is what I have set up: On mouse down the script executes. On mouse up, or Command Executed it sends the message to the editbox.
This does not seem to work right, however.
Sometimes the script takes time to execute. So the "command Executed" event has ocurred. However, the script itself is still running, which means that it has not written to the file yet, so you dump nothing to the edit box.
I tried putting a Object.Sleep(5000) in the On_ScriptExit subroutine, but that seemns to do nothing really...
If I have several scripts they all write to the same results file.
So If I run ping 10.10.10.10 I get nothing dumped to the screen. I hit the refresh button and I then get the results in the editbox.
But lets say I didn't hit the refresh button. I execute the ping. Nothing in text/editbox.
Then I execute netstat -a
What happens is that when I click on the execute script button, it sends the message to the EditBox script to read in the text file. However, since netstat -a had not yet written to the text file, what gets dumped to the screen are the results from the PREVIOUSLY executed commands (ping in this case).
Refresh button works fine. I just want the execute button to wait a decent amount of time after it runs the script, and before it sends the resultsrefresh message to the resultsbox object. Again, putting a sleep in the exit routine doesn't do anything. Does the "Command Executed" state ocurr BEFORE the exit subroutine? That would explain my results.
The best solution here is for me to send the message in the script rather than via the properties. could I somehow do this ins the exit sub
Object.Sleep(5000)
DesktopX.ScriptObject("ResultsBox").State = "RefreshResults"
???
What is the right syntax? I get an error when I put in that code.
I also tried
DesktopX.ScriptObject("ResultsBox").StatePreempt = "RefreshResults"
That didn't seem to change anything. Again this is in the script for the Execute button, sending a message to the ResultsBox object.
Thanks,
Brain21