Sign in to follow this  
Followers 0
pieeater

stringregexp question[nevermind]

3 posts in this topic

#1 ·  Posted (edited)

im trying to check if a point is between two set points using stringregexp. i know i can do it this way:

if ... > ... and ... < ... and ... > ... and < ... then

however im trying to check it through stringregexp. if its possable. heres what i tried:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 554, 312, 331, 130)
$click = GUICtrlCreateGroup("click", 144, 64, 249, 161)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    $mp = MouseGetPos()
    $mp1 = BinaryToString($mp[0])
    $mp2 = BinaryToString($mp[1])
    If _IsPressed(01) and StringRegExp($mp1, "{144, 393}", 0) = 1 And StringRegExp($mp2, "{64, 225}") = 1 Then MsgBox(0, "", "")
WEnd
Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Regular expressions is definitely not the means to solve this issue.

You're asking for a "String"/"Char" type function to do "Number/Integer" type operation, even if it works, it's not a good way to approach it.

Why not just make a simple func to do it.

eg.

Func __IsBetween($n_num, $n_pt1, $n_pt2)

    If Number($n_num) <= Number($n_pt1) Then Return False
    If Number($n_num) >= Number($n_pt2) Then Return False

    Return True
EndFunc

pseudo:

If IsArray($mp) Then
    If _IsPressed(01) Then
        If __IsBetween($mp[0], 144, 393) And __IsBetween($mp[1], 64, 225) Then
            MsgBox(0, "", "")
        EndIf
    EndIf
EndIf
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

i didnt think that it would work ;) well thanks for replying :huh2:


[spoiler]My UDFs: Login UDF[/spoiler]

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