View Single Post
Old 04-20-2013, 12:00 PM   #106
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,541

Originally Posted by Argitoth View Post
hey spk77 that script is weird in that you must activate it twice for it to select something, or you must have something already selected.

Edit: Hey actually, could you tell me the command for getting the mouse cursor position so I have a choice of edit cursor or mouse cursor? I can't find anything about mouse cursor in the API.

Edit2: What program do you use for scripting this stuff?
Ok, it should work now (added "RPR_UpdateArrange()" at the end)

Yes, there isn't any function to get mouse cursor position. This is how the script works:
- unselect all items first
- get item count with "RPR_CountMediaItems(0)" (0 for active project)
- loop in range(item count)
- get every item's ID, start position and length
  • ID = RPR_GetMediaItem(0, index)
  • StartPos = float(RPR_GetMediaItemInfo_Value(ID, "D_POSITION"))
  • Length = float(RPR_GetMediaItemInfo_Value(ID, "D_LENGTH"))
  • EndPos = StartPos + Length
- "RPR_GetCursorPositionEx(0)" gets edit cursor position in seconds
- if edit cursor position is between item's StartPos and EndPos, set that item selected. "RPR_SetMediaItemInfo_Value(ID, "B_UISEL", 1)"

Sorry, I cannot explain it better.

I'm using PyScripter:

Last edited by spk77; 04-20-2013 at 12:09 PM.
spk77 is offline   Reply With Quote