Jump to content

Recommended Posts

Posted

Hi all-

I have used autoIt succesfully for many months now. It last worked for me on Friday Jan 12th. It is not working now.

I have 2 scripts for TextPad which are used to run an entire .do file in stata or run highlited lines. I have only used autoIt for these 2 scripts.

I am using autoIt v3 (and tried upgrading to 3.2.2, but that didn't help), textpad v 4.7.3 & stata 8.2.

I do not believe I am having virus issues since my Norton Quarantine does not list any files or other warnings, etc.

The error I get when running either script is "The system cannot find the file specified." I have not changed my stata, textpad or autoIt configurations since Friday. I work at a large company, so it is possible my windows configuration has changed since Friday without my knowledge. I have pasted one of the scripts which fails below.

Any suggestions would be really appreciated as this is one of my most useful little tools!

Thank you in advance,

Zachary Harrison

; AutoIt v3 script to run a Stata do-file from an external text editor.

; Version 2.2, Friedrich Huebler (fhuebler at gmail.com), 26 September 2005.

; Updated by Nicholas Winter (nw53 at cornell.edu), 25 May 2005.

; Adapted from a script by Dimitriy V. Masterov

; (dvmaster at lily.src.uchicago.edu), 23 June 2004.

; AutoIt is available at http://www.autoitscript.com/autoit3/.

; The latest version of this script is at

; http://huebler.info/2005/20050310_Stata_editor.html.

; Declare variables

Global $statapath, $statawin, $dofile

$OldClip = ClipGet()

; EXAMPLE: For Intercooled Stata 8.2 delete preceding block and use commands below

$statapath = "C:/Program Files/Stata8/wstata.exe"

$statawin = "Intercooled Stata 8.2"

; NOTE: Edit this block of commands to match the editor used

; EmEditor or TextPad: path of do-file is passed to AutoIt

$dofile = $CmdLine[1]

; Alternative method to obtain path of do-file with TextPad

; Get path of do-file from title of TextPad window

$dofile = WinGetTitle("")

; Remove unwanted text from window title to keep path only

$dofile = StringReplace($dofile,"TextPad - ","")

$dofile = StringReplace($dofile,"[","")

$dofile = StringReplace($dofile,"]","")

; If more than one Stata window is open, the window

; that was most recently active will be matched

Opt("WinTitleMatchMode",2)

; Reduce SendKeyDelay and WinWaitDelay to speed up script

Opt("SendKeyDelay", 1)

Opt("WinWaitDelay", 200)

; Check if Stata is already open, run it if not

If WinExists($statawin) Then

WinActivate($statawin)

WinWaitActive($statawin)

; Activate Stata Command Window and select text (if any)

Send("^4")

Send("^a")

; Run saved do-file

; Double quotes around $dofile needed in case path contains blanks

ClipPut("do " & '"' & $dofile & '"')

; Pause avoids problem with clipboard, may be AutoIt or Windows bug

Sleep(100)

Send("^v" & "{Enter}")

Else

;Run($statapath)

_RunDOS($statapath)

WinWaitActive($statawin)

; Activate Stata Command Window

Send("^4")

; Run saved do-file

; Double quotes around $dofile needed in case path contains blanks

ClipPut("do " & '"' & $dofile & '"')

; Pause avoids problem with clipboard, may be AutoIt or Windows bug

Sleep(100)

Send("^v" & "{Enter}")

EndIf

ClipPut($OldClip)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...