shoushou111 Posted February 3, 2014 Share Posted February 3, 2014 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 More sharing options...
Werty Posted February 3, 2014 Share Posted February 3, 2014 Never heard of Calculator, is it a mmorpg ? Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
water Posted February 3, 2014 Share Posted February 3, 2014 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dondre Posted February 3, 2014 Share Posted February 3, 2014 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 More sharing options...
shoushou111 Posted February 3, 2014 Author Share Posted February 3, 2014 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 More sharing options...
Werty Posted February 3, 2014 Share Posted February 3, 2014 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 I was just being sardonic after having read his closed gamebot thread Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
shoushou111 Posted February 3, 2014 Author Share Posted February 3, 2014 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 More sharing options...
sumanthupar Posted February 3, 2014 Share Posted February 3, 2014 Hi shoushou111, Try like this i think it will work. run ("calc.exe") WinWaitActive("Calculator") ControlSend("Calculator", "", "#327701", "123") Link to comment Share on other sites More sharing options...
shoushou111 Posted February 3, 2014 Author Share Posted February 3, 2014 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 More sharing options...
Bowmore Posted February 3, 2014 Share Posted February 3, 2014 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 More sharing options...
water Posted February 3, 2014 Share Posted February 3, 2014 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
BlackDawn187 Posted February 4, 2014 Share Posted February 4, 2014 (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 February 4, 2014 by BlackDawn187 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now