[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Simple Stata browser toggle using Autoit

From   Gawrich Stefan <>
To   "''" <>
Subject   st: Simple Stata browser toggle using Autoit
Date   Fri, 31 Aug 2007 16:15:08 +0200

Hi Statalisters,

for those who are interested here's a little Autoit script to toggle the
Stata browser window (only for Windows OS).
I use the Stata browser extensively for quick data checks and often forget
to close the window before running the next part of code from my external
editor. Opening and closing the browser with one shortcut from anywhere in
Windows saves me a lot of clicking in daily work. 

The script uses code snippets of Friedrich Hueblers editor integration
scripts (see and the
extention of these scripts by Jeffrey Arnold
(, who already
implemented a browser window closing routine into the editor integration

The script runs outside Stata. I named it browsertoggle.au3 and after
compiling (now browsertoggle.exe) put it on the desktop and assigned a
shortcut (e.g. Ctrl + F12) to it. Stata must be running but not necessarily
be the active window. Comments and improvements are welcome. 

Stefan Gawrich
Hesse State Health Office
** Adjust path and stata version; use Autoit to compile script 

; start of script
; Declare variables
Global $statapath, $statawin

; NOTE: Edit $statapath and $statawin 
; Path to Stata executable
$statapath = "S:/stata/wstata.exe"
; Title of Stata window
$statawin = "Stata/IC"
;the last active Stata Window will be matched
; Reduce SendKeyDelay and WinWaitDelay to speed up script
Opt("SendKeyDelay", 1)
Opt("WinWaitDelay", 200)

; only when Stata is running
If WinExists($statawin) Then
; if browser is open : close browser
   If WinExists("Data Browser") Then
       WinClose("Data Browser")
       WinWaitClose("Data Browser")
;if browser is closed : open browser	   
   ElseIf Not WinExists("Data Browser") Then
	;Activate Stata Command Window and select text (if any) to delete
it. Input "browse" and press ENTER
	  Send("browse" & "{Enter}")
; end of script  

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index