Jump to content

How to send keystrokes to parent window with ControlSend()


 Share

Recommended Posts

Hey guys my question is obvious and heres example about my problem ;

Picture1 Child window of notepad ; aka Edit1

LpG7d1.png

As you can see there is instance(1) and control class name(Edit)

But on this pic2 ;

RJGLEj.png

There is no instance and control class name...

 

So i just want to send keystrokes to not child window of notepad(pic1) , i want to send keystrokes to parent window of notepad(pic2)

But parent windows havent got any controlid or controlname etc..

So what should i do ?

Thanks in advance.

Edited by hqq
Link to comment
Share on other sites

Are you sure it does not give you any of these?

ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screen readers for the blind and Microsoft tools/APIs may allow you to get this Control ID
    TEXT - The text on a control, for example "&Next" on a button
    CLASS - The internal control classname such as "Edit" or "Button"
    CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"
    NAME - The internal .NET Framework WinForms name (if available)
    REGEXPCLASS - Control classname using a regular expression
    INSTANCE - The 1-based instance when all given properties match.

As these are the ways you can interact with a control.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

As you can see on pic3 , it gives just instance handle but idk how can i use this instance handle for sending keystrokes with controlsend ?

Pic3;

VlByZq.png

Edited by hqq
Link to comment
Share on other sites

  • Moderators

You went from au3info tool to property inspector (no idea what that is)... 

In au3info tool, make sure you have unfrozen the app, placed your mouse over the control/area you want to get data from, and if it's a control you want to interact with, click on the control tab... this will provide you the data you need for the 3rd parameter of ControlSend().  The 3rd parameter takes the "Control ID", "Class Name + Instance number", or the controls "Handle" itself.

Your tool (property inspector) does not provide the class of the control nor the instance number... it's showing you the windows class itself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You went from au3info tool to property inspector (no idea what that is)... 

In au3info tool, make sure you have unfrozen the app, placed your mouse over the control/area you want to get data from, and if it's a control you want to interact with, click on the control tab... this will provide you the data you need for the 3rd parameter of ControlSend().  The 3rd parameter takes the "Control ID", "Class Name + Instance number", or the controls "Handle" itself.

Your tool (property inspector) does not provide the class of the control nor the instance number... it's showing you the windows class itself.

I think you didnt read clearly that what i said.. i want to send keystokes to all window of process not only childwindow of its with controlsend..

As you can see on pic4 Notepad has 2 childwindow , one of them aka Edit1 and i want to send keystrokes to allwindows of notepad.

Pic4;

j4Avgj.png

Edited by hqq
Link to comment
Share on other sites

ControlSetText is way more reliable:

Run("notepad")
$hWin = WinWaitActive("[CLASS:Notepad]")
$hControl = ControlGetHandle($hWin,"",15)
ControlSetText($hWin,"",$hControl,"NEW TEXT!")
ControlSetText($hWin,"",$hControl,ControlGetText($hWin,"",$hControl) & " MORE TEXT!")

It can work without the window being active as well.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

ControlSetText is way more reliable:

Run("notepad")
$hWin = WinWaitActive("[CLASS:Notepad]")
$hControl = ControlGetHandle($hWin,"",15)
ControlSetText($hWin,"",$hControl,"NEW TEXT!")
ControlSetText($hWin,"",$hControl,ControlGetText($hWin,"",$hControl) & " MORE TEXT!")

It can work without the window being active as well.

Its not what im lookin for .. i need to send keystrokes to all window which process has,

so simply ;  send keystrokes directly main window, not to child windows and even its inactive

Edited by hqq
Link to comment
Share on other sites

Well, that's impossible.

Instead, you can get ALL the windows of the process, and ControlSetText to ALL windows.  Or ONLY those windows you want to...you are in control.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

No its not , there should be one way to do it ,  just send keystrokes to mainwindow without controlid or control info even its inactive .. 

Edited by hqq
Link to comment
Share on other sites

Here...but it's not as reliable as controlsettext

Run("notepad")
$hWin = WinWaitActive("[CLASS:Notepad]")
$hControl = ControlGetHandle($hWin,"",15)
; make your window NOT active
Run("notepad")

; loop until it's not active
While WinActive($hWin)
WEnd

ControlSend($hWin,"",$hControl,"NEW TEXT!")
ControlSend($hWin,"",$hControl," MORE TEXT!")

;~ ControlSetText($hWin,"",$hControl,"NEW TEXT!")
;~ ControlSetText($hWin,"",$hControl,ControlGetText($hWin,"",$hControl) & " MORE TEXT!")

If this isn't what you are looking for, then I'm suspect of your motives.

Also, I have verified it's impossible to send to a focused control on an inactive window...workaround, use controlsettext.

Proof of this assertion:

Run("notepad")
$hWin = WinWaitActive("[CLASS:Notepad]")
$hControl = ControlGetHandle($hWin,"",15)
ControlFocus($hWin,"",$hControl)
; make your window NOT active
Run("notepad")

; loop until it's not active
While WinActive($hWin)
WEnd

ControlSend($hWin,"","","NEW TEXT!")
ControlSend($hWin,"",""," MORE TEXT!")

;~ ControlSetText($hWin,"",$hControl,"NEW TEXT!")
;~ ControlSetText($hWin,"",$hControl,ControlGetText($hWin,"",$hControl) & " MORE TEXT!")

data is not populated.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Here...but it's not as reliable as controlsettext

Run("notepad")
$hWin = WinWaitActive("[CLASS:Notepad]")
$hControl = ControlGetHandle($hWin,"",15)
; make your window NOT active
Run("notepad")

; loop until it's not active
While WinActive($hWin)
WEnd

ControlSend($hWin,"",$hControl,"NEW TEXT!")
ControlSend($hWin,"",$hControl," MORE TEXT!")

;~ ControlSetText($hWin,"",$hControl,"NEW TEXT!")
;~ ControlSetText($hWin,"",$hControl,ControlGetText($hWin,"",$hControl) & " MORE TEXT!")

If this isn't what you are looking for, then I'm suspect of your motives.

Its not too , because you are sendin keystrokes to Edit window(child window) of Notepad with controlid(15) , but i want to send keystrokes to main window of notepad 

Link to comment
Share on other sites

Why.  What are you attempting to do, open a menu item?  Explain yourself...there is nothing else on that application that can accept sends.

Use:

WinMenuSelectItem
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Developers

Im showing my problem on notepad , and thats my problem if you know how to solve it , tell me solution , but you dont know please dont talk about other things..

attitude problems?

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

And I'm telling you that notepad can't reproduce what your issue is.  I've provided you workarounds...make it happen on your actual app.

Also, your initial question makes no sense...of course you can't view the control details while focused on the spy tools WINDOW tab...move over to the control tab, and done.

Separate applications may react differently, but notepad.exe will NOT populate the edit while sending to the window, when the window is inactive.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I've already shown you how to interact with notepad, and defined and have proven the limitations of an inactive window...what is the actual application you want to send to.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Just use ControlSend with a blank control id parameter.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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