Jump to content

How to Send() something to a not active window


Recommended Posts

Dear all,

I am a Newbie with AutoIt. Please excuse if this is very basic. What I try to do:

Process my Stata do-files (Stata is a statistics software) from within my favourite text editor WinEdt. Stata should be opened, if not already running, but not made active. Then the line "do $CmdLine[1] {Enter}" should be sent to the command line of Stata. I have some problems doing this. Here is what I tried (I found this on statalist: http://www.stata.com/statalist/archive/200...msg00699.html):

If WinExists("Intercooled Stata 8.2") Then
    WinWaitActive("Intercooled Stata 8.2")
    Send("do " & '"' & $CmdLine[1] & '"' & "{Enter}")
Else
   ;Run Stata
    Run("C:/Programme/Stata8/wstata.exe")
    WinWaitActive("Intercooled Stata 8.2")
    Send("do " & '"' & $CmdLine[1] & '"' & "{Enter}")
EndIf

With this, the line "do $CmdLine[1]" is only executed when I click on the Stata window to make it active. But I would rather like to skip this and directly look at the log file in the editor. So I tried with

WinWait("Intercooled Stata 8.2")

instead, but this resulted in

"do " & '"' & $CmdLine[1] & '"' & "{Enter}"
being send to my editor window instead, if Stata was not already running.

Is there some way I can do this? It is very important that I can also send the {Enter} , else Stata won't execute the do-file. I'd be grateful for any pointers.

Best,

Eva

Link to comment
Share on other sites

  • Developers

You could do it this way:

WinWait("Intercooled Stata 8.2")
WinActivate("Intercooled Stata 8.2")
Send("do " & '"' & $CmdLine[1] & '"' & "{Enter}")

Or check if you can do a ControlSend which is even better, but you need to figure out the control to send it to. This can be done wit AU3_Spy.exe.

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

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