-- -- drag timeslider with mouse moving over viewport without clicking mouse button. -- with ctrl pressed it snaps to keyframes. -- v1.0 -- tested with max 2011 -- huijunpark@gmail.com -- macroScript timeSliderControl category:"HJ Tools" buttonText:"TimeSlider Control" toolTip:"TimeSlider Control" ( fn getMapVal arr v = ( arrD = for i in arr collect abs (v - i) ixMin = finditem arrD (amin arrD) arr[ixMin] ) arrKeyFrame = #() for t = animationrange.start-1 to animationrange.end-1 do appendifunique arrKeyFrame (at time t trackbar.getNextKeyTime()) arrKeyMap = if arrKeyFrame[1] != undefined then for t=animationrange.start to animationrange.end collect (getMapVal arrKeyFrame t) else undefined tool timesliderDrag ( local sFrame = animationrange.start.ticks / ticksPerFrame local frameRange = (animationrange.end.ticks / ticksPerFrame) - sFrame + 1 local r = 1. * frameRange / gw.getWinSizex() on freeMove do ( setArrowCursor() t = sFrame + (r * mouse.pos.x) as integer slidertime = if ctrlKey and arrKeyMap != undefined then arrKeyMap[t - sFrame + 1] else t ) on mousePoint clickno do #stop on mouseAbort arg do #stop ) starttool timesliderDrag -- stoptool timesliderDrag )