Jump to content

ControlSend and sluggish software


Recommended Posts

Hello everyone,

I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.

To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  

Yes I could block input but I prefer not to do that (permissions).

Is there a better way of doing this?  Any Help would be much appreciated.

Anyway here is the snippet of the script in question:

Func KVSend ()
   WinActivate ( "Window", "" )
   Local $WindowPos = WinGetPos("Window", "")
   If $kV < 30 Then
         WinActivate ( "Window", "" )
         ControlClick ("Window", "", 1001) ;Click in Accel Voltage box
         Sleep (100)
         ControlSend ("Window", "", 1001, $kV) ; \ kV
         Sleep (100)
         MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1)
         MouseClick($MOUSE_CLICK_LEFT)
         MouseClick($MOUSE_CLICK_LEFT)
         Send ("^c")
         Local $clip = ClipGet ()

         If $clip = $kV Then
            ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct
            Sleep (100)
            ControlClick ("Window", "", 1518) ;Lens Clear
         Else
            Send ("{BACKSPACE}")
            KVSend() ; If value is incorrect try again
         EndIf
   EndIf

 

Edited by rawkhopper
Link to comment
Share on other sites

  • Developers

Have you tried to get the current value with ControlGetText() and compare that?

edit: Something like this:

Func KVSend()
    WinActivate("Window", "")
    Local $WindowPos = WinGetPos("Window", "")
    If $kV < 30 Then
        WinActivate("Window", "")
        While $kv <> ControlGetText("Window", "", 1001)
            Sleep(100)
            ControlSend("Window", "", 1001, $kV) ; \ kV
        WEnd
        ControlSend("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct
        Sleep(100)
        ControlClick("Window", "", 1518) ;Lens Clear
    EndIf
EndFunc   ;==>KVSend

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hey big thanks again the way you suggested works quite well! I had to add in a line to clear the value first before entering otherwise if you somehow messed it up it would never get out of the loop but you were a very big help thanks!!!!!!

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

×
×
  • Create New...