Sign in to follow this  
Followers 0
StataUser

How to Send() something to a not active window

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

thanks a lot! I used AU3_Spy.exe and than tried a ControlSend, and it worked just like I wanted.

Best,

Eva

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  
Followers 0