Jump to content
Sign in to follow this  
dandymcgee

Sending keystokes to a hidden window?

Recommended Posts

dandymcgee

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]

Share this post


Link to post
Share on other sites
dandymcgee

OH yeah, I wanted to know why every once in a while ill find a thread in which the same person periodically types "BUMP"? LOL this is probably a very noob question but thanks.


- Dan [Website]

Share this post


Link to post
Share on other sites
Briegel

In this thread you can find the answer.

good luck

Share this post


Link to post
Share on other sites
MHz

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

Share this post


Link to post
Share on other sites
dandymcgee

thanks guys


- Dan [Website]

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  

×