TFM

SendKeys.SendWait

10 posts in this topic

Hello,

I have looked through the forums and documentation but have not found anything on this.  In .NET, using the System.Windows.Forms assembly, you can use:

Sendkeys.SendWait

To send key strokes.  It:  Sends the given keys to the active application, and then waits for the messages to be processed.

When using the AutoItScript Send function, it seems to not wait for the messages to be processed because when automating my application, there is a timing issue where tabs are occuring before text is finished sending etc.

Does anyone know if there is a wait to use AutoIt same as SendWait?   I know you can set the speed between keypresses but that seems kind of a potential for errors if the system or app slows down.

 

Thanks in advance.

Share this post


Link to post
Share on other sites



You should look in to:
AutoItSetOption ( "option" [, param] )

Option:
SendKeyDelay: Alters the length of the brief pause in between sent keystrokes. A value of 0 removes the delay completely.
Time in milliseconds to pause (default=5).

This probably help you with your problem.
 

Share this post


Link to post
Share on other sites

I would use Send/ControlSend + WinWait/ProcessWait

Share this post


Link to post
Share on other sites

@alien4u the OP specifically states he is looking for a "wait for response" behavior, not SendKeyDelay.

@TFM I think mikell is closest on this, if you want to do this natively. IIRC, Sendkeys first tries to establish a keyboard hook into the other process. Only then will it operate as expected. If it cannot, it simply uses SendInput. I don't believe you're going to be able to hook into the other process in the same manner natively with AutoIt (someone could very well come along and prove me completely wrong), and are going to be forced to rely on the method mikell lays out above.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

@JLogan3o13
I'm just wondering here because I'm a beginner.

If he increment the delay between sent keystrokes then maybe it could fix the timing issue?
Example:
Sent TAB 3 times but with delay between keystrokes of 1 second, then that will give enough time to the application to react?
I'm right here even if is not the best way? or I'm missing something? I'm just curious about.

Regards
Alien.

Share this post


Link to post
Share on other sites

@alien4u read the MSDN article on SendKeys.SendWait to see what the OP is looking to do. Specifically:

Quote

use this method to send keystrokes to an application and wait for any processes that are started by the keystrokes to be completed

 


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites
6 hours ago, JLogan3o13 said:

@alien4u read the MSDN article on SendKeys.SendWait to see what the OP is looking to do. Specifically:

 

Hi @JLogan3o13 thanks you.
As incredible as it sound is really difficult for me to access Microsoft MSDN or Technet because is slow like hell for me, near impossible to open from my Dial-Up connection.
Anyways I will look in to this.

Regards
Alien.
 

Share this post


Link to post
Share on other sites

Hi mikell,

Do you have an example of what you were thinking when using:

I would use Send/ControlSend + WinWait/ProcessWait

It looks to me like the 2 Wait calls pause until the application is active.   Not sure how the effects keystrokes and possible application delay between each?   I am still a little hesitant to use SendKeysDelay option as it sets a fixed delay rather than waiting until the system is ready to process addition keystrokes. 

Share this post


Link to post
Share on other sites

Given the requirements from post #1, it seems to me that after the SendKeys you want to wait for something to change - this could be the content of an application window or a process existence (reason why I mentioned WinWait and ProcessWait)
With both, unless you specifically define a timeout the default delay is "wait indefinitely"

Share this post


Link to post
Share on other sites

Okay, thanks a lot for responding. 

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