Jump to content

ControlSend() help


Recommended Posts

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.

Link to comment
Share on other sites

  • Developers

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

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

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")
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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