Statalist


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

st: Simple Stata browser toggle using Autoit


From   Gawrich Stefan <[email protected]>
To   "'[email protected]'" <[email protected]>
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 http://huebler.info/2005/20050310_Stata_editor.html) and the
extention of these scripts by Jeffrey Arnold
(http://www.stata.com/statalist/archive/2006-08/msg00894.html), who already
implemented a browser window closing routine into the editor integration
scripts. 

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
Dillenburg
Germany
 
 
***********************************************************
** 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
opt("WinTitleMatchMode",2)
; Reduce SendKeyDelay and WinWaitDelay to speed up script
Opt("SendKeyDelay", 1)
Opt("WinWaitDelay", 200)

; only when Stata is running
If WinExists($statawin) Then
  WinActivate($statawin)
  WinWaitActive($statawin)
; 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("^4")
	  Send("^a")
	  Send("browse" & "{Enter}")
  Endif
Endif
; end of script  

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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