Old 06-12-2019, 03:13 PM   #561
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,033
Default

@edgemeal
Hmmm nope, this just make file list disapear :/
X-Raym is offline   Reply With Quote
Old 06-12-2019, 04:42 PM   #562
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
@edgemeal
Hmmm nope, this just make file list disapear :/
Seems to works fine on Win7.

Code:
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end  
local container = reaper.JS_Window_FindChildByID(hWnd, 0)
local file_LV = reaper.JS_Window_FindChildByID(container, 1000)

local SB_LINEUP = 0
local SB_LINEDOWN = 1
local SB_TOP = 6
local SB_BOTTOM = 7

-- go to top
reaper.JS_WindowMessage_Send(file_LV, "WM_VSCROLL", SB_TOP, 0,0,0)
-- scroll down # of lines
for n = 1, 7 do
 reaper.JS_WindowMessage_Send(file_LV, "WM_VSCROLL", SB_LINEDOWN, 0,0,0)
end
Edgemeal is offline   Reply With Quote
Old 06-12-2019, 04:49 PM   #563
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Is there a regression in JS_Window_AttachTopmostPin? This used to work for me (though when I'm not entirely sure), but at least as of 0.988 with Reaper 5.978 this isn't working:

Code:
gfx.init('blargh!', 640, 480, 0, 100, 100)
local hwnd = reaper.JS_Window_Find('blargh!', true)
reaper.ShowConsoleMsg('found hwnd: ' .. tostring(hwnd) .. '\n')
reaper.JS_Window_AttachTopmostPin(hwnd)
function go()
    gfx.update()
    reaper.defer(go)
end
go()
The console does report a non-nil hwnd. But the pin isn't showing on the window. Anyone else see this?

Windows 10 x64 (build 1809).
tack is offline   Reply With Quote
Old 06-12-2019, 08:42 PM   #564
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Also, how might one fetch the hwnd of a docked gfx script that matches the hwnd returned by JS_Window_GetFocus() when the docked script is focused?

JS_Window_Find(title_passed_to_gfx_init, true) != JS_Window_GetFocus() when the docked script is focused. However this does work when the script is undocked and floating.

(I swear this used to work, in fact I even went out of my way to add a comment to that effect but either I was wrong at the time or the behavior changed, because it doesn't seem to work anymore.)
tack is offline   Reply With Quote
Old 06-13-2019, 02:38 AM   #565
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,558
Default

@tack
There is a function I posted in this thread, hat returns the hwnd of the gfx-window. Can you test that and give me feedback, if it works?

Can't look for the post to give you the link currently. Browsing is a nightmare on my telephone
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635

Last edited by mespotine; 06-14-2019 at 04:06 AM.
mespotine is offline   Reply With Quote
Old 06-13-2019, 02:39 AM   #566
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,033
Default

@Edgemeal
Your code don't contains the force Vertical position:

Code:
a = reaper.JS_Window_SetScrollPos( file_LV, "v", 80 )

I'm trying to close MediaExplorer (to refresh its content) and Reopen it where the scroll was, within a single script. So I first use the GetScrollPos function, and I supposed that the SetScroll would be enough to just reset it, but nope :/
X-Raym is offline   Reply With Quote
Old 06-13-2019, 04:59 AM   #567
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,452
Default

Maybe I'm doing something wrong with getcursor, but should I convert it to address ?

If yes (which I am) is it supposed to generate entirely new address each time reaper restarts?
Sexan is offline   Reply With Quote
Old 06-13-2019, 07:33 AM   #568
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
@Edgemeal
Your code don't contains the force Vertical position:

Code:
a = reaper.JS_Window_SetScrollPos( file_LV, "v", 80 )
That function messes up the LV drawing, I tried sending it paint msg and using LVM_SCROLL message but they didn't work.

Quote:
I'm trying to close MediaExplorer (to refresh its content) and Reopen it where the scroll was,
Seems the LV 'position' from GetScrollInfo is equal to line number, so for example this would scroll down one line from current position (or a saved position),..

Code:
retval, position, pageSize, min, max, trackPos = reaper.JS_Window_GetScrollInfo(file_LV, 'v')
--
reaper.JS_WindowMessage_Send(file_LV, "WM_VSCROLL", SB_TOP, 0,0,0)
for n = 1, position + 1 do
  reaper.JS_WindowMessage_Send(file_LV, "WM_VSCROLL", SB_LINEDOWN, 0,0,0)
end
Not the most elegant but it does the job.

update:
LVM_SCROLL does work, but scale is in pixels.

Code:
local LVM_SCROLL = "0x1014"
reaper.JS_WindowMessage_Send(file_LV, LVM_SCROLL, 0, 0, 80, 0)

Last edited by Edgemeal; 06-13-2019 at 09:52 AM.
Edgemeal is offline   Reply With Quote
Old 06-13-2019, 09:59 AM   #569
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,033
Default

@edgemeal

Thx for brainstorming :P



This is with the scroll




A bit slow ^^






for the Pixel based solution which seems fast, how would you store this pixel value first ?
X-Raym is offline   Reply With Quote
Old 06-13-2019, 11:13 AM   #570
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
@edgemeal
for the Pixel based solution which seems fast, how would you store this
pixel value first ?
Looking at some vb.net code seems all I did was multiply that saved position (line number) by the height of a LV item. Not sure how well that will work with that file_LV though, it seems to be coded to scroll one full line (not pixels), so if you move it down one pixel too many it may skip to the next line. Thats all I got. Good Luck!

Last edited by Edgemeal; 06-13-2019 at 11:20 AM.
Edgemeal is offline   Reply With Quote
Old 06-13-2019, 12:18 PM   #571
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,033
Default

@Edgemeal
Understood, I'll try,


Also, you might want to know that your code


Code:
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end  

local container = reaper.JS_Window_FindChildByID(hWnd, 0)
local file_LV = reaper.JS_Window_FindChildByID(container, 1000)

will break if the Media explorer is docked and that action list is undocked and most of all action list is on Media Explorer context.
X-Raym is offline   Reply With Quote
Old 06-13-2019, 12:31 PM   #572
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

Quote:
Originally Posted by Sexan View Post
Maybe I'm doing something wrong with getcursor, but should I convert it to address ?

If yes (which I am) is it supposed to generate entirely new address each time reaper restarts?
You don't need to convert the returned handle to an address, and can compare the handles directly.

These handles are not stable, so you should load them at least once per REAPER session (or once each time that the script is run).

BTW, to find cursor numbers (so that you can get their handles using LoadCursor), you can use Resource Hacker as cfillion advised in WDL/SWELL and C++ extensions: How to change mouse cursor?.
juliansader is offline   Reply With Quote
Old 06-13-2019, 03:12 PM   #573
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
will break if the Media explorer is docked and that action list is undocked and most of all action list is on Media Explorer context.
Ya, I didn't realize 'JS_Window_Find' was going down to child levels,

EDIT
Better way to get handle of "Media Explorer" is to just call...
Code:
local hWnd = reaper.OpenMediaExplorer("", false)

Last edited by Edgemeal; 06-14-2019 at 02:03 AM.
Edgemeal is offline   Reply With Quote
Old 06-13-2019, 05:50 PM   #574
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,033
Default

@edgemeal


Thanks to your advice, my delete and rename form media explorer scripts are becoming usable !





(it flashes a bit cause media explorer have to be close/refresh, I didnt succeed to use the native actions with Unload preview and refresh browser, even with the JS command for media explorer action... It's tricky there, I dont know what is wrong. But this version with lose/open MediaExplorer is usable !
X-Raym is offline   Reply With Quote
Old 06-13-2019, 05:56 PM   #575
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
@edgemeal


Thanks to your advice, my delete and rename form media explorer scripts are becoming usable !
Cool!

@ julian Maybe I need a break but...
JS_Window_Find(String title, Boolean exact)
Returns a HWND to the top-level window whose title matches the specified string. This function does not search child window, and is not case sensitive.

Code:
hwnd = reaper.JS_Window_Find("Media Explorer", true)
If Actions window is open and Section is set to "Media Explorer", the function returns the ComboBox handle. Combobox is top-level?

Win7 / REAPER v5.979rc2/x64, SWS v2.10.0.1, JS v0.987

Last edited by Edgemeal; 06-13-2019 at 06:32 PM.
Edgemeal is offline   Reply With Quote
Old 06-13-2019, 10:44 PM   #576
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

Quote:
Originally Posted by Edgemeal View Post
Cool!

@ julian Maybe I need a break but...
JS_Window_Find(String title, Boolean exact)
Returns a HWND to the top-level window whose title matches the specified string. This function does not search child window, and is not case sensitive.
OMG, what a horrible error in one of the most fundamental functions' definitions!

From the very beginning, Window_Find was actually coded to "* Searches child windows as well, so that script GUIs can be found even if docked."

I wonder how other users used the function in existing scripts. Should I change the function to match the help text (and add a new FindAny function), or change the help text to match the function (and add a new FindTop function)?
juliansader is offline   Reply With Quote
Old 06-14-2019, 01:35 AM   #577
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

I think I'd go with changing the help text to match the function and add a new FindTop function.
Edgemeal is offline   Reply With Quote
Old 06-14-2019, 02:56 AM   #578
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

v0.989 uploaded with a hotfix and new Window_FindTop.
juliansader is offline   Reply With Quote
Old 06-14-2019, 02:55 PM   #579
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

Quote:
Originally Posted by tack View Post
Also, how might one fetch the hwnd of a docked gfx script that matches the hwnd returned by JS_Window_GetFocus() when the docked script is focused?

JS_Window_Find(title_passed_to_gfx_init, true) != JS_Window_GetFocus() when the docked script is focused. However this does work when the script is undocked and floating.
I do not quite understand what you are trying to do -- could you perhaps upload a short script to demonstrate the problem?


Quote:
(I swear this used to work, in fact I even went out of my way to add a comment to that effect but either I was wrong at the time or the behavior changed, because it doesn't seem to work anymore.)
The comment states:
Code:
        -- reaper.JS_Window_FindChild() using reaper.GetMainHwnd() as the parent
        -- window seemed like the safer bet but this isn't robust.  First, it
        -- only works when the window is docked (otherwise returns nil) and even
        -- then, the hwnd returned by JS_Window_FindChild() doesn't match JS_Window_GetFocus().
        -- So we use this more expensive call and hope that our title is unique enough.
rtk.hwnd = reaper.JS_Window_Find(rtk.title, true)
JS_Window_FindChild(reaper.GetMainWindow(), ...) only searches child windows of the main window, so it will not find script GUIs that are undocked or that are docked in a floating docker. JS_Window_Find is the correct function to search through all windows, undocked or docked in any docker, to find the target window.
juliansader is offline   Reply With Quote
Old 06-14-2019, 03:43 PM   #580
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
It's tricky there
Another method that comes in handy is LVM_ENSUREVISIBLE.

Code:
local LVM_ENSUREVISIBLE = "0x1013"
local hWnd = reaper.OpenMediaExplorer("", false)
if hWnd == nil then return end
local container = reaper.JS_Window_FindChildByID(hWnd, 0)
local file_LV = reaper.JS_Window_FindChildByID(container, 1000)

-- make LV item index 13 visible
reaper.JS_WindowMessage_Send(file_LV, LVM_ENSUREVISIBLE, 13,0,0,0)

Last edited by Edgemeal; 06-14-2019 at 03:56 PM.
Edgemeal is offline   Reply With Quote
Old 06-14-2019, 05:50 PM   #581
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,033
Default

@Edgemeal
Intersting,
what woudl allow to see visibility state of FileLV list items ? reaper.JS_ListView_GetItemState( listviewHWND, index ) ?


Thx for still trying things :P
X-Raym is offline   Reply With Quote
Old 06-15-2019, 08:43 AM   #582
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by X-Raym View Post
@Edgemeal
Intersting,
what woudl allow to see visibility state of FileLV list items ? reaper.JS_ListView_GetItemState( listviewHWND, index ) ?


Thx for still trying things :P
Yes, try sending the item index as wParam. EnsureVisible is often used to keep a selected item in view after say sorting a listview column, you can see it in action, notice REAPER's media explorer file list keeps selected item in view when sorting by columns, but ReaPack Browser doesn't seem to use that function.
Edgemeal is offline   Reply With Quote
Old 06-17-2019, 10:08 AM   #583
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Quote:
Originally Posted by juliansader View Post
I do not quite understand what you are trying to do -- could you perhaps upload a short script to demonstrate the problem?
I was putting together said short script and determined that the problem is, in fact, mine. It turns out that JS_Window_Find() was finding a different window than intended: I had a JSFX window open that it was finding.

In spite of the fact that the apparent window title of the floating JSFX was 'JS: Reaticulate.jsfx - Track 11: "Sable" [2/3]' it happens that JS_Window_Find('Reaticulate', true) was returning it.

I suppose this isn't an issue with JS_Window_Find() because JS_Window_GetTitle() on the resulting hwnd is indeed just 'Reaticulate' (which matches the desc attribute in the JSFX itself). But I'm also not sure why the GetTitle() says something different than the apparent window title. For what it's worth, AutoHotkey's Window Spy agrees with the apparent title, not what JS_Window_GetTitle() returns.

In any case, I'll just need to make the title passed to gfx.init() more unique, or perhaps better narrow it down with JS_Window_FindEx().

Thanks Julian.
tack is offline   Reply With Quote
Old 06-17-2019, 10:38 AM   #584
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Quote:
Originally Posted by tack View Post
In any case, I'll just need to make the title passed to gfx.init() more unique, or perhaps better narrow it down with JS_Window_FindEx().
I ended up using JS_Window_ArrayFind() and if there was more than one result, it will choose the hwnd whose screen position matches gfx.clienttoscreen(0, 0).

Edit: actually, I changed the logic again to only use JS_Window_ArrayFind() if the hwnd returned by JS_Window_Find() didn't match the screen coordinates of the gfx window. This avoids a very expensive call to JS_Window_ArrayFind() in the common case.

Last edited by tack; 06-17-2019 at 05:44 PM.
tack is offline   Reply With Quote
Old 06-17-2019, 11:14 AM   #585
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

I quickly checked this, and it seems that the floating FX has a child window, next to the "Edit" button, that displays the FX name and that is simply titled "Reaticulate" in this case. FindWindow is apparently finding this child window first. The FX window itself returns the full title.
juliansader is offline   Reply With Quote
Old 06-17-2019, 01:43 PM   #586
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Quote:
Originally Posted by juliansader View Post
I quickly checked this, and it seems that the floating FX has a child window, next to the "Edit" button, that displays the FX name and that is simply titled "Reaticulate" in this case. FindWindow is apparently finding this child window first. The FX window itself returns the full title.
Ah, that makes perfect sense. Thanks for the sleuthing.

BTW were you able to reproduce the issue with JS_Window_AttachTopmostPin() I reported above?
tack is offline   Reply With Quote
Old 06-17-2019, 04:16 PM   #587
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

Quote:
Originally Posted by tack View Post
BTW were you able to reproduce the issue with JS_Window_AttachTopmostPin() I reported above?
The function still seems to work fine on Windows 7 x64 and macOS Mojave x64. Unfortunately I can't test on Windows 10 -- I wonder if any other users can check on Windows 10?

Are you sure that you have a handle to the correct (top-level) window?
juliansader is offline   Reply With Quote
Old 06-17-2019, 04:23 PM   #588
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Quote:
Originally Posted by juliansader View Post
Are you sure that you have a handle to the correct (top-level) window?
As far as I know. Did the snippet I posted earlier look right to you? I also called JS_Window_GetParent() on the hwnd returned there and tried to attach the pin to that hwnd with no result. And GetParent() on that hwnd returns nil, so that's definitely the top-most window.

Or even a brute force approach had no effect:

Code:
gfx.init('blargh!', 640, 480, 0, 100, 100)
local hwnd = reaper.JS_Window_Find('blargh!', true)
while hwnd do
    reaper.ShowConsoleMsg('Attaching pin to hwnd: ' .. tostring(hwnd) .. '\n')
    reaper.JS_Window_AttachTopmostPin(hwnd)
    hwnd = reaper.JS_Window_GetParent(hwnd)
end
function go()
    gfx.update()
    reaper.defer(go)
end
go()
Yes, please, can others on Win10 test that?
tack is offline   Reply With Quote
Old 06-17-2019, 04:40 PM   #589
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,788
Default

Quote:
Originally Posted by tack View Post
Yes, please, can others on Win10 test that?
Is that snippet in the current pre-release of Reariculate?
If so, then it still doesn’t work for me.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 06-17-2019, 04:42 PM   #590
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Quote:
Originally Posted by _Stevie_ View Post
Is that snippet in the current pre-release of Reariculate? If so, then it still doesn’t work for me.
Not quite like that. There's so much else going on with Reaticulate that it's better to test the condensed test case if possible.
tack is offline   Reply With Quote
Old 06-17-2019, 04:47 PM   #591
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,788
Default

Quote:
Originally Posted by tack View Post
Not quite like that. There's so much else going on with Reaticulate that it's better to test the condensed test case if possible.
Okay, will insert that snippet and give it a test run.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 06-18-2019, 07:46 PM   #592
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,788
Default

Nope, not working here either. Also, IIRC, Julian's MIDI inspector used to have a pin in the new version, right? Can't see that either, anymore.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 06-20-2019, 01:11 AM   #593
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,111
Default

Quote:
Originally Posted by tack View Post
As far as I know. Did the snippet I posted earlier look right to you? I also called JS_Window_GetParent() on the hwnd returned there and tried to attach the pin to that hwnd with no result. And GetParent() on that hwnd returns nil, so that's definitely the top-most window.

Or even a brute force approach had no effect:

Code:
gfx.init('blargh!', 640, 480, 0, 100, 100)
local hwnd = reaper.JS_Window_Find('blargh!', true)
while hwnd do
    reaper.ShowConsoleMsg('Attaching pin to hwnd: ' .. tostring(hwnd) .. '\n')
    reaper.JS_Window_AttachTopmostPin(hwnd)
    hwnd = reaper.JS_Window_GetParent(hwnd)
end
function go()
    gfx.update()
    reaper.defer(go)
end
go()
Yes, please, can others on Win10 test that?
Not followed this whole issue - but just copied that snippet into a new reascript file and ran on Win10Home (v1809) latest Reaper dev release + latest JS API 0.989.

Pin shows up fine for me (although it tries to attach it to two hwnds).

Code:
Attaching pin to hwnd: userdata: 0000000000180CCE
Attaching pin to hwnd: userdata: 00000000002B0E54
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 06-20-2019, 08:12 AM   #594
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,137
Default

Guys, is there an easy way to close action list if it's opened and focused. So if you have action list opened but it's in one docked tab and some other tab is active in the docker you don't see it. In that case, I would like to show the action list - BUT if action list is already visible - then I would close it.

Any easy way to do that using js_ReaScriptAPI?

With new global shortcuts we could make a script that always toggles action list to easily do stuff and then close it once done without using mouse to middle click action list docker tab
Breeder is offline   Reply With Quote
Old 06-20-2019, 08:38 AM   #595
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,383
Default

Quote:
Originally Posted by Breeder View Post
Guys, is there an easy way to close action list if it's opened and focused.
Seems if a window is found and control on it is not visible it means its docked but not the active tab. Try something like,...

Code:
function Main()
  local found = false
  local arr = reaper.new_array({}, 100)
  local title = reaper.JS_Localize("Actions", "common")
  reaper.JS_Window_ArrayFind(title, true, arr)
  local adr = arr.table() 
  for j = 1, #adr do
    local hwnd = reaper.JS_Window_HandleFromAddress(adr[j])
    local editbox = reaper.JS_Window_FindChildByID(hwnd, 1324)
    if editbox ~= nil  and reaper.JS_Window_IsVisible(editbox) then
      reaper.JS_Window_Destroy(hwnd) -- close action list 
      found = true
      break
    end 
  end 
  if not found then reaper.ShowActionList() end -- show action list
end

Main()
Edgemeal is offline   Reply With Quote
Old 06-20-2019, 08:56 AM   #596
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,137
Default

Quote:
Originally Posted by Edgemeal View Post
Seems if a window is found and control on it is not visible it means its docked but not the active tab. Try something like,...

Code:
function Main()
  local found = false
  local arr = reaper.new_array({}, 100)
  local title = reaper.JS_Localize("Actions", "common")
  reaper.JS_Window_ArrayFind(title, true, arr)
  local adr = arr.table() 
  for j = 1, #adr do
    local hwnd = reaper.JS_Window_HandleFromAddress(adr[j])
    local editbox = reaper.JS_Window_FindChildByID(hwnd, 1324)
    if editbox ~= nil  and reaper.JS_Window_IsVisible(editbox) then
      reaper.JS_Window_Destroy(hwnd) -- close action list 
      found = true
      break
    end 
  end 
  if not found then reaper.ShowActionList() end -- show action list
end

Main()
Awesome, thanks! I've been too lazy to study js_RSAPI properly, this example will definitely come in-handy!
Breeder is offline   Reply With Quote
Old 06-20-2019, 10:31 AM   #597
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,137
Default

My take for the script that opens/closes the Action list:
Code:
-- Misc ----------------------------------------------------------------------------------------------------------------
function IsMidiEditorFocused ()
	local IsMidiEditorFocused = false

	if reaper.MIDIEditor_GetActive() ~= nil then
		local focusedHwnd = reaper.JS_Window_GetFocus()
		local midiEditorArray = reaper.new_array({}, 100)
		reaper.JS_MIDIEditor_ArrayAll(midiEditorArray)
		local midiEditorArrayTable = midiEditorArray.table()

		for i = 1, #midiEditorArrayTable do
			if IsMidiEditorFocused == true then
				break
			end
			local midiEditorHwnd = reaper.JS_Window_HandleFromAddress(midiEditorArrayTable[i])
			local midiEditorChildArray = reaper.new_array({}, 1000)
			reaper.JS_Window_ArrayAllChild(midiEditorHwnd, midiEditorChildArray)
			local midiEditorChildArrayTable = midiEditorChildArray.table()

			for j = 1, #midiEditorChildArrayTable do
				local hwnd2 = reaper.JS_Window_HandleFromAddress(midiEditorChildArrayTable[j])
				if hwnd2 == focusedHwnd then
					IsMidiEditorFocused = true
					break
				end
			end
		end
	end

	return IsMidiEditorFocused
end

function OpenProperActionListSection ()
	if IsMidiEditorFocused() then
		if reaper.MIDIEditor_GetMode(reaper.MIDIEditor_GetActive()) == 0 then
			reaper.MIDIEditor_LastFocused_OnCommand(40420, false) -- Show action list
		else
			reaper.MIDIEditor_LastFocused_OnCommand(40420, true) -- Show action list
		end
	else
		reaper.Main_OnCommand(40605, 0) -- Show action list
	end
end

-- Main ----------------------------------------------------------------------------------------------------------------
function Main()
	local actionListOpened = false

	local windowArray = reaper.new_array({}, 100)
	local title = reaper.JS_Localize("Actions", "common")
	reaper.JS_Window_ArrayFind(title, true, windowArray)
	local windowArrayTable = windowArray.table()

	for j = 1, #windowArrayTable do
		local hwnd = reaper.JS_Window_HandleFromAddress(windowArrayTable[j])
		local editbox = reaper.JS_Window_FindChildByID(hwnd, 1324)
		if editbox ~= nil  and reaper.JS_Window_IsVisible(editbox) then
			reaper.JS_Window_Destroy(hwnd) -- close action list
			actionListOpened = true
			break
		end
	end
	
	_, _, g_thisSection, g_thisCmd = reaper.get_action_context()
	if not actionListOpened then
		OpenProperActionListSection()
		reaper.SetToggleCommandState(g_thisSection, g_thisCmd , 1)
	else
		reaper.SetToggleCommandState(g_thisSection, g_thisCmd , 0)
	end	
end

Main()
function NoUndoPoint () end -- Makes sure there is no unnecessary undo point created, see more
reaper.defer(NoUndoPoint)   -- here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67
This will open proper action list section depending on the focus. So if you have MIDI editor focused it will open MIDI editor section of the action list etc...
This is useful because now you can put this script in Main section only and assign a global shortcut to it so it always works and always toggles the window on/off for quick action list tasks.

Some effort has been invested in this. If you seriously use it, please consider supporting the developer. Thank you!

I don't mind if someone puts this script in ReaPack, but please include my donation link, forum nickname and link to this thread in the description if you do so.

Last edited by Breeder; 10-15-2019 at 05:06 AM.
Breeder is offline   Reply With Quote
Old 06-20-2019, 02:12 PM   #598
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,752
Default

Quote:
Originally Posted by _Stevie_ View Post
Nope, not working here either. Also, IIRC, Julian's MIDI inspector used to have a pin in the new version, right? Can't see that either, anymore.
Do SWS windows such as "Auto color/icon" still have the pin?
juliansader is offline   Reply With Quote
Old 06-20-2019, 02:13 PM   #599
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,788
Default

Nope, the Reaper Mixer window does, though.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 06-20-2019, 05:38 PM   #600
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 741
Default

Quote:
Originally Posted by juliansader View Post
Do SWS windows such as "Auto color/icon" still have the pin?
I'm in the same boat as Stephan, no pin on that window either.

Do you reckon it's an SWS issue?

(Win 10 x64 Version 1809 (OS Build 17763.437))
tack 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 11:43 PM.


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