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)
         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
            Send ("{BACKSPACE}")
            KVSend() ; If value is incorrect try again


Edited by rawkhopper

Share this post

Link to post
Share on other sites

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)
            ControlSend("Window", "", 1001, $kV) ; \ kV
        ControlSend("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct
        ControlClick("Window", "", 1518) ;Lens Clear
EndFunc   ;==>KVSend


Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites


I thought I had tried ControlGetText and failed.  I thought it gave me the old value and not the new value written in.  I must have done something wrong before.  Thanks for the help!

Share this post

Link to post
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!!!!!!

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

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
    • SkysLastChance
      By SkysLastChance
      Run("notepad.exe") GLOBAL $One = ('Line1' & _ 'Line2' & _ 'Line3' & _ 'Line4' & _ 'Line5') ClipPut($One) $Notepad = WinWait("[CLASS:Notepad]", "", 10) ControlSend("Untitled - Notepad", "", "", ("^v")) Instead of having this paste as Line1Line2Line3Line4Line5
      How can I make it paste it into notepad as (without double spacing.)
    • lganta
      By lganta
      I created some scripts for a simple farming bot a few years ago and they rely on ControlSend.
      A year ago I quit that game and then installed Windows 10 (was using windows 7).
      Recently I installed that game and tried running them again and they seem to work (I have some messages displayed on the screen with the state of the bot ), except for the ControlSend part (which obviously is crucial).
      I started debugging the scripts so I created a basic script that makes use of Send. I tested this with Notepad in focus and works just fine and then with my game window in focus and it didn't work (it's supposed to write that text in an input box from the game).
      #include <MsgBoxConstants.au3> Sleep(3000); Send("some text"); MsgBox($MB_OK, "Notification", "Control was sent!");  
      Is there a way for the creators of the game to create some kind of security system against this? Or something happens because I updated to Windows 10?
      Is there something I'm missing?
      Thank you!
    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?

    • AndreyS
      By AndreyS
      Dear developers and creators of the language, please explain to me why when pressing the combination Crtl + Shift + C from the 5th or the 10th time "sticks / sinks" Ctrl or Shift? And then you need to press Ctrl or Shift again to reset their triggering. I only need to use hot keys like in the example!
      The code is a small example. Its essence is that when a user in the editor selects any number and presses a combination, then it increases by 1. 
      Dim $x HotKeySet("+^c","Calc") While 1 Sleep(10000) WEnd Func Calc() Send("^c") Sleep(50) $x=ClipGet()+1 ClipPut($x) Send("^v") EndFunc I thought that in my program some kind of glitch was searching for a reason for a long time. And it turned out that apparently somehow the work of some functions used in the example is not compatible. 
      Tell me, please, what is the problem?

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.