Jump to content

How to check if copied integer is greater, less, etc. ?


Recommended Posts

Hey everyone, 

Just a quick question, tried searching about it, but didn't really find exactly what I needed.

So the situation is for example I did a few commands as follows to simply highlight and copy an integer from a textbox. 

MouseClick("left", $Highlightx, $Highlighty) ; Highlight textbox
    MouseClick("left", $Highlightx, $Highlighty)
    Send("{CTRLDOWN}c{CTRLUP}")

How do I take that copied integer and compare it with another integer using If statements? Is there some command that I'm not finding? For example

MouseClick("left", $Highlightx, $Highlighty) ; Highlight textbox
    MouseClick("left", $Highlightx, $Highlighty)
    Send("{CTRLDOWN}c{CTRLUP}")
    Local $iValue = Int("{CTRLDOWN}c{CTRLUP}")

    If ($iValue > 100 ) Then
        _Reset() 
    Else
        Sleep (50)
    EndIf

Now obviously it doesn't work lol, but I'm unsure of what code is needed to check that stored "copied" integer from the textbox. 

Any help would be great!

Thanks.

Link to comment
Share on other sites

what kind of textbox.  Use ControlGetText, or one of the _IE functions.

And you would use clipget to get the value you copy...but that's got to be the most inefficient and inaccurate way to do it.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

what kind of textbox.  Use ControlGetText, or one of the _IE functions.

It's a standard web textbox similar to what we're using now to reply. Hmm never used these types of codes before.

edit: thanks for the fast reply btw!!

Edited by Fission102
response
Link to comment
Share on other sites

Hi Fission,

you can use:

If IsInt($iValue) Then
    if $iValue > 100 Then
        _Reset()
    EndIf
Else
    MsgBox(0,"Not Int","The Value Copied is not recognized as an Int")
EndIf

give that a crack and see what it returns for you.

 

Unfortunately it didn't do anything, the message box didn't pop up and the reset function portion didn't activate even though the copied value was > 100 :(  

It's probably to do with the following not being valid

Local $iValue = Int("{CTRLDOWN}c{CTRLUP}")
 

Edited by Fission102
Link to comment
Share on other sites

The int value of a string is always 0

Local $iValue = Int("{CTRLDOWN}c{CTRLUP}")

If you don't want to use the IE functions then you'll want to do

Send("^{c}") ; Sends Ctrl + C
Local $iValue = ClipGet() ; Gets the value copied

If ($iValue > 100) Then
    _Reset()
Else
    MsgBox("", "", "Number is less than or equal to 100")
EndIf

It's going to implicitly convert any non number string to 0 and since you're checking to see if it's greater than 100, it doesn't matter if it's a true number or not.

(I would give you an IE example but there's plenty in the help file and I've never actually used the IE functions)

Edited by InunoTaishou
Link to comment
Share on other sites

The int value of a string is always 0

Local $iValue = Int("{CTRLDOWN}c{CTRLUP}")

If you don't want to use the IE functions then you'll want to do

Send("^{c}") ; Sends Ctrl + C
Local $iValue = ClipGet() ; Gets the value copied

If ($iValue > 100) Then
    _Reset()
Else
    MsgBox("", "", "Number is less than or equal to 100")
EndIf

It's going to implicitly convert any non number string to 0 and since you're checking to see if it's greater than 100, it doesn't matter if it's a true number or not.

(I would give you an IE example but there's plenty in the help file and I've never actually used the IE functions)

Ahh!! ClipGet is what I was misunderstanding then, it will work perfect. I'll also use  ^{c} and v instead, seems a lot cleaner.

Cheers!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...