Author Topic: exit command end condition and a inline function  (Read 1837 times)

jane

  • Newbie
  • *
  • Posts: 49
exit command end condition and a inline function
« on: March 17, 2024, 08:05:06 AM »
hello.
I try run 2 codeparts in 1 command.

1st codepart (green) ment to click  4 and 2nd codepart ment to click 2, both dependant of colorpixle.
Oh color dont show, might be its possible to identify the 2 parts anyway(?)
I could probably
a) run 3 commands, a main, controlling 2 alternative paths of instructions.
b) try to fit solution in 1 command  (attached)

Would a be slower than b?

RE. a: Im stuck with the exit commands/end conditions.

Any help to get their logical placement in code?

Programming goal is:
Loop, and compare, 2 pixel color value pairs, until equality is found width  one of the pairs.
Dependant of colorvalues, type a keyboardkey.
Do a correct exit of this command  <------??
Code: [Select]
Set integer [~~mouseX] value to 962
Set integer [~~mouseY] value to 1010
Set integer [~~mouseX2] value to 147
Set integer [~~mouseY2] value to 1002
Set Boolean [vari1] to True
Start Loop While : [vari1] Equals True
    Inline C# Function: Function for retrieving pixel color data at (X, Y) screen coordinate, wait until execution finishes
    Begin Condition : ([~~RedValue] Is Greater Than 90 AND [~~RedValue] Is Less Than 112 AND [~~BlueValue] Is Greater Than 52 AND [~~BlueValue] Is Less Than 70)
        Press 4 key and hold for 0,06 seconds and release
        Say, 'finish2'
        Exit Command
    End Condition
    Set integer [~~mouseX] value to the value of [~~mouseeX2]
    Set integer [~~mouseY] value to the value of [~~mouseY2]
    Inline C# Function: Function for retrieving pixel color data at (X, Y) screen coordinate, wait until execution finishes
    Begin Condition : ([~~RedValue] Is Greater Than 207 AND [~~GreenValue] Is Greater Than 207 AND [~~BlueValue] Is Greater Than 207)
        Press 2 key and hold for 0,06 seconds and release
        Pause 0,1 seconds
        Say, 'finish3’
Exit Command
    End Condition
End Loop





If

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: exit command end condition and a inline function
« Reply #1 on: March 17, 2024, 01:42:19 PM »
Looks fine to me - if you can achieve it in one command, why make 3?

Keep it simple.

If it works, use it. If it doesn't work, fix it.  Your use of 'Exit Command' actions (while redundant, given options in the conditions they are contained in) is correct and appropriate.  Alternatively, you can double-click the 'End Condition' actions and modify them to exit this command when this condition is met.

That said, it appears that this loop will continue indefinitely unless one of these conditions are met, and I must assume that some other command or function is capable of altering the variable 'vari1' to 'False' in order for this command to gracefully exit its "While" loop if desired.

You could more efficiently contain all of this logic and these actions within the inline function (including the loop) which could be made to run indefinitely in the background, and which will not be forced to stop this loop when you 'Stop all running commands' through an action or the "Stop" button on the main VA window.  It really just depends on what you prefer, and how you intend to enact this loop and/or end it.