Accessing text in the main status bar
Author: kazuna
Creation Date: 5/28/2010 10:35 AM
profile picture

kazuna

#1
I'm seeing an issue where "Guaranteed Alerts" isn't often available until I restart WLP.
I would like to identify it programmatically either via AutoIt or the strategy code.
I tried AutoIt but no success and apparently AutoIt cannot extract the text from the main status bar "StatusStrip1".
Is there a way I access the status strip in my strategy code through .NET class?
I'm thinking to popup a dialog and sound a warning when my strategy code saw "Guaranteed Alerts are not available" in the status bar so that I can notice it immediately and restart WLP.
profile picture

Eugene

#2
Here you go. Pure .NET, nothing but Reflection.

1. First we set up a class that is searching for the MainForm of WLP/WLD.
2. Then we traverse through all its controls (the Controls collection).
3. We need to find the status strip, we know it's name can contain something like "status" in it.
4. Having found it, we get the ToolStip object.
5. Finally, we want to access the status message (or its absense - this is what you care about) which is the first item of the Items collection.

CODE:
Please log in to see this code.

profile picture

Cone

#3
Excellent Eugene. This would be a good add to Community.Components for Fidelity customers. The method could take a status frame item number and a string to search for within that frame, and, if it matches (Contains), it could play a sound file for precisely the purpose kazuna described.
profile picture

kazuna

#4
The code works great! Thank you Eugene!
profile picture

kazuna

#5
What is the message precisely when "Guaranteed Alerts" isn't available?

I think it was something like this:
QUOTE:
Guaranteed Alerts are not available. ....30 seconds....


I would like to know the message precisely (capitals and spaces) in order to compare the string in the code.

I first tried to compare the string with "Guaranteed Alerts are available." but the message isn't available for the first few seconds while the strategy code first runs right after WLP started. So I would like to check the message to see if it explicitly says that GA isn't available but I haven't seen the message for a little while.

Or is there a way to see the message? Neither disconnecting the network cable nor disconnecting from Fidelity Server application doesn't let the GA to be unavailable.
profile picture

Eugene

#6
Why complicate things? Use String.Length > x, where x is the string length of the normal string.
profile picture

kazuna

#7
Because I want to ensure that it is the message GA not available but anything else.
The string length is not sufficient to determine if it is really GA not available message.
For example, "Strategy Status Message (click to clear)" message which is longer than the normal message "Guaranteed Alerts are available." but probably? shorter than GA not available message.
What if there is yet other message which I'm not aware suddenly pops up in the future?

At least I would like to confirm if the first string is "Guaranteed Alerts are not available." which I just cannot confirm myself right now.
profile picture

Cone

#8
Serves the purpose?
CODE:
Please log in to see this code.
However, this might be going a long way for not much gain. There's no guarantee that WLP can detect when guaranteed Alerts are not available.
profile picture

kazuna

#9
QUOTE:
There's no guarantee that WLP can detect when guaranteed Alerts are not available.
The reverse is also true? There is no guarantee that WLP can detect when Guaranteed Alerts are available?

I'm wondering if you are saying that I should look for the "are available" message not the "are not available" message. If that is the case, I think I would wait at least for one bar before the "are available" message to appear.
profile picture

kazuna

#10
I implemented the code to look for either "are available" and "are not available" message.
In case if neither message appears, the code retries by looking at 1 sec interval for 30 secs, then treat if it was GA not available.

I think it will reasonably handle all the possible scenarios.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).