aviasd wrote:

> Hi , I've been using powerpro for a while , but there's some feature I 
> have not found ... I want to assign a hotkey to switch between all 
> instances of the current processes - somtehing like alt+tab only for a 
> process.
> 
> I.E - I have 5 instances of putty (among other processes). when I'm on 
> a putty window and press win+w , I switch to the next putty window, and 
> when I click win+shift+w I switch to the previous putty.
> 
> I have this functionality under linux , does anyone know if it can be 
> accomplished via powerpro ?

Hi Avi,

I think it can be accomplished with a script. I don't think that PowerPro has
a built-in way to do what you're asking for.

Here's a basic script that does it. I tested the code very little, you need to 
adapt
it to your needs and debug it more thoroughly. Cut the text below, paste it
into file rotwin.powerpro in the scripts subfolder, then assign [EMAIL 
PROTECTED]
to a hotkey.

Have fun!
--sgp

// rotwin - cycle through a window "process" group

// get the handle of the active window
local h=win.handle("active")
// find its corresponding executable name
local exename = win.exename(h)
// save a list of handles of all visible windows by that exename ("process")
static hs
if( not map.exists(hs) )
  hs = map.create(32) // max 32 "process" groups
hs[exename] = win.handlelist("="++exename,0) // 0 for visible windows only
/*
at which point the script needs to decide what "next window" means
wrt the current (active) window. I'm not going deep into that, as it's a matter
of taste. The reason I declared hs static above, is so that you can find
it again the next time the script is re-executed upon pressing the hotkey.
It is not necessary, but it sets a base to compare the new list of handles
with the previous list of handles.  They will most likely differ, for two
reasons. a) you may have closed some windows;
b) caveat: win.handlelist() doesn't return an ordered list
of handles. Given the same three windows A, B and C, win.handlelist
may return A, B, C once, and B, C, A the next time it's called.

  So let's continue...
*/
// 4. determine the "next window"
local nw = [EMAIL PROTECTED](hs[exename],exename)
// 5. and finally switch to the next window
window.show_(nw) // _ avoids error message if nw not found
quit

// find and remember the next window of a group
@NextWindow
args handles, group
static previous
local i, v

if( not map.exists(previous) )
  previous = map.create(32)
// below we sort the handles to work-around the handlelist caveat
// (it isn't a complete solution...)
v = vec.createfromwords(handles)
vec.sort(v)
handles = vec.makewords(v)
// then we look for the previous window possibly wrapping around the handles
handles = " "++handles++" "++handles++" "
i = index(handles, " "++previous[group]++" ")
if( i )do // previous found, now get out next
  handles = remove(handles, i)
  i = nextword(handles,"handles")
  i = nextword(handles,"handles")
else
  // previous window not found, return the first handle in the list
  i = nextword(handles,"handles")
  i = nextword(handles,"handles")
endif

previous[group] = i
quit(i)

Reply via email to