Jump to content

Sending keystokes to a hidden window?


Recommended Posts

Hi, I'm just a noobie in the world of AutoIt, and really I'm just messing around with the funtions right now. I'm trying to get an AutoIt program to send text to a hidden notepad window. I know it can be done because I used to have an example program a while back that did this. That example got lost when i formatted my hard drive :whistle: . I've posted my script below:

Run("Notepad.exe")
Sleep(500)
Send("Hello{Enter}")
Sleep(500)
WinSetTitle("Untitled - Notepad", "Hello", "Hiding")
Sleep(500)
Send("Hiding window...{Enter}")
Sleep(500)
WinSetState("Hiding", "Hiding window...", @SW_HIDE)
Sleep(500)
ControlSend("Hiding", "Hiding window...", 15, "The window was hidden when this was typed.")
Sleep(500)
WinSetState("Hiding", "Hiding window...", @SW_SHOW)
Sleep(500)
Send("This program will now shut down.{Enter}")
Sleep(100)
Send("!{F4}")
Sleep(500)
Send("N")
Sleep(100)
Exit

Thank You in advance for all your guys help.

- Dan [Website]

Link to comment
Share on other sites

You cannot interact with hidden windows using Send. You need ControlSend or ControlSetText for this example.

This works fine.

Run('Notepad', '', @SW_HIDE)
WinWait('Untitled')
ControlSend('Untitled', '', 'Edit1', 'Some text')
Sleep(1000)
WinSetState('Untitled', '', @SW_SHOW)

ControlSend does not need an Active window as was incorrectly mentioned in the link.

:whistle:

Edited by MHz
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...