the script algorithm is:

*take the window name
if (the window name exists but not active)
  *bring the first window that matches the name
else if (the window name exists and active)
  if (only one window with the same name exists)
    *bring back preview window
  else
    *bring the next window that matches the name
else if (the window name doesn't exist)
  *execute the program

==============================================================
It seems an easy task to do. But if taking a closer look, we'll find that 
window.backshow();win.back() all broken. All we can count on is win.show().
Below is the script. 
the usage:
take an example: set hot key ctrl+alt+a to execute 
.bringup_prog("=acrobat,&,*Adobe Acrobat Professional", "d:\\program 
files\\Adobe\\Acrobat 8.0\\Acrobat\\acrobat.exe")
==============================================================
bringup_win.powerpro:
==============================================================
local prog_name =arg(1)
local hlist = win.handlelist(prog_name)
local prog_path = arg(2)
local listnum=0
local handle=0
static pos, preforewin

;win.debug("hlist: "++hlist++" ;"++"preforewin: "++preforewin)

if(hlist != "") do
  local hforewin = window("firstwindow", "active")
  for (listnum=1; ;listnum=listnum+1)
    handle = word(hlist,listnum)
    if (handle == "") do
    listnum = listnum-1
      break
    endif
  endfor
  ;win.debug("pos: "++pos++" ;"++"listnum: "++listnum)
  if(hforewin!=word(hlist,1))do
    ;win.debug("not active")
    preforewin = hforewin
    pos=1
    win.show(word(hlist,1),1)
  else
    ;win.debug("active")
    if(listnum==1) do
      win.show(preforewin)
    else
      if(pos+1>listnum) do
      win.show(word(hlist,listnum),1)
      ;win.debug("list end")
    else
      win.show(word(hlist,pos+1),1)
      ;win.debug("next")
    endif
    pos=pos+1
    endif
  endif
else
  do(prog_path, "", "", "")
endIf

Reply via email to