Author Topic: Call another command and return  (Read 3522 times)

0 Members and 1 Guest are viewing this topic.

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Call another command and return
« on: May 11, 2015, 11:30:13 AM »
Can VC jump like Event Ghost? I have a RoboB command I'm working on that requires logging in to the server (mytotalconnectcomfort.com) and have everything working perfectly except the page expires after a certain amount of time and defaults back to the login page.

I can eliminate that by having each command login, run the commands and log out. When I started though (before I knew it timed out), I created a command that creates the browser session and logs in and the other commands just select that browser session first. If I could tell each command to "jump" to that login command then "return" when it's done it would save a lot of time in creating each command to duplicate that login session as well as if I needed to change the password for some reason I would only have to change it in one place.

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: Call another command and return
« Reply #1 on: May 11, 2015, 11:45:41 AM »
You can use "VC.TriggerEvent" to jump to other macros. I did a quick test and it seems like VC jumps to the macro you trigger and after executing continues with the first macro.

Wiki:
http://voxcommando.com/mediawiki/index.php?title=Actions#TriggerEvent
« Last Edit: May 11, 2015, 11:49:51 AM by Dave »

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Re: Call another command and return
« Reply #2 on: May 11, 2015, 11:53:11 AM »
Interesting, I knew you could trigger an event, but I did not know the current macro paused until it was done. I'll give that a shot.

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Re: Call another command and return
« Reply #3 on: May 11, 2015, 12:04:46 PM »
Unfortunately the loading page can be instant, or take a few seconds and once the login macro is done it tries to click on items that are not there yet. If I could have a macro pause until an event is triggered that would also work because it triggers an event when the page it done loading. I can't have that event trigger the actual macro though because it would cross various macros to raise or lower temp, turn fan on or off, switch from heat to cool, etc.

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: Call another command and return
« Reply #4 on: May 11, 2015, 12:51:38 PM »
You could of course make your second macro pause a predefined amount of time (e.g. 5 seconds) with "VC.Pause". Hopefully the loading is done after this time.

If you want to use the "page loaded trigger" it is much more tricky. I will try to explain what you could try (probably not the best way to do it):
1. create a third macro that is executed when the page is loaded. the macro should set a a variable (e.g. "loaded") to true.
2. edit your first macro so that variable "loaded" is set to false and a second variable (e.g. "first_loop") is set to true.
3. your second macro now needs two if-conditions: if the first is true (first_loop = true), set first_loop to false, set loaded to false, then do whatever your macro did before.
4. if the second condition is true (loaded = true) stop the macro using "VC.StopMacro"
5. now activate looping for this macro (e.g. max loops = 100 with delay of 100 ms)

Try at own risk, I'm not 100% sure it will work :bonk

p.s. with this method the first macro will continue and try to click even if the page is not loaded but the second macro did all its loops. you could add an if-block right after the "TriggerEvent"-command, which controlls the "loaded" variable and stops the macro (and maybe reports that the site could not be loaded by tts" if loaded = false.

p.p.s. I hope you can understand my explanation! :biglaugh
« Last Edit: May 11, 2015, 12:59:41 PM by Dave »

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Call another command and return
« Reply #5 on: May 11, 2015, 02:43:25 PM »
in robob you can wait for the page to load (Robob.wait) ... then perform the action you want.
or you can use the RoboB.DocComplete (check wiki) to trigger a macro ... check the netflix command I shared a while ago ... I think it demonstrate how to use this to make a decision based on which page is loaded (this can be used to detected that you got logged out)
When Voice command gets tough, use hand gestures

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Re: Call another command and return
« Reply #6 on: May 11, 2015, 07:31:00 PM »
Tried a quick fix when I ran home for lunch that I think is working so far. I set up the main command that loads and logs in to the site to trigger itself when it's done loading. The macro itself checks the URL for the word timeout. If it is there it logs in. If not it does nothing. (for now it has an osd that says you're already logged in.) when the page times out and reloads, it will log right back in.

It may not be the most elegant solution but for now it works. Now for the new issue that they just put up a maintenance warning for tonight. No big deal except it breaks my scraping for the current and set temps. I think I can do an if statement though that if the maintenance warning is there load a different tag.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Call another command and return
« Reply #7 on: May 11, 2015, 10:23:06 PM »
Check this post might help keeping the command simple and avoid multiple ifs
http://voxcommando.com/forum/index.php?topic=2091.0
When Voice command gets tough, use hand gestures