Old 06-13-2019, 02:38 AM   #561
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
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
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 06-14-2019 at 04:06 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-13-2019, 02:39 AM   #562
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
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   #563
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
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 online now   Reply With Quote
Old 06-13-2019, 07:33 AM   #564
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #565
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
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   #566
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #567
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
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   #568
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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   #569
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #570
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
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   #571
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #572
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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   #573
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #574
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

v0.989 uploaded with a hotfix and new Window_FindTop.
juliansader is offline   Reply With Quote
Old 06-14-2019, 02:55 PM   #575
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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   #576
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #577
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
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   #578
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #579
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
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   #580
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
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   #581
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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   #582
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
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   #583
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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   #584
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
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   #585
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
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
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-17-2019, 04:42 PM   #586
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
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   #587
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
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
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-18-2019, 07:46 PM   #588
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
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
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-20-2019, 01:11 AM   #589
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
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:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 06-20-2019, 08:12 AM   #590
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
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   #591
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
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   #592
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
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   #593
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
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   #594
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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   #595
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Nope, the Reaper Mixer window does, though.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-20-2019, 05:38 PM   #596
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
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
Old 06-21-2019, 01:24 AM   #597
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by _Stevie_ View Post
Nope, the Reaper Mixer window does, though.
Quote:
Originally Posted by tack View Post
I'm in the same boat as Stephan, no pin on that window either.
Ah, so SWS is in the same boat. This is good news in a way, since it means the problem doesn't lie with ReaScriptAPI.


Quote:
Originally Posted by tack View Post
Do you reckon it's an SWS issue?
No, ReaScriptAPI adds the pin directly, without requiring SWS, so it seems to be a REAPER or Windows issue. Both extensions use the same trick to add the pin, namely an undocumented, unofficial feature of REAPER.

I will submit a bug report thread, but since the feature is not officially supported, it may not be high on the devs' priority list.

Are either of you perhaps using an unusual Windows 10 theme, or anything else that might affect window frames, such as WindowBlinds?
juliansader is offline   Reply With Quote
Old 06-21-2019, 02:58 AM   #598
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Using the default Windows 10 theme. No changes or theme hacks.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-29-2019, 09:44 AM   #599
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Hi JS!

Your extension is a thing of beauty, a great contribution to the Reaper community.

Wanna throw an idea past you for plausibility and whether or not you think it would be of value:

I know you have functions that get the mouse cursor's time-position from the arrange, would it be possible to have a function where you could get an item's x/y-coordinates at its upper-left point?

Similarly, I could also see potential value in a function that could get the x coordinate of the project edit cursor.

High regards,

Dafark
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 06-30-2019, 04:24 PM   #600
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Dafarkias View Post
I know you have functions that get the mouse cursor's time-position from the arrange, would it be possible to have a function where you could get an item's x/y-coordinates at its upper-left point?

Similarly, I could also see potential value in a function that could get the x coordinate of the project edit cursor.
This is actually already possible, using the existing API. For example, to get item position, get the track y position as in this code above, and then get the item position inside the track using GetMediaItemInfo_Value with I_LASTY, I_LASTH, F_FREEMODE_Y and F_FREEMODE_H.
juliansader 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:50 AM.


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