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: 5,788
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,167
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: 583
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: 583
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,183
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; Yesterday at 04:06 AM.
mespotine is online now   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: 5,788
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,402
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   #568
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,167
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: 5,788
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,167
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: 5,788
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,569
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,167
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; Yesterday 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: 5,788
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,167
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,569
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 Yesterday, 01:35 AM   #577
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,167
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 Yesterday, 02:56 AM   #578
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,569
Default

v0.989 uploaded with a hotfix and new Window_FindTop.
juliansader is offline   Reply With Quote
Old Yesterday, 02:55 PM   #579
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,569
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 Yesterday, 03:43 PM   #580
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,167
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; Yesterday at 03:56 PM.
Edgemeal is offline   Reply With Quote
Old Yesterday, 05:50 PM   #581
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,788
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 Today, 08:43 AM   #582
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,167
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
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 03:33 PM.


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