Hi Dedebaykus, here something to get you started.
It works for me, but I tested it very little.
As far as I can tell, there's no way to snap all open notes to their
associated windows all at once. You have to select the window
then run the script. This is because notes that are associated to
windows are open only while the window is selected. Special case,
the window may not be selected but it was selected and and you
just switched to a console window. Anyway, if you discover that
multiple notes can be open at the same time this script should
handle that case.

Some possible improvements for this script:

* Now the note snaps to the top,left window coordinate.
Possibly you'd like it to snap somewhere else.

* Now the script selects the first window handle which is associated to the 
note.
What constitutes the "first" handle is left to Window's engine to decide,
you may want to change that. For instance, with some calculations you
could pick the matching window that's closest to the note's current
position - sort of an "attractor" mode. This case may occur, for instance,
if you have two notepads open and two notes that are associated with
notepad (admittedly a rare case I would say).
Or this case may occur, I think, when an application opens
multiple visible windows. In which case you'll want to decide which
of those is your snap target.

* If you're interested in automating note positioning for all open
windows, you could make the script cycle through all visible windows, select 
(raise)
each window so that its associated note, if any, becomes visible, then
make the note snap to the window. I think it's an overkill, but you could do it.

Anyway, HTH and if you make some improvements please share. I'm interested
in this functionality myself, but I have very little time to further 
investigate it.

--sgp

; ---script begin--- (tested very little!)

;: @SnapAllToWinExes(nh) - snap all open notes to the window of their
;; associated exe file -- assign to a hotkey or to an event
function SnapAllToWinExes() 
local n,nc,nh,nhl,oh,ohl,xy
//nhl=win.handlelist("c=PowerProNote",1) // visible notes
nhl=note.handlelist // open notes
for(n=nhl.word(0);n>0;n--)
  nc=note.getcategory(nhl.word(n))
  if( "!" == nc.select(1) )do
    ohl=win.handlelist(nc.remove(1),1) // nc's visible windows
    oh=ohl.word(1) // customize window handle selection criteria
    if( oh )do
      nh=nhl.word(n) // snap note nh...
      xy=oh.getrect // ... to selected window's left,top (xy)
      nh.move(xy.word(1),xy.word(2)) // customize positioning criteria
    endif
  endif
endfor

; ---script end---

Reply via email to