Mochiza Posted August 17, 2019 Share Posted August 17, 2019 Hello everyone, I'm trying to send the keystroke to an inactive notepad windows while the another one is activating. The problem that I found is word "Hello World" can't type in the inactive window, after I pressed the "Home" button while the cursor is staying in the active window. Here is my code. I'm trying with 2 windows of Notepad, using ControlSend() and WinGetHandle(). HotKeySet("{PGUP}", "NotepadHWND") HotKeySet("{HOME}", "Sim") HotKeySet("{DEL}", "PrntResult") Global $VAR_NotepadHWND While 1 Sleep(50) WEnd Func NotepadHWND() $VAR_NotepadHWND = WinGetHandle("[ACTIVE]") EndFunc Func Sim() Return ControlSend($VAR_NotepadHWND, "", "", "Hello World !!") EndFunc Func PrntResult() MsgBox(0, "","HWND is :" & $VAR_NotepadHWND) EndFunc Thank you everyone for sharing your solution and knowledge. 🤗 Link to comment Share on other sites More sharing options...
Nine Posted August 17, 2019 Share Posted August 17, 2019 LoL: inactive notepad ! Ok, how about you tell us what application you are trying to automate, and what is the goal of your issue... alienclone and FrancescoDiMuro 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Mochiza Posted August 18, 2019 Author Share Posted August 18, 2019 8 hours ago, Nine said: LoL: inactive notepad ! Ok, how about you tell us what application you are trying to automate, and what is the goal of your issue... I'm newbie for autoit and I just want to try this function with multiple copies of an application open which have the same title/text. My purpose is typing some word to an inactive window while I'm in the active window. Refer to my code, press "PGUP" button to specify the window I want to send word to by using WinGetHandle() to identify. After that press "Home" button to call the function to send a word to inactive window by using ControlSend(). But my code not provides me the thing what I want. I would like to say sorry if my description isn't clear for you. Link to comment Share on other sites More sharing options...
Network_Guy Posted August 18, 2019 Share Posted August 18, 2019 16 hours ago, Mochiza said: Func NotepadHWND() $VAR_NotepadHWND = WinGetHandle("[ACTIVE]") EndFunc wingethandle("[ACTIVE]") will return current active window handle (can return handle for another window than notebad ) ,so use this code instead $VAR_NotepadHWND =WinGetHandle("[CLASS:Notepad]") second , dont forget the Control ID in ControlSend so it should be :- Func Sim() Return ControlSend($VAR_NotepadHWND, "", "Edit1" , "Hello World !!") ;ControlID EndFunc Mochiza 1 Link to comment Share on other sites More sharing options...
Mochiza Posted August 18, 2019 Author Share Posted August 18, 2019 2 hours ago, Network_Guy said: wingethandle("[ACTIVE]") will return current active window handle (can return handle for another window than notebad ) ,so use this code instead $VAR_NotepadHWND =WinGetHandle("[CLASS:Notepad]") second , dont forget the Control ID in ControlSend so it should be :- Func Sim() Return ControlSend($VAR_NotepadHWND, "", "Edit1" , "Hello World !!") ;ControlID EndFunc Now I can send the word to inactive window. I have the question that if I don't know the "ControlID" or any properties of control (Id, ClassNN, ... ), so the word can't be sent to inactive window. Do we have the alternative ways to send the word to inactive window ? Link to comment Share on other sites More sharing options...
Nine Posted August 18, 2019 Share Posted August 18, 2019 Use au3info.exe tool in autoit folder to find the control ID or any other properties. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
water Posted August 18, 2019 Share Posted August 18, 2019 (edited) According to the help file: Send - Sends simulated keystrokes to the active window. To send data to inactive windows you can either try to automate the GUI by using Control* functions or use COM to directly interact with the programs API and avoid the GUI. It would help if you could tell us which program you REALLY try to automate at the end. Edited August 18, 2019 by water Mochiza 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Mochiza Posted August 18, 2019 Author Share Posted August 18, 2019 4 minutes ago, Nine said: Use au3info.exe tool in autoit folder to find the control ID or any other properties. There is no information about control. (I try with RO exe) Link to comment Share on other sites More sharing options...
Nine Posted August 18, 2019 Share Posted August 18, 2019 (edited) nvm Edited August 18, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Developers Jos Posted August 18, 2019 Developers Share Posted August 18, 2019 8 hours ago, Mochiza said: (I try with RO exe) So this is for game automation? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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