Sign in to follow this  
Followers 0
shoushou111

How do I send keys to unfocused window?

12 posts in this topic

Hello, I'm new to this program, can someone help me how to utilize ControlSend function to send keys to unfocused window?

I need someone to do this for me. Calc.exe (calculator) is already open but not focused. But I want AutoIt to send "123" to calc.exe, how would I do this? Please give me a script, I went on to read other threads about ControlSend but I just cannot get it in my head as I'm really really new to this program. Also, how would I do the same thing but when I have multiple calc.exe open and I want to send '123' to a specific calc.exe? Thanks in advance!

Share this post


Link to post
Share on other sites



Never heard of Calculator, is it a mmorpg ?

Share this post


Link to post
Share on other sites

Calc.exe is the builtin Calculator of Windows.

Is this a real problem you try to solve or do you just learn how to use AutoIt?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Never heard of Calculator, is it a mmorpg ?

 

Lol  I was thinking the same thing. If its just a calculator why not just set focus first then do what you have to do. Better yet, why not do your calculations in the code itself?

Share this post


Link to post
Share on other sites

Calc.exe is the builtin Calculator of Windows.

Is this a real problem you try to solve or do you just learn how to use AutoIt?

 

Yea I want to learn how to use AutoIt and this is just an example. If someone gave me an example of it, I was going to apply to something else.Or is that not allowed here?

Share this post


Link to post
Share on other sites

Calc.exe is the builtin Calculator of Windows.

Is this a real problem you try to solve or do you just learn how to use AutoIt?

 

I know :P I was just being sardonic after having read his closed gamebot thread :P

Share this post


Link to post
Share on other sites

Lol  I was thinking the same thing. If its just a calculator why not just set focus first then do what you have to do. Better yet, why not do your calculations in the code itself?

This is just an example I gave for the purpose of this thread, I want to know how to send keys when it is unfocused. Also, no calculations, I just want to send keys, or in this case the keys: 123

Share this post


Link to post
Share on other sites

Hi shoushou111,

Try like this i think it will work.

run ("calc.exe")
WinWaitActive("Calculator")
ControlSend("Calculator", "", "#327701", "123")

Share this post


Link to post
Share on other sites

Hi shoushou111,

Try like this i think it will work.

run ("calc.exe")

WinWaitActive("Calculator")

ControlSend("Calculator", "", "#327701", "123")

Hey thanks for your help but I don't think that was what I was looking for, I tried this type of script before. I want to send keys to an unfocused window which is already open but just not focused. (Ex, have calculator running in the background while browsing in Chrome). The script you gave me opens up calculator and only inputs the keystrokes 123 when it is focused. Thanks for trying to help though I appreciate it.

Share this post


Link to post
Share on other sites

Some applications will and some applications wil not accept user input from AutoIt unless the application has focus.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

I think it is best to learn AutoIt by trying to solve "real" problems.

Automating Calc is never required in "real" life :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

In regards to your issue with sorting multiple windows, Assuming there are none open prior to running your script, You could assign them different names using WinSetTitle, Though, This would have to be done one at a time to ensure multiple windows were not all renamed the same. Then you could independently focus or, ControlSend to which ever window you choose by grabbing the window with the appropriate name title.

Edited by BlackDawn187

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