Sign in to follow this  
Followers 0
triodz

Attempt to send "Enter" to window is not working

6 posts in this topic

I have looked at this every which way I can, and I have been unable to find what I may have done wrong here. Here is the code:

#RequireAdmin
Run("C:\Users\Funky Monkey\Desktop\test\program.exe");
WinWaitActive("program");
Sleep(2000);
Send("{ENTER}",1)

The windows gets brought to the front, then sits there. I need it to send "Enter" so it closes automatically and continue on with the rest of the code. It's a really simple command, but just will not work! I am using Win7 64 bit is that makes any difference.

I tried using runwait, shellexecute and winactivate. Does not seem to make a difference. Except that winactivate does not bring the window forward.

Any help is appreciated. Thanks.

Share this post


Link to post
Share on other sites



Could be the program doesn't accept external keystrokes.. or maybe something else.. :D


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Not sure what you mean? I can manually hit the enter key and it works fine. Autoit just won't send the keystroke? I am positive that I have gotten this to work at some point in the past. I can't find the old code though! Grrr... this is becoming frustrating.

As a side note. I just tried in my XP VM and it does not work there either. :D

Share this post


Link to post
Share on other sites

Ummmm... Instead of using just "send" try using control send to send it DIRECTLY to the program... or first check if autoit even detects it.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks, Sleepercell. Gave it a go:

#RequireAdmin
Run("C:UsersFunky MonkeyDesktoptestprogram.exe");
WinWaitActive("program");
Sleep(2000);
ControlSend("program","","[CLASS:Button; INSTANCE:3]","{ENTER}",1)

But still no love unfortunately.

Autoit definitely detects it, as winwaitactive brings the window to the foreground, whereas without it, it stays in the background.

Edited by triodz

Share this post


Link to post
Share on other sites

Welp, I finally figured it out. Here's the end code:

#RequireAdmin
Run("C:UsersFunky MonkeyDesktoptestprogram.exe","",@SW_SHOWNORMAL)
sleep(100)
Send("{ENTER}")

Thanks to all who took the time to throw in their 2 cents, I really do appreciate it. Not sure why "SHOWNORMAL" would make it behave differently than WinWaitActive. Possibility that it is a macro whereas WinWaitActive is a command? Dunno.

I know this was a simple thing, but I have spent hours trying to figure it out! I feel like the brick wall and I are very close compadre's now.

At least someone with the same issue has an answer.

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