Sign in to follow this  
Followers 0
olo

Limit an area to be between 2 points?

10 posts in this topic

hey all,

Just looking to see if anyone can help me?

I have 2 points say (x,y) and (x1,y1).

Now (x,y) is the top left point of a rectangle(for example)

and (x1,y1) is the bottom right point of the rectangle.

How would I say this in an if statement?

EG.

If $my_data is not between these 2 points ---> exit.

else ...do_whatever...

Endif

Share this post


Link to post
Share on other sites



What is the name of the application you wish to interact with? There may be a much better way to interact with the controls than Pixel search. Pixel search is one of the most unreliable methods to use. You are much better to use things such as controlclick and controlsend.

Share this post


Link to post
Share on other sites

What is the name of the application you wish to interact with? There may be a much better way to interact with the controls than Pixel search. Pixel search is one of the most unreliable methods to use. You are much better to use things such as controlclick and controlsend.

I just had two sets of data in a pdf that I want to make a range. and i want all my data to be within that range

Share this post


Link to post
Share on other sites

This is it:

;; This script is guaranteed to exit

Global $x1=0, $y1=0, $x2=320, $y2=320
Global $MYDATA[2] = [234,345]

If $MYDATA[0] >= $x1 and $MYDATA[0] <= $x2 then
  If $MYDATA[1] >=$y1 and $MYDATA[1] <= $y2 then
    _DoSomething()
      else
        Exit
  EndIf
    else
   Exit
EndIf

Func _DoSomething()
msgbox(64, '', 'The point is inside')
EndFunc

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Great example!

"Great" - I don't think so.

One If statement with three And's would be a better example, IMO.

Four nested If statements would have been worse.

Share this post


Link to post
Share on other sites

One If statement with three And's would be a better example, IMO

Alright, so here we go:

;; This script is guaranteed to exit

Global $x1=0, $y1=0, $x2=320, $y2=320
Global $MYDATA[2] = [345,345]

If $MYDATA[0] >= $x1 and $MYDATA[0] <= $x2 and $MYDATA[1] >=$y1 and $MYDATA[1] <= $y2 then
    _DoSomething()
      else
        Exit
  EndIf

Func _DoSomething()
msgbox(64, '', 'The point is inside')
EndFunc

:sweating: Undoubtedly, this one is better, since it saves me nesting.


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

You are welcome indeed. However, I suggest you to use the example in Post-7 of this thread. It's much better than the first one (which you have quoted).

1 person likes this

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0