Sign in to follow this  
Followers 0
Smiley357

ControlSend() help

4 posts in this topic

Ok I dont get it. All the post I have read say to use Controlsend() to send text to a minimized window. I have tried and it doesnt work for me. Could someone explain what Im doing wrong? Here is my code.

$hGUI = WinGetHandle(Run("notepad.exe"))
WinWaitActive("Untitled - Notepad")
Sleep(4000)

ControlSend("Untitled - Notepad" , "", $hGUI, "This is a line of text in the first notepad window {enter}")

It is simple. Opens up notepad and gives me 4 seconds to minimize notepad then suppose to send the text the minimize notepad.

What happens is notepad opens I minimize it and no text is sent to notepad. If I dont minimize it the text is sent to notepad. Can someone please show me my mistake? Thanks for all help and ideas.

Share this post


Link to post
Share on other sites



This doesn't look rigth: WinGetHandle(Run("notepad.exe"))

The run command returns a handle and the WinGetHandle() needs Title,Text aa parameter.

ControlSend() needs the ControlHandle in stead of the Window handle.

Enough for you to work on?

muttley


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

SOLVED!!!

Jos, thank you so much for the help. That answered my question. OMG I was starting to get a headache from beating my head on my desk so much. LOL

My goal was to send text to 2 different windows that is minimized. Here is my simple code if anyone is having the same issue.

AutoItSetOption("WinTitleMatchMode", 4)

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
$handle = WinGetHandle("classname=Notepad")
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
$handle2 = WinGetHandle("classname=Notepad")
Sleep(4000)
ControlSend($handle, "", "Edit1", "AbCdE")
ControlSend($handle2, "", "Edit1", "FGHIJ")

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm using a script wich will run "cmd" but everytime I open another "cmd" Command Prompt window it will write in this last active window.

Here is a part from the code:

AutoItSetOption ( "WinTitleMatchMode" , 4)

WinWaitActive("system32")
;WinWaitActive("[CLASS:ConsoleWindowClass]")

handle = WinGetHandle ("classname=telnet")
Sleep (1000)
ControlSend ($handle,"","","{Enter}")

What am I doing wrong ?

You are using classname not CLASS. Why ?AutoIt v3 Window Info is showing Class for a window property...

Edited by mentosan

Share this post


Link to post
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
Sign in to follow this  
Followers 0