Sign in to follow this  
Followers 0
Gar

How do I Send keys to an inactive window?

10 posts in this topic

This seems to be a common question on the forum, and there is never a useable answer. A few people seem to post "I got it working!" but never say how. How do I simulate a Send() to an inactive window without it gaining focus? There are no useable controls. ControlSend using its window handle and window process hasn't worked (as there are no controls to send it to).

I've seen reference to DllCalls, but I don't know how these work. This is the closest I've come to having it send the 'up' key:

DllCall("user32.dll", "int", "SendMessageA", "hwnd", $winHandle, "int", 0x100, "int", 0x26, "int", 0x1480001)

Unfortunately, this does nothing.

Can anyone point me in the right direction?

Share this post


Link to post
Share on other sites



What you mean by "There are no useable controls"?


Why crabs don't give money to charity..... because they are shell-fish!! PS: Don't be a crab and share your scripts with the community! ;-)

Share this post


Link to post
Share on other sites

What you mean by "There are no useable controls"?

I mean that the window has no control objects for ControlSend to target. I need a Send directed specifically at "the window", which is also inactive.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Would a suitable workaround be to make it active, do a Send(), then got back to the previous window?

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Would a suitable workaround be to make it active, do a Send(), then got back to the previous window?

No, because I want it to remain inactive.

Share this post


Link to post
Share on other sites

I've been trying to figure this out for months now. Look up my posts, it's true. Can't anybody offer a solution?

Share this post


Link to post
Share on other sites

please refer to code below.

CODE

Run("notepad.exe")

Run("cmd.exe")

WinActive("Untitled - Notepad")

Sleep( 500)

ControlSend("C:\WINDOWS\system32\cmd.exe" , "",0, "inactive command window")

Send("active notepad window")

When i use command prompt, it is working remaning inactive.

but i dont't know what's the meaning of 0 at the ControlSend function.

Share this post


Link to post
Share on other sites

please refer to code below.

CODE

Run("notepad.exe")

Run("cmd.exe")

WinActive("Untitled - Notepad")

Sleep( 500)

ControlSend("C:\WINDOWS\system32\cmd.exe" , "",0, "inactive command window")

Send("active notepad window")

When i use command prompt, it is working remaning inactive.

Is there a way to make this work with commands like Send("^o")?

Thanks!

Share this post


Link to post
Share on other sites

Try controlsend with a blank control id parameter.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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