opening email app in Windows

Ken Ray kray at sonsothunder.com
Sat May 20 22:45:24 EDT 2006


On 5/20/06 1:02 AM, "Peter Brigham" <pmbrig at comcast.net> wrote:

> All I want is  
> to be able to activate the email app's frontmost window (which will
> be the mostly-completed message).

Well, this isn't quite as easy as it might sound because each window in
Windows has its own "handle" which is (oddly enough) accessible based on the
title in the titlebar of the window. You can also activate the window if you
know what the process ID of the window is. In either case, you can use this
code (which uses VBScript to do the dirty work):

on VBS_AppActivate pTitleOrID
  put format("set WshShell = WScript.CreateObject(\"WScript.Shell\")") into
tVBS
  if isNumber(pTitleOrID) then
    put tVBS & cr & "WshShell.AppActivate" && pTitleOrID into tVBS
  else
    put tVBS & cr & "WshShell.AppActivate" && quote & pTitleOrID & \
      quote into tVBS
  end if
  put "C:\vbs_temp.vbs" into tVBSPath
  put tVBS into url ("file:" & tVBSPath)
  set the hideConsoleWindows to true
  get shell("cscript.exe //nologo" && tVBSPath)
  put it into tResult
  if there is a file tVBSPath then
    send "delete file" && quote & tVBSPath & quote to me in 1 second
  end if
  if tResult <> "" then return "Error: " & tResult
end VBS_AppActivate

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list