Jump to content

How do I send keys to unfocused window?


Recommended Posts

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!

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

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

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

Some guy's script + some other guy's script = my script!

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

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

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...