Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER General Discussion Forum

Reply
 
Thread Tools Display Modes
Old 03-09-2022, 10:13 AM   #1
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default Recent(last modified) Project in Media Explorer

THANKS Edgemeal

****** only from version v6.52+dev0327 - March 27 2022**********
-
Recent Project
Open Media Explorer
SetDatabase
Scan Database for new files
set search ".rpp"
sort file list "Modified" (42254) 2 times
--------------------------------------------------
Yellow.rpp is loaded, edited and saved.
The next time you start Media Explorer, Yellow.rpp comes first

Code:
-- Show Media Explorer, set path, search and sort last modified
-- v1.03 - Edgemeal - Mar 22, 2021
-- Donate: https://www.paypal.me/Edgemeal
--
-- Tested: Win10/x64, REAPER v6.51+dev0318/x64, js_ReaScriptAPI v1.301
-- v1.03... Wait time set in seconds, added delay before scrolling to top.
-- v1.02.1. Scroll list to top after sort.
-- v1.02... Make filelist global, unselect files in list before sorting.



-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --
local path = "Projectmanager"
local search = ".rpp"
local wait = 0.600 -- Explorer needs time to update/populate, set Time in seconds to wait between actions.
-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --


-- setup >>
if not reaper.APIExists('JS_Window_SetTitle') then
  reaper.MB('js_ReaScriptAPI extension is required for this script.', 'Missing API', 0)
  return
end
-- open explorer/make visible/select it
local explorer = reaper.OpenMediaExplorer("", false)
if not explorer then
  reaper.Main_OnCommand(50124, 0) -- Media explorer: Show/hide media explorer
  explorer = reaper.OpenMediaExplorer("", false)
end
-- get search combobox, show explorer if docked and not visible
local cbo_search = reaper.JS_Window_FindChildByID(explorer, 0x3F7)
if not cbo_search then return end
if not reaper.JS_Window_IsVisible(cbo_search) then reaper.Main_OnCommand(50124, 0) end
-- get file list
local filelist = reaper.JS_Window_FindChildByID(explorer, 0x3E9)
-- variable for wait timer
local init_time = reaper.time_precise()
--<< setup

function PostKey(hwnd, vk_code) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYDOWN", vk_code, 0,0,0)
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYUP", vk_code, 0,0,0)
end

function PostText(hwnd, str) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-char
  for char in string.gmatch(str, ".") do
    local ret = reaper.JS_WindowMessage_Post(hwnd, "WM_CHAR", string.byte(char),0,0,0)
    if not ret then break end
  end
end

function SetExplorerPath(hwnd, folder)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3EA)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, folder)
    PostKey(edit, 0xD)
  end
end

function SetExplorerSearch(hwnd, text)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3F7)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, text)
    PostKey(edit, 0xD)
  end
end


function SortDateModified()
  if reaper.time_precise() < init_time then
    reaper.defer(SortDateModified)
  else
    reaper.JS_Window_SetFocus(filelist) -- Set focus on Media Explorer file list.
    reaper.JS_ListView_SetItemState(filelist, -1, 0x0, 0x2) -- unselect items in file list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42256,0,0,0) -- "sort title" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42085,0,0,0) -- rescan database for new files    
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    init_time = reaper.time_precise() + wait
    ScrollToTop()
  end
end

function ScrollToTop()
  if reaper.time_precise() < init_time then
    reaper.defer(ScrollToTop)
  else
    reaper.JS_WindowMessage_Send(filelist, "WM_VSCROLL", 6,0,0,0) -- scroll list to top
  end
end

function Main() 
  SetExplorerPath(explorer, path)       -- set path field
  SetExplorerSearch(explorer, search)   -- set search field 
  init_time = reaper.time_precise() + wait
  SortDateModified()
end

function Initalize() 
  if reaper.time_precise() < init_time then
    reaper.defer(Initalize)
  else
    Main()
  end
end

init_time = reaper.time_precise() + wait
Initalize()

Last edited by Dragonetti; 07-03-2022 at 06:04 AM.
Dragonetti is offline   Reply With Quote
Old 03-10-2022, 04:09 AM   #2
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@Edgemeal

Is it possible to scroll up again vertically at the end of the script.
The top entry is not displayed. (.mp3 search)
thanks
Dragonetti is offline   Reply With Quote
Old 03-10-2022, 09:52 AM   #3
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Dragonetti View Post
Is it possible to scroll up again vertically at the end of the script.
I only tested this separately, but if placed after the "sort modified file" list code, hopefully it will work.
Code:
local filelist = reaper.JS_Window_FindChildByID(explorer, 0x3E9)
reaper.JS_WindowMessage_Send(filelist, "WM_VSCROLL", 6,0,0,0) -- SB_TOP=6
EDIT Replaced "0x115" with "WM_VSCROLL" (already defined in the API).

Last edited by Edgemeal; 03-10-2022 at 10:19 AM.
Edgemeal is offline   Reply With Quote
Old 03-10-2022, 11:59 AM   #4
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Thanks
Doesn't work yet, I'll keep trying.
Dragonetti is offline   Reply With Quote
Old 03-21-2022, 07:14 AM   #5
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Dragonetti View Post
Thanks
Doesn't work yet, I'll keep trying.
Explorer auto scrolls the selected file into view, and it remembers what file was selected even when changing folders. My guess is you have files selected, so I set this up to unselect the files before the sorting. I removed WM_VSCROLL calls, if really needed it would be right after the sorting calls.

Code:
-- Show Media Explorer, set path, search and sort last modified
-- v1.02.1 - Edgemeal - Mar 21, 2021
-- Donate: https://www.paypal.me/Edgemeal
--
-- Tested: Win10/x64, REAPER v6.51+dev0318/x64, js_ReaScriptAPI v1.301
-- v1.02.1. Scroll list to top after sort.
-- v1.02... Make filelist global, unselect files in list before sorting.


-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --
local path = "Projectmanager"
local search = ".rpp"
-- Before sending actions Explorer needs time to update/populate! Higher number = longer wait time.
local m_wait = 20 -- wait after open to set path and search.
local r_wait = 20 -- wait before calling sort file list.
-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --

-- setup >>
if not reaper.APIExists('JS_Window_SetTitle') then
  reaper.MB('js_ReaScriptAPI extension is required for this script.', 'Missing API', 0)
  return
end

-- open explorer/make visible/select it
local explorer = reaper.OpenMediaExplorer("", false)
if not explorer then
  reaper.Main_OnCommand(50124, 0) -- Media explorer: Show/hide media explorer
  explorer = reaper.OpenMediaExplorer("", false)
end

local cbo_search = reaper.JS_Window_FindChildByID(explorer, 0x3F7)
if not cbo_search then return end
if not reaper.JS_Window_IsVisible(cbo_search) then reaper.Main_OnCommand(50124, 0) end

local filelist = reaper.JS_Window_FindChildByID(explorer, 0x3E9)
--<< setup

function PostKey(hwnd, vk_code) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYDOWN", vk_code, 0,0,0)
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYUP", vk_code, 0,0,0)
end

function PostText(hwnd, str) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-char
  for char in string.gmatch(str, ".") do
    local ret = reaper.JS_WindowMessage_Post(hwnd, "WM_CHAR", string.byte(char),0,0,0)
    if not ret then break end
  end
end

function SetExplorerPath(hwnd, folder)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3EA)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, folder)
    PostKey(edit, 0xD)
  end
end

function SetExplorerSearch(hwnd, text)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3F7)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, text)
    PostKey(edit, 0xD)
  end
end

function Main()
  if explorer then
    SetExplorerPath(explorer, path)       -- set path field
    SetExplorerSearch(explorer, search)   -- set search field
    reaper.JS_Window_SetFocus(filelist) -- OPTIONAL: Set focus on Media Explorer file list.
    SortDateModified() -- Gives REAPER time to finish populating file list before sorting!
  end
end

function SortDateModified()
  r_wait = r_wait -1
  if r_wait > 0 then
    reaper.defer(SortDateModified)
  else
    reaper.JS_ListView_SetItemState(filelist, -1, 0x0, 0x2) -- unselect all items in file list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42085,0,0,0) -- rescan database for new files
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(filelist, "WM_VSCROLL", 6,0,0,0) -- scroll list to top, else may be below top!(SB_TOP=6)
  end
end

function Initalize()
  m_wait = m_wait -1
  if m_wait > 0 then
    reaper.defer(Initalize)
  else
    Main()
    end
end

Initalize()

Last edited by Edgemeal; 03-21-2022 at 09:10 AM. Reason: v1.02.1 - Scroll list to top after sort!
Edgemeal is offline   Reply With Quote
Old 03-21-2022, 07:49 AM   #6
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Thanks, but
If I save a new project and then call up the Media Explorer, the new one isn't visible, it has to be scrolled up first.

The sort function by "last modified" works better now if I sort by something else first(title)

edit:if I call twice, then it works.



Code:
function SortDateModified()
  r_wait = r_wait -1
  if r_wait > 0 then
    reaper.defer(SortDateModified)
  else
    reaper.JS_ListView_SetItemState(filelist, -1, 0x0, 0x2) -- unselect all items in file list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42085,0,0,0) -- rescan database for new files
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42256,0,0,0) -- "sort title" list   
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(filelist, "WM_VSCROLL", 6,0,0,0) -- SB_TOP=6
  end
end
Dragonetti is offline   Reply With Quote
Old 03-21-2022, 08:17 AM   #7
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Dragonetti View Post
Thanks, but
If I save a new project and then call up the Media Explorer, the new one isn't visible, it has to be scrolled up first.

The sort function by "last modified" works better now if I sort by something else first(title)

edit:if I call twice, then it works.
Whatever works I suppose.

EDIT
But even with code I posted I had to add a WM_VSCROLL call after sorting or the list is not at the top as you said!

TEST (without 'scroll to top' code)... Search projects folder for ".Wav"...
I record one new track (WAV), save project, run script, and list is scrolled 1 item below the top.
I record two tracks, save project, run script, and the list is scrolled 2 items below the top!
Its like REAPER still tries to scroll the old list of items into view and ignores the newest files.

Last edited by Edgemeal; 07-03-2022 at 07:43 AM.
Edgemeal is offline   Reply With Quote
Old 03-22-2022, 07:23 AM   #8
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@edgemeal
Sorry but I don't understand.
Is it now possible (with code) to scroll up to see the new mp3?
Or is it not possible.
Thanks
Dragonetti is offline   Reply With Quote
Old 03-22-2022, 09:14 AM   #9
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Weird, it was scrolling to top OK for me yesterday, but now its not (testing with much bigger database now). So I made a few changes, The wait time is now set in seconds, currently set to 400ms, and the scroll call is now delayed which fixed that issue here. Fingers crossed!

Code:
-- Show Media Explorer, set path, search and sort last modified
-- v1.03 - Edgemeal - Mar 22, 2021
-- Donate: https://www.paypal.me/Edgemeal
--
-- Tested: Win10/x64, REAPER v6.51+dev0318/x64, js_ReaScriptAPI v1.301
-- v1.03... Wait time set in seconds, added delay before scrolling to top.
-- v1.02.1. Scroll list to top after sort.
-- v1.02... Make filelist global, unselect files in list before sorting.



-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --
local path = "Projectmanager"
local search = ".rpp"
local wait = 0.400 -- Explorer needs time to update/populate, set Time in seconds to wait between actions.
-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --


-- setup >>
if not reaper.APIExists('JS_Window_SetTitle') then
  reaper.MB('js_ReaScriptAPI extension is required for this script.', 'Missing API', 0)
  return
end
-- open explorer/make visible/select it
local explorer = reaper.OpenMediaExplorer("", false)
if not explorer then
  reaper.Main_OnCommand(50124, 0) -- Media explorer: Show/hide media explorer
  explorer = reaper.OpenMediaExplorer("", false)
end
-- get search combobox, show explorer if docked and not visible
local cbo_search = reaper.JS_Window_FindChildByID(explorer, 0x3F7)
if not cbo_search then return end
if not reaper.JS_Window_IsVisible(cbo_search) then reaper.Main_OnCommand(50124, 0) end
-- get file list
local filelist = reaper.JS_Window_FindChildByID(explorer, 0x3E9)
-- variable for wait timer
local init_time = reaper.time_precise()
--<< setup

function PostKey(hwnd, vk_code) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYDOWN", vk_code, 0,0,0)
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYUP", vk_code, 0,0,0)
end

function PostText(hwnd, str) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-char
  for char in string.gmatch(str, ".") do
    local ret = reaper.JS_WindowMessage_Post(hwnd, "WM_CHAR", string.byte(char),0,0,0)
    if not ret then break end
  end
end

function SetExplorerPath(hwnd, folder)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3EA)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, folder)
    PostKey(edit, 0xD)
  end
end

function SetExplorerSearch(hwnd, text)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3F7)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, text)
    PostKey(edit, 0xD)
  end
end


function SortDateModified()
  if reaper.time_precise() < init_time then
    reaper.defer(SortDateModified)
  else
    reaper.JS_Window_SetFocus(filelist) -- Set focus on Media Explorer file list.
    reaper.JS_ListView_SetItemState(filelist, -1, 0x0, 0x2) -- unselect items in file list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42256,0,0,0) -- "sort title" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42085,0,0,0) -- rescan database for new files    
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    init_time = reaper.time_precise() + wait
    ScrollToTop()
  end
end

function ScrollToTop()
  if reaper.time_precise() < init_time then
    reaper.defer(ScrollToTop)
  else
    reaper.JS_WindowMessage_Send(filelist, "WM_VSCROLL", 6,0,0,0) -- scroll list to top
  end
end

function Main() 
  SetExplorerPath(explorer, path)       -- set path field
  SetExplorerSearch(explorer, search)   -- set search field 
  init_time = reaper.time_precise() + wait
  SortDateModified()
end

function Initalize() 
  if reaper.time_precise() < init_time then
    reaper.defer(Initalize)
  else
    Main()
  end
end

init_time = reaper.time_precise() + wait
Initalize()
Edgemeal is offline   Reply With Quote
Old 03-22-2022, 09:22 AM   #10
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

if I restart reaper and then call the script, the search entry is missing

Last edited by Dragonetti; 03-22-2022 at 09:33 AM.
Dragonetti is offline   Reply With Quote
Old 03-22-2022, 09:36 AM   #11
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Dragonetti is offline   Reply With Quote
Old 03-22-2022, 09:48 AM   #12
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

I didn't change anything in that part, but the wait time is shorter, it was ~600ms before and now set to 400ms, maybe try changing wait from 0.400 to 0.600 or maybe even a tad more.

FWIW I'm testing on old i7-3770 PC with projects folder on a WD Black hard drive.

Or maybe adding a delay before search is also needed? Like I said on other thread, we have no events to tell us when the list is done updating, etc, all we can do is add delays between sending messages.
Edgemeal is offline   Reply With Quote
Old 03-22-2022, 09:59 AM   #13
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

with 0.600 it works
thanks
Dragonetti is offline   Reply With Quote
Old 07-03-2022, 05:17 AM   #14
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@edgemeal
I can't integrate the loading of a column preset into your script.new feature in REAPER 6.62
reaper.Main_OnCommand(42339,0) --Media_Explorer load column Preset 2
I've copied it to many places.
Thanks
Dragonetti is offline   Reply With Quote
Old 07-03-2022, 05:27 AM   #15
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

I integrated the line and now it works.

reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42339,0,0,0)-- "column preset2"
Code:
-- Show Media Explorer, set path, search and sort last modified
-- v1.03 - Edgemeal - Mar 22, 2021
-- Donate: https://www.paypal.me/Edgemeal
--
-- Tested: Win10/x64, REAPER v6.51+dev0318/x64, js_ReaScriptAPI v1.301
-- v1.03... Wait time set in seconds, added delay before scrolling to top.
-- v1.02.1. Scroll list to top after sort.
-- v1.02... Make filelist global, unselect files in list before sorting.



-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --
local path = "Projectmanager"
local search = ".mp3"
local wait = 0.600

-- Explorer needs time to update/populate, set Time in seconds to wait between actions.
-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS --


-- setup >>
if not reaper.APIExists('JS_Window_SetTitle') then
  reaper.MB('js_ReaScriptAPI extension is required for this script.', 'Missing API', 0)
  return
end
-- open explorer/make visible/select it
local explorer = reaper.OpenMediaExplorer("", false)
if not explorer then
  reaper.Main_OnCommand(50124, 0) -- Media explorer: Show/hide media explorer
  explorer = reaper.OpenMediaExplorer("", false)
end
-- get search combobox, show explorer if docked and not visible
local cbo_search = reaper.JS_Window_FindChildByID(explorer, 0x3F7)
if not cbo_search then return end
if not reaper.JS_Window_IsVisible(cbo_search) then reaper.Main_OnCommand(50124, 0) end
-- get file list
local filelist = reaper.JS_Window_FindChildByID(explorer, 0x3E9)
-- variable for wait timer
local init_time = reaper.time_precise()
--<< setup

function PostKey(hwnd, vk_code) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYDOWN", vk_code, 0,0,0)
  reaper.JS_WindowMessage_Post(hwnd, "WM_KEYUP", vk_code, 0,0,0)
end

function PostText(hwnd, str) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-char
  for char in string.gmatch(str, ".") do
    local ret = reaper.JS_WindowMessage_Post(hwnd, "WM_CHAR", string.byte(char),0,0,0)
    if not ret then break end
  end
end

function SetExplorerPath(hwnd, folder)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3EA)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, folder)
    PostKey(edit, 0xD)
  end
end

function SetExplorerSearch(hwnd, text)
  local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3F7)
  local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
  if edit then
    reaper.JS_Window_SetTitle(edit, "")
    PostText(edit, text)
    PostKey(edit, 0xD)
  end
end


function SortDateModified()
  if reaper.time_precise() < init_time then
    reaper.defer(SortDateModified)
  else
    reaper.JS_Window_SetFocus(filelist) -- Set focus on Media Explorer file list.
    reaper.JS_ListView_SetItemState(filelist, -1, 0x0, 0x2) -- unselect items in file list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42256,0,0,0) -- "sort title" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42085,0,0,0) -- rescan database for new files    
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0) -- "sort modified file" list
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42254,0,0,0)
    reaper.JS_WindowMessage_Send(explorer, "WM_COMMAND", 42339,0,0,0)--   "column preset2"
    init_time = reaper.time_precise() + wait
    ScrollToTop()
  end
end

function ScrollToTop()
  if reaper.time_precise() < init_time then
    reaper.defer(ScrollToTop)
  else
    reaper.JS_WindowMessage_Send(filelist, "WM_VSCROLL", 6,0,0,0) -- scroll list to top
  end
end

function Main() 
  SetExplorerPath(explorer, path)       -- set path field
  SetExplorerSearch(explorer, search)   -- set search field 
  init_time = reaper.time_precise() + wait
  SortDateModified()
end

function Initalize() 
  if reaper.time_precise() < init_time then
    reaper.defer(Initalize)
  else
    Main()
  end
end

init_time = reaper.time_precise() + wait
Initalize()

Last edited by Dragonetti; 07-03-2022 at 09:44 AM.
Dragonetti is offline   Reply With Quote
Old 07-03-2022, 07:33 AM   #16
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Dragonetti View Post
I integrated the line and now it works.
Just a heads up, Above this line,
Code:
function SetExplorerPath(hwnd, folder)
You have this in there,
Code:
reaper.Main_OnCommand(42339,0)
Which is, Item: Force no pre-echo reduction mode for stretch markers
You might want to remove that.
Edgemeal is offline   Reply With Quote
Old 07-03-2022, 09:44 AM   #17
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Ah thanks, I will correct it.
Dragonetti is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.