Sign in to follow this  
Followers 0
AutID

ControlSend/Send not working accurately

8 posts in this topic

#1 ·  Posted (edited)

So I am having this bug, don't know if someone had that before, couldn't find much with google and forum searches.

I want to send TAB to a specific window we have at work. Tab changes the value of some specific things on the window.
Now the first way I tried is ControlSend($hWND, "", "", "{TAB}"). That would normally work but in my case, it doesn't. I tried elevating scite, even though our program doesn't require admin, but still nothing. ControlSend doesn't return any error.
Then the second bad way I tried was

WinActivate($hWND)

Send("{TAB}").
Now this works once out of ten. I could run the same script 10 times and it will only work once, maybe less. 1/20 times.

I don't have any clue from which side this bug is coming from, autoit or my window.

 

Any ideas?

Edited by AutID

Share this post


Link to post
Share on other sites



Why are you using the WindowHandle in the ControlHandle parameter of ControlSend()?

Jos

Sorry about that, wrote it by hand, didn't check it in scite. I have used those commands very little in autoit. Not very big fan of those commands :/. Will edit the post.

Share this post


Link to post
Share on other sites

No clue what you are telling me there.  Just Cut&Paste what you have in your script into a codebox.
The ControlSend() now only contains a WindowHandle. You are missing the control you want to send the TAB to.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OT:

"ControlSend/Send not working accurately" is definitely not true! With this title you insinuate that the AutoIt-developers are lazy dumbasses not fixing a "bug" since years! They are NOT!

"I am not able to understand how ControlSend/Send works accurately" should be the title! 

 

BTT:

After activating a Window it is highly recommended to wait until the activation of this Window! In your example the Send("{TAB}") is executed immediately after the WinActivate($hWND)! At this time, Windows is processing the activation of the window, and nobody knows if the window is active or not. You have to ensure that the Window is active, maybe "WinWaitActive" would good to start with....

Edited by AndyG

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

No clue what you are telling me there.  Just Cut&Paste what you have in your script into a codebox.
The ControlSend() now only contains a WindowHandle. You are missing the control you want to send the TAB to.

Jos

 

The controlID doesn't have to be specified if the control has focus when the windows is activated, cases sensitive excluded.
This example will work as the original one in the examples provided from autoit(controlID not included)

Example()


Func Example()
 ; Run Notepad
 Run("notepad.exe")


 ; Wait 10 seconds for the Notepad window to appear.
 Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

 ; Wait for 2 seconds.
 Sleep(2000)

 ; Send a string of text to the edit control of Notepad. The handle returned by WinWait is used for the "title" parameter of ControlSend.
 ControlSend($hWnd, "", "", "This is some text")

 ; Wait for 2 seconds.
 Sleep(2000)

 ; Close the Notepad window using the handle returned by WinWait.
 WinClose($hWnd)

 ; Now a screen will pop up and ask to save the changes, the classname of the window is called
 ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
 WinWaitActive("[CLASS:#32770]")
 Sleep(500)
 Send("{TAB}{ENTER}")
EndFunc   ;==>Example

 

 In my case when the window is activated, my control has focus.
Now after this simpe code:

Local $hWND = WinGetHandle("title")


Sleep(3000) ;so the guy from the 5th post won't compain
ControlSend($hWND, "", "", "{TAB}")

if I simply press TAB on my keyboard, it will work like a charm. However if I add more sleep and then use Send("{TAB}") it won't work.

 

Anyway Jos this is just an explanation, no worries I found a workaround.

Edited by AutID

Share this post


Link to post
Share on other sites

OT:

"ControlSend/Send not working accurately" is definitely not true! With this title you insinuate that the AutoIt-developers are lazy dumbasses not fixing a "bug" since years! They are NOT!

"I am not able to understand how ControlSend/Send works accurately" should be the title! 

 

BTT:

After activating a Window it is highly recommended to wait until the activation of this Window! In your example the Send("{TAB}") is executed immediately after the WinActivate($hWND)! At this time, Windows is processing the activation of the window, and nobody knows if the window is active or not. You have to ensure that the Window is active, maybe "WinWaitActive" would good to start with....

I don't know if autoit developers are lazy and I can't understand why you are claiming that. To be honest; I can barely understand what you are saying.

As for what you are claiming about autoit:
Everybody can know "if the window is active or not" by using WinActive().

 

P.S. this is not facebook. If you need some attention go there or take a pet.

Share this post


Link to post
Share on other sites

ControlSetText = 99.99999% accurate...even without an active window.


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.

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

  • Similar Content

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Friends i am new to autoit and i am stuck in middle of automation of flashing tool..
      my requirement is i have a window and i have to get the value present in that window (below is the picture)

      in the above window i need to get the value of the highlighted field.the value of this filed keeps on changing...ii need to get the current value present in the field..below are the details of the window and field..

       
      CAN it be done?
       
      thanks

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys i am working on automating a flashing tool..When flashing is started if there is any error in connection it pops's up a error window...(as shown below)

       whenever this popup appears i need a msgbox to appear saying "error occured" how can i do this?
      Thanks

    • lganta
      By lganta
      Hello!
      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?