Jump to content

Recommended Posts

Posted

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

Capture.PNG

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

Posted
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

 

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

Posted (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 by water

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

 

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

sss.PNG

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
  • Recently Browsing   0 members

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