Use a Stat Monitor to notify Users
If something happens in your application, you should notify your users. So they don't think that the app is stuck. Because if you don't do that, people will cancel or close the app. So you should add some notifications into your app, so people know what's going on.
Hi, good morning everyone. Greetings from Germany. I hope you're all doing well and that you're healthy and not hit by that crazy virus thing that is currently going on. And making life a little bit different for all of us, so stay strong. I think all of us who can work online and make money online are currently in a really good position. We can leverage technology and the internet to still do our business and make some money. Although, I think this is a good thing.
What I would like to do in the next couple of days, weeks, months, I already announced that a while ago that I wanted to create a new series of how I code videos. I will just randomly choose websites and probably just use that random button on Google, or you guys can also send me some ideas from websites that you would like to see.
The goal here is to just show you some stuff and maybe you get some little hints here and there. I will keep those videos to 15 minutes. Let's run that little timer here so that I can keep track of that stuff a little bit. I will explain certain things, and maybe I already talked about couple of those ideas and settings, but not everyone is watching every video. Not everyone watched all the tutorials, so maybe this is always a good reminder.
Always have that licensing command right in your bot. You have to run that with version two. It has to execute at least once, right? You guys know that. It doesn't matter if you're in your bot studio or are in a compiled bot. It always has to execute at least once. And you also only should execute it once, because otherwise it will always contact the license server, which is additional delay and overhead and all that stuff. So, best thing is to put that on launch or on load, and have that with the bot loaded setting and then you're good to go. Of course, put your activation key in here.
We will just use Google Chrome with the portable browser option, ensure that both settings are identical. Each version of X-Browser plugin always comes with the tested and supported portable browser version and Firefox version. If you execute that the first time, or you upgrade to a newer X-Browser version that brings a new browser, that command can take awhile to launch. One idea, and maybe that's a good thing to start here in this how to code tutorial, how to do a status bar update and notification.
Here's the thing. Let's say we have a UI stat monitor, and let's call it info. And we give it variable. Now what you could do, you could of course specify a text here before you execute the launcher command, “Please wait, Launching Browser.” After you're done, you just remove that text. This is the most simple thing. That way, people will see a message and then after it's loaded, that message will go away. The problem with that… Well not problem, but you could make that a little nicer, that you actually have something that is moving. And then it stops after the browser is loaded.
So how can you do that? You create a defined command, MyStatusMessage, and you put that stuff into its own thread, so that it can run in parallel to the other stuff that is running. And we have a loop, loop while, and comparison, stopstatus, does not equal true. What else we will do… Actually not yet, it's not done. Now let's remove that kind of stuff. I will explain it while I code it. What we will do, here we have a set command where we have that variable stopstatus false. Then we run that thread and then it will loop until stopstatus is not longer true. Just a second.
Then we will have that status message. What was the variable we used? Info, right? This one, we copy a couple of times and then we have a wait in between. After each one we have a little wait, and you just changed the message a little bit. So we have two and we have three, and so on. See where I'm going? We are changing the message here so that it looks like something is moving along. You can do that your own way, of course, and have that the way you want it. Let's change that check so that it matches the stuff you want to do. As long as stop status is false, it will loop in a separate thread.
Now what we have to do of course, is after this is done, after it's launched, we have to set this to true. That way that thread loop will end, and we can have another status update here after that loop just to, “Browser fully loaded.” So that you see that this executed. Now we have to launch that MyStatusMessage before we execute the browser. Let's just clear the variable so that it's fresh and new. That way, we have that stat monitor, we launch that updater process in that MyStatusMessage define, it sets the stop variable to false. As long as that stop status variable equals false, that thing will loop. It will change the text of the status variable info. It has a pause in between of half a second.
So you just change the text a little bit, and you could also rotate the text even more so that it's more obvious. Like, “Loading Browser, Please wait.” That way, it's even more obvious. Let's see what happens. “Please wait… Loading. Loading Browser, Please wait.” It's updating the status info, and after it's done, “Browser fully loaded.” Here you have your status update thing for the browser. We have that in a separate defined that you can always use, and you just add that launcher, MyStatusMessage, defined before the launcher. And you change that stop variable after the launcher command, and then you're good to go.
I think I'll make a cut here and then compile that video, because this is kind of interesting as standalone thing. Then I will do to the actual how to code thing on the website in the next video, and we will take it from there. See you soon.