I just discovered that note.opencategory opens all notes associated to a
program even if that program isn't running. This enables full automation.
Now the script cycles through all note folders, opens all its notes, and snaps
them. When the script is done, click on the desktop to auto-close all
irrelevant notes.

--- script start ---

;: @SnapAllToWinExes() - snap all !* notes to the window of their
;: running associated application -- assign to a hotkey or to an event
function SnapAllToWinExes()
; step 1: open all !* category notes
local pn=pprofolder++?"Notes\"
file.allfiles(pn++"!*";;+
,"note.opencategory(_file_.remove(pn.length))";;+
,4,50)
; step 2: snap notes
local n,nc,nh,nhl,oh,ohl,xy
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
      // caveat: unless note is ontop exe window may cover it
    endif
  endif
endfor
; step 3: user clicks on desktop to auto-close irrelevant !* category notes
quit

--- script end ---

 

Reply via email to