Author Topic: Need a bit help- loop/condition  (Read 1978 times)

gorgo

  • Guest
Need a bit help- loop/condition
« on: February 02, 2019, 06:59:23 PM »
hi.
This command should get colorvalues (rgb) from a pixel in position x,y and press e-key if conditions not met.
If conditions met, it shoulc exit command. which doesnt happen. Just types 6 x e-key.

I have checked values the condition variables, their all within limits which, as I understand it, should trigger an exit of command.

I wonder if the end condition cant exit out of a loop?

Any suggestions?
Thank You.


Code: [Select]
Start VoiceAttack listening
// Obtain mouse cursor's X-coordinate
Set integer [~~mouseX] value to 309
Set integer [Teller] value to 0

// Obtain mouse cursor's Y-coordinate
Set integer [~~mouseY] value to 345

// Output mouse cursor coordinate
Write [Black] 'Cursor Coordinate = ({INT:~~mouseX} , {INT:~~mouseY})' to log

// C# inline function to obtain RGB and hexadecimal color values for screen pixel at (X, Y) coordinate of interest
Inline C# Function: Retrieve pixel color data at (X, Y) screen coordinate, wait until execution finishes

// Output RGB color values for screen pixel coordinate of interest
Write [Red] 'Red Value = {INT:~~RedValue}' to log
Write [Green] 'Green Value = {INT:~~GreenValue}' to log
Write [Blue] 'Blue Value = {INT:~~BlueValue}' to log

// Output hexadecimal color value for screen pixel coordinate of interest
Write [Gray] 'Hex Value = {TXT:~~HexValue}' to log
Start Loop While : [Teller] Is Less Than 6
    Set integer [Teller] to [Teller] plus 1
    Write [Blue] '{INT:Teller}' to log
    Begin Condition : ([~~Green Value] Is Greater Than 160 AND [~~Green Value] Is Less Than 231 AND [~~Red Value] Is Greater Than 229 AND [~~Red Value] Is Less Than 251)
    End Condition - Exit when condition met
    Press E key and hold for 0.05 seconds and release
    Pause 3 seconds
End Loop
Set integer [Teller] value to 0
Stop VoiceAttack listening

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Need a bit help- loop/condition
« Reply #1 on: February 02, 2019, 07:10:57 PM »
You're writing the value of "~~GreenValue"(and red and blue) to the log(which I assume is set by the inline function), but then in the condition you're checking "~~Green Value".

The variable name must match exactly(though they are case-insensitive), otherwise you're checking the values of two different variables.

gorgo

  • Guest
Re: Need a bit help- loop/condition
« Reply #2 on: February 02, 2019, 07:35:13 PM »
You're writing the value of "~~GreenValue"(and red and blue) to the log(which I assume is set by the inline function), but then in the condition you're checking "~~Green Value".

The variable name must match exactly(though they are case-insensitive), otherwise you're checking the values of two different variables.

Thank You. I forgot that the tildes ~~ before variable arent part of their names :)
Ill check this out tomorrow.  :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Need a bit help- loop/condition
« Reply #3 on: February 02, 2019, 07:58:50 PM »
I forgot that the tildes ~~ before variable arent part of their names
They are, actually...

I was pointing out that the first variable name is "~~GreenValue", whereas the second is "~~Green Value", note the space between "~~Green" and "Value" in the latter.

gorgo

  • Guest
Re: Need a bit help- loop/condition
« Reply #4 on: February 02, 2019, 08:29:34 PM »
You're writing the value of "~~GreenValue"(and red and blue) to the log(which I assume is set by the inline function), but then in the condition you're checking "~~Green Value".

The variable name must match exactly(though they are case-insensitive), otherwise you're checking the values of two different variables.

Thank You. I noticed the space btwn i.e. ~~Red Value. Did delete the space and it works.

Ididnt make the inline's, this guy did :) https://forum.voiceattack.com/smf/index.php?action=profile;u=915

Code: [Select]
Start VoiceAttack listening
// Obtain mouse cursor's X-coordinate
Set integer [~~mouseX] value to 278

// Obtain mouse cursor's Y-coordinate
Set integer [~~mouseY] value to 345
Set integer [Teller] value to 0

// Output mouse cursor coordinate
Write [Black] 'Cursor Coordinate = ({INT:~~mouseX} , {INT:~~mouseY})' to log

Start Loop While : [Teller] Is Less Than 6
    Set integer [Teller] to [Teller] plus 1

// C# inline function to obtain RGB and hexadecimal color values for screen pixel at (X, Y) coordinate of interest
    Inline C# Function: Retrieve pixel color data at (X, Y) screen coordinate, wait until execution finishes

    Begin Condition : ([~~GreenValue] Is Greater Than 160 AND [~~GreenValue] Is Less Than 231 AND [~~RedValue] Is Greater Than 229 AND [~~RedValue] Is Less Than 251)
    End Condition - Exit when condition met
    Press E key and hold for 0.05 seconds and release
    Pause 3 seconds
End Loop
Set integer [Teller] value to 0
Stop VoiceAttack listening

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Need a bit help- loop/condition
« Reply #5 on: February 12, 2019, 09:24:22 AM »
So just to double-check, do you have any issues with the RGB inline function or the associated profile?

gorgo

  • Guest
Re: Need a bit help- loop/condition
« Reply #6 on: February 23, 2019, 04:27:54 PM »
So just to double-check, do you have any issues with the RGB inline function or the associated profile?

No, everything works nice. Thank you