Jump to content

How to send keystrokes to a minimised app without changing focus


GDB2222
 Share

Recommended Posts

I want to continue working on whatever else I happen to be doing and occasionally send some text to another, minimised, application using autoit. Ideally, I don't want to be aware that this is happening. So far, the best I have been able to come up with is to switch focus, send the keys, then switch back to the original app. The code is as follows:

$handleAct = WinGetHandle("[ACTIVE]") ; Get handle of current application

$handleNotepad = WinGetHandle("Untitled - Notepad") ; Get handle of Notepad - which is already running

Sleep (5000) ; Continue to work on current app

WinActivate ($handleNotepad) ; activate notepad and send some text

send("text to notepad {ENTER}")

send("text2 to notepad {ENTER}")

WinActivate($handleAct) ; revert back to original app

This is very clunky. There must be a better way, no?

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...