Jump to content

ControlSend/Send not working accurately


AutID
 Share

Recommended Posts

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

  • Developers

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

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

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

 

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

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...