Using Tasker, AutoInput, and USSD codes you can easily grab this data and manipulate it however you want. In my tutorial, I will be grabbing the minutes/data used from T-Mobile USA and incorporate it into a Zooper Widget.
- AutoInput to query the text on the toast input.
- USSD codes you can run that will provide you with the remaining minutes/data left in your account. You will have to look these up for your carrier.
- OPTIONAL: Zooper Widget, for displaying the minutes/data in the form of a progress bar.
I'm not defining any contexts here for you, but you can set these tasks up to run on whatever trigger you want. For instance, for me I have these two tasks run every night at 1am to update my Zooper Widgets.
- Run the USSD code you want to automatically grab at least one time manually in the phone app. Take a screenshot or write down the text used for reference. It's less than 160 chars since it's an SMS, so don't complain about having to write (You could use Flash action to show what the output is, that's up to you though)
- Create a task and call it "Call Usage."
- Phone --> Call. Set the Number to the USSD code that will return how many minutes you have left. For me on T-Mobile USA this is #646#. Check "Auto Dial."
- Plugin --> AutoInput UI Query. Check "Only Visible" and go down to "Text" and put in some unique, recurring text from the USSD code pop-up that AutoInput will wait to see before querying the screen. For me, I used "Addl minutes are charged" because I'm on a pre-paid plan.
- Plugin --> AutoInput Action. This one is a bit wonky to set up, but basically you'll want to have AutoInput ready to record your tap input while the USSD is already on screen. To do this I would recommend setting a wait function before running the USSD code, then quickly going to AutoInput and starting the record input function. Once the USSD code is on screen, you can record the input. Optionally, you can use an input tap to have it tap anywhere on the screen to dismiss it.
- Variables --> Variable Split. Split %aitext(1) in an attempt to isolate the amount of remaining minutes you have. For me, I set the Splitter to "You have"
- Variables --> Variable Split. Split %aitext12 to fully isolate the number value of the remaining minutes. Here, I did "included minutes" as the Splitter.
- Variables --> Variable Set. Set Name to %calltotal and set it To your total minutes minur %aitext121. Check "Do Math". This will determine how many minutes you have actually used.
- (OPTIONAL): Plugin --> Zooper Widget Pro Variable. Set #TCALLUSAGE# (which should be written as CALLUSAGE within the ZW configuration, but is presented to ZW as variable #TCALLUSAGE#) to %calltotal. Now you can display this variable as a part of any Zooper Widget you like!
- Create a new task called "Data Usage."
- Phone --> Call. Number is the USSD code that tells you the data remaining in your plan. For me on T-Mobile USA it's #932#. Again, set it to "Auto Dial."
- Plugin --> AutoInput UI Query. Again, like before, click on "Only Visible" and for Text set something unique from the USSD code pop-up that will make AutoInput query the screen when the text pops up.
- Plugin --> AutoInput Action. Do the same as before, hell, you can even copy/paste the same action from the previous task to dismiss the pop-up!
- Variables --> Variable Split. Split %aitext(1) to isolate the amount of data used. For me, I put "You have used" as the splitter.
- Variables --> Variable Split. Split %aitext12 using the splitter to separate the number and its data unit. For me, I set it to "MB"
- Variables --> Variable Set. Set Name to %datamb and set it to ceil(%aitext121). This will round-up the data usage to the nearest whole number, so it will display properly in Zooper Widget.
- (OPTIONAL): Plugin --> Zooper Widget Pro Variable. Set #TDATAUSAGE# to %datamb. Same idea as before.
Finally, here's what my Zooper Widget looks like (along with my config). My usage had just reset recently so you can't really see much of the progress, though: