Author Topic: Why does only half of this command work?  (Read 4164 times)

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Why does only half of this command work?
« on: December 26, 2016, 04:53:24 PM »
OK, I'm having a problem. Shouldn't VA just go down the list of commands, and trigger each?

Here's the whole command.

Code: [Select]
Set integer [Y] value to the converted value of {MOUSESCREENY}
Set integer [Max] value to 30
Begin Text Compare : [{EXP:'{WINDOWTITLEUNDERMOUSE}' LIKE '*Edit Style*' OR '{WINDOWTITLEUNDERMOUSE}' LIKE '*Developer Tools*'}] Does Not Equal '1'
    Begin Text Compare : [{EXP: {INT:Y} > {INT:Max} }] Does Not Equal '1'
        Write '[Blue] Working' to log
        Execute command, 'Balabolka Sound Control' (and wait until it completes)
    End Condition - Exit when condition met
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Contains 'Edit Style'
    Quick Input, ' {'
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Contains 'Developer Tools'
    Quick Input, ' {'
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Does Not Contain 'Edit Style'
    Write '[Blue] Open Page in New Browser Window' to log
    Execute command, 'Open Page;Open;Opened'
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Does Not Contain 'Developer Tools'
    Write '[Blue] Open Page in New Browser Window' to log
    Execute command, 'Open Page;Open;Opened'
End Condition - Exit when condition met

This part works fine, when it's at the top of the command.

Code: [Select]
Set integer [Y] value to the converted value of {MOUSESCREENY}
Set integer [Max] value to 30
Begin Text Compare : [{EXP:'{WINDOWTITLEUNDERMOUSE}' LIKE '*Edit Style*' OR '{WINDOWTITLEUNDERMOUSE}' LIKE '*Developer Tools*'}] Does Not Equal '1'
    Begin Text Compare : [{EXP: {INT:Y} > {INT:Max} }] Does Not Equal '1'
        Write '[Blue] Working' to log
        Execute command, 'Balabolka Sound Control' (and wait until it completes)
    End Condition - Exit when condition met
End Condition - Exit when condition met

But the rest seems to no long work.

Now if I move that part down to the bottom of them command list. Everything else works, and it no longer works.

Code: [Select]
Set integer [Y] value to the converted value of {MOUSESCREENY}
Set integer [Max] value to 30
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Contains 'Edit Style'
    Quick Input, ' {'
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Contains 'Developer Tools'
    Quick Input, ' {'
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Does Not Contain 'Edit Style'
    Write '[Blue] Open Page in New Browser Window' to log
    Execute command, 'Open Page;Open;Opened'
End Condition - Exit when condition met
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Does Not Contain 'Developer Tools'
    Write '[Blue] Open Page in New Browser Window' to log
    Execute command, 'Open Page;Open;Opened'
End Condition - Exit when condition met
Begin Text Compare : [{EXP:'{WINDOWTITLEUNDERMOUSE}' LIKE '*Edit Style*' OR '{WINDOWTITLEUNDERMOUSE}' LIKE '*Developer Tools*'}] Does Not Equal '1'
    Begin Text Compare : [{EXP: {INT:Y} > {INT:Max} }] Does Not Equal '1'
        Write '[Blue] Working' to log
        Execute command, 'Balabolka Sound Control' (and wait until it completes)
    End Condition - Exit when condition met
End Condition - Exit when condition met

Is there a limit to how big a command can be? Or can one part of the command overrule the rest? Is there a way to write this command where all commands are possible?

I've run into stuff like this before, but I just used alternate ways around the problem. But I figured, maybe someone with more knowledge than me could explain what I'm doing wrong, and how to overcome my problem. I just don't have any spare keys. :)

Thanks for the help!


Gangrel

  • Caffeine Fulled Mod
  • Global Moderator
  • Full Member
  • *****
  • Posts: 216
  • BORK FNORK BORD
Re: Why does only half of this command work?
« Reply #1 on: December 26, 2016, 05:11:09 PM »
Just a quick look over, so Pfeil wil correct me more than likely, but you are exiting the command as soon as it completes one part of the command, which is working as intended.

Is the command meant to be run continuously?

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Re: Why does only half of this command work?
« Reply #2 on: December 26, 2016, 06:03:08 PM »
No, it's not meant to run continuously. Only one of the commands should meet the requirement, and then terminate the whole thing.

I just realized though, there is no way to do that, at least not easily anyway. Because I have 2 commands that are meeting the requirements. So, only the top one is triggered.

I wanted the sound control one to be universal. But I can't seem to separate 2 of the command good enough for that.

I realized this after posting it. I seem to answer my own questions most of the time, while creating a post, and then not having to finish the post, because I figured out the problem. This time, I figured it out afterwards.

I was able to move the command to share another key, that wouldn't have the conflicted issue.

Thanks for trying to help!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: Why does only half of this command work?
« Reply #3 on: December 26, 2016, 06:45:20 PM »
you are exiting the command as soon as it completes one part of the command, which is working as intended.
I agree.

Shouldn't VA just go down the list of commands, and trigger each?
As Gangrel has stated, every single conditional block ends with "Exit when condition met", which is exactly what VoiceAttack will do if either condition returns "1", and why your command simply stops.

You control flow is very confusing, but if I'm interpreting it correctly, here's how your command could go:
Code: [Select]
Set integer [Max] value to 30
Begin Text Compare : [{EXP:'{WINDOWTITLEUNDERMOUSE}' LIKE '*Edit Style*' OR '{WINDOWTITLEUNDERMOUSE}' LIKE '*Developer Tools*'}] Equals '1'
    Begin Text Compare : [{EXP: ({MOUSESCREENY} > {INT:Max}) AND ('{ACTIVEWINDOWTITLE}' LIKE '*Edit Style*' OR '{ACTIVEWINDOWTITLE}' LIKE '*Developer Tools*')}] Equals '1'
        Quick Input, ' {'
    Else
        Write '[Blue] Working' to log
        Execute command, 'Balabolka Sound Control'
    End Condition
Else
    Write '[Blue] Open Page in New Browser Window' to log
    Execute command, 'Open Page;Open;Opened'
End Condition
This way:
  • If the window title contains either "Edit Style" or "Developer Tools", VoiceAttack checks if the mouse cursor is below 30 pixels from the top of the screen
  • If it is low enough, it also checks whether the title of the window that has focus(the active window) contains either "Edit Style" or "Developer Tools"
  • If it does, it will write " {" to the active window
  • If it does not contain that text, or the cursor is not low enough, the command "Balabolka Sound Control" is executed, and the execution is completed(the command stops running)
  • If in the first place the window title under the cursor did not contain either "Edit Style" or "Developer Tools", the command "Open Page;Open;Opened"
You may note that neither of the "Execute command" actions include the "and wait until it completes" parameter, this is because both are at the end of the command's execution and waiting for the called command is unnecessary.
Likewise, neither of the "End Condition" actions include the "Exit when condition met" parameter, as both are at the natural end of the command's execution, which makes explicitly instructing the command to exit redundant.

If it's not how you want the command to go, that's kind of the point: You're not instructing the computer(through VoiceAttack) to execute the sequence of events in a way that is consistent with your expectations, so it cannot meet them(and by extension, nor can I).


I don't mean this in a condescending way, but you should really consider studying basic control flow(beginning with simpler forms like "IF" and "ELSE"). It's knowledge common to literally all programming languages(because it's how your computer works internally), and it will help you understand how to make things work as you want them to.

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Re: Why does only half of this command work?
« Reply #4 on: December 26, 2016, 07:47:04 PM »
I took what you gave me, and adjusted it, to get the out come I needed.

Code: [Select]
Set integer [Max] value to 30
Begin Text Compare : [{EXP:'{WINDOWTITLEUNDERMOUSE}' LIKE '*Edit Style*' OR '{WINDOWTITLEUNDERMOUSE}' LIKE '*Developer Tools*'}] Contains '1'
    Quick Input, ' {'
Else If Text Compare : [{EXP: {MOUSESCREENY} < {INT:Max} }] Equals '1'
    Execute command, 'Balabolka Sound Control' (and wait until it completes)
Else
    Execute command, 'Open Page;Open;Opened'
    Write '[Blue] Open Page in New Browser Window' to log
End Condition

You also gave me a new idea, and now this seems to work as I wish it to.

I know I need to studying basic control flow, I just don't know what I should study. Meaning what's a good book that would help with using VA.

I do this all by Trial and Error, and learning from You, and Gary's responses, among a few others. I learn something, and try to make old commands better all the time.

I had tried something like this before, but kept getting a Exp Error. Apparently, I didn't realize I need () around each portion.

{EXP: ({MOUSESCREENY} > {INT:Max}) AND ('{ACTIVEWINDOWTITLE}' LIKE '*Edit Style*' OR '{ACTIVEWINDOWTITLE}' LIKE '*Developer Tools*')}

I've even tried something similar to my final out come, and it didn't work. It's very frustrating when you have no foundation in programming. I've tried reading books, but they always seem to take for granted that you know more than they're trying to teach you. Even when it's a beginners guide. It's like I'm coming into a movie have way through, and can't seem to understand what's going on. Or say like, they give you a list of ingredients, but don't tell you how your suppose to really use them. It's very frustrating!

Thanks for the help again. I always learn a great deal from you.

« Last Edit: December 27, 2016, 06:15:46 AM by iceblast »

Gangrel

  • Caffeine Fulled Mod
  • Global Moderator
  • Full Member
  • *****
  • Posts: 216
  • BORK FNORK BORD
Re: Why does only half of this command work?
« Reply #5 on: December 27, 2016, 03:19:25 AM »
I find the "easiest" method to working stuff out is using pen and paper to draw a flow chart diagram, and then work on each part. It isn't high tech, but it at least helps you visualise how your code is meant to work.

Each step of the flow chart is a command/function that you need to do. If/Else choices are where you split, and reaching the bottom of the command is where the "exit command" takes you.

Side note: Don't be afraid of making a step in the flow chart its *own* flow chart.

Side note 2: If you find that you are making a command too big, break that command apart into smaller more manageable pieces. and have a command then call those sections up. It also allows you to more easily fine tune where potential errors crop up.