Sign in to follow this  
Followers 0
Cormin

If statement for specific value in text box?

12 posts in this topic

How can I make an if statement to continue when this value (-421, selected by finder tool) is + or - 1 number within -421?  If it's anything else I want to re-calibrate again(I can do this part), if it is within that range of +/-1 then continue the script.

 

 

8oKTH1D.png

Share this post


Link to post
Share on other sites



First step would be to retrieve the value from the control. Show us your code where you tried to do this.

Share this post


Link to post
Share on other sites

First step would be to retrieve the value from the control. Show us your code where you tried to do this.

Not sure what you mean specifically.  I haven't been using control clicks and my code does nothing with this box anyways for now.  This box only gives me data from the board I'm programming giving me info on how much current it sees when I apply the current by hand.

Share this post


Link to post
Share on other sites

This text box can be selected and copied into clipboard.  I could do clipget but was hoping for a faster way than that.

Share this post


Link to post
Share on other sites

Based on your initial post, my assumption was that you needed to retrieve the value from the designated control and then perform an action if the value is within +/- 1 of -421. To get the control's contents, you would call ControlGetText() with the appropriate parameters.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Based on your initial post, my assumption was that you needed to retrieve the value from the designated control and then perform an action if the value is within +/- 1 of -421. To get the control's contents, you would call ControlGetText() with the appropriate parameters.

MouseClick("left",156,210,1);calibrate start
Sleep ( 50 )
MouseMove(1233,201)
Sleep ( 50 )
Sleep ( 5000 )
MouseMove(251,212)
Sleep ( 20 )
Beep(600, 500)
Sleep ( 5000 )

This is my code for this process.  The mouse click just clicks the big calibrate as indicated below button.  It then moves the mouse(only for my reference when using headphones) to the right while calibrating then back when done calibrating.  This is when I want the if statement.  After the second mouse move, I want it to read if the box says +/-1 to -421, if it does continue the script, if it does not then click the button again.  When its done calibrating(after the beep) I then stop current.  So I guess I want a loop in there too which I don't know how to use.  I want it to keep calibrating until it is within range.

I don't know how to use control clicks.  Also in a lot of spots in this program they don't work anyways.

Edited by Cormin

Share this post


Link to post
Share on other sites

So have you tried using ControlGetText? Based on the contents of your screenshot, the following should work:

$nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]")

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

 

So have you tried using ControlGetText? Based on the contents of your screenshot, the following should work:

$nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]")

 

I have not.  I don't know how to use that in a looping if statement.  Thanks so much for helping so far.

Edited by Cormin

Share this post


Link to post
Share on other sites

 

So have you tried using ControlGetText? Based on the contents of your screenshot, the following should work:

$nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]")

 

Tried making a tiny script to even test if this works.  I have no clue how to use this.

Sleep ( 800 )
$nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]") 

Sleep ( 50 )
MsgBox($nCurrent)

Share this post


Link to post
Share on other sites

You need to read the help file. o:) The correct syntax would be:

MsgBox(0, "result", $nCurrent)

This should tell you if the value is being read with the earlier code. Then you would need to wrap everything in a While loop, like this:

Local $nCurrent, $nMin = -422, $nMax = -420

While 1
    MouseClick("left",156,210,1);calibrate start
    Sleep ( 50 )
    MouseMove(1233,201)
    Sleep ( 50 )
;   Sleep ( 5000 )
    MouseMove(251,212)
    Sleep ( 20 )
    
    $nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]") 
    
    If $nCurrent >= $nMin And $nCurrent <= $nMax Then
        ExitLoop
    EndIf
    
    Sleep ( 5000 )
WEnd

Beep(600, 500)

You probably will want to add some other method to exit the loop so that it doesn't run non-stop if the correct value isn't ever retrieved. :thumbsup:

Share this post


Link to post
Share on other sites

Sleep ( 800 )
$nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]") 
Sleep ( 50 )
MsgBox(0, "result", $nCurrent)

This just gives me a window named result with nothing inside.

Share this post


Link to post
Share on other sites
Sleep ( 800 )
$nCurrent = ControlGetText("Texas Instruments", "", "[CLASSNN:ThunderRT6Textbox3]") 
Sleep ( 50 )
MsgBox(0, "result", $nCurrent)

This just gives me a window named result with nothing inside.

Add Opt("WinTitleMatchMode", 2) to the top of this script, and read the Help file some more


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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