Old 10-30-2019, 01:38 PM   #761
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Edgemeal View Post
Any clue why this code runs OK on v0.990 and 991 but instantly crashes REAPER using v0.992 or 993? (on Windows 10).
Eeeck, this is bad! The bug probably crawled in when I changed the message handler function for new windows created by JS_Window_Create to use widechars for Unicode. I will investigate.
juliansader is offline   Reply With Quote
Old 10-31-2019, 06:25 AM   #762
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I have uploaded v0.995 with a hotfix for the bug that Edgemeal reported.
juliansader is offline   Reply With Quote
Old 10-31-2019, 07:47 AM   #763
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

I got this code by someone in this thread (Edgemeal, most likely)

Code:
reaper.Main_OnCommand( 41157, 0 )

local hWnd = reaper.JS_Window_Find("Project Bay", true)
if hWnd == nil then return end  

local search = reaper.JS_Window_FindChildByID(hWnd, ID)  --handle 3134C says Spy++
if search == nil then return end  

reaper.JS_Window_SetFocus(search)
I am trying to open the Project Bay editor and have the cursor already in the filter field. My question is in regard the second parameter of reaper.JS_Window_FindChildByID: ID. Using Spy++ i get a lot of different values, but none of them matches the 4digit integer format i can see this function needs (i can see that in other scripts)

In the API documentation says i can get this value using

Code:
 reaper.JS_Window_GetLongPtr( windowHWND, info )
But then i am also not sure what the info parameter is here, since i cant seem to find either in Spy++ infos something similar to the examples ("USERDATA", "WNDPROC", "DLGPROC", "ID", "EXSTYLE" or "STYLE") written on the API doc.

EDIT: I actually tried copying the value on User Data ("DEADF00B") as the info parameter but didnt work
Attached Images
File Type: png del_Spy.png (21.0 KB, 232 views)
reapero is offline   Reply With Quote
Old 10-31-2019, 08:11 AM   #764
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

To get the ID using a script, use
Code:
reaper.JS_Window_GetLong(windowHWND, "ID")
In Spy, use the "Control ID" value, which 0x52C in this case.

Control ID = "ID"
User Data = "USERDATA"
Window Proc = "WNDPROC"
juliansader is offline   Reply With Quote
Old 10-31-2019, 08:20 AM   #765
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Thanks Julian!

So, running this:

Code:
reaper.Main_OnCommand( 41157, 0 )

local hWnd = reaper.JS_Window_Find("Project Bay", true)
if hWnd == nil then return end  

ID =  reaper.JS_Window_GetLong(hWnd, "0000052C")
local search = reaper.JS_Window_FindChildByID(hWnd, ID)  --3134C
if search == nil then return end  

reaper.JS_Window_SetFocus(search)
I get no errors, and the script works, but i see ID has a value of 0.0

Does this make sense? Form what i saw in other scripts, this usually was something like 1015 or the like
reapero is offline   Reply With Quote
Old 10-31-2019, 08:22 AM   #766
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

You should use id = reaper.JS_Window_GetLong(hWnd, "ID"), to get the return value of 0x52C. The parameter is the literal string "ID", because you are telling the function that the info that you want is the window ID.
juliansader is offline   Reply With Quote
Old 10-31-2019, 08:46 AM   #767
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Thx. Using

id = reaper.JS_Window_GetLong(hWnd, "ID")

Also returns 0.0. I guess i am looking at the wrong hWnd, which in the script is the Project Bay, not that little filter textbox inside the Project Bay.

Trying to use reaper.JS_Window_FindChild( parentHWND, title, exact ), i am faced with the problem of providing a title, which the search box doesnt seem to have.

Maybe i should just go back to fetal position on the floor and start crying again..
reapero is offline   Reply With Quote
Old 10-31-2019, 08:53 AM   #768
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by juliansader View Post
I have uploaded v0.995 with a hotfix for the bug that Edgemeal reported.
Looks good Julian!

Question, How do you move a borderless window with mouse? In Windows I simply do something like this, but we dont have a way to release mouse capture do we?
Code:
function Some_window_Mousedown_event()
  ReleaseCapture() // Release mouse capture, https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-releasecapture
  SendMessage(hwnd, WM_NCLBUTTONDOWN, HT_CAPTION, 0) // move window with mouse.
end
I tried saving mouse pos but doesn't work well if you move the mouse just a little too fast, maybe just needs better logic?
Code:
title = "Test"
btnX,btnY,btnW,btnH,txt = 30,30,120,33,"Drag Window"
winW,winH=300,200
window = reaper.JS_Window_Create(title, "myClass", 120, 120, winW, winH,"POPUP")
bm = reaper.JS_LICE_CreateBitmap(true, winW, winH)
reaper.JS_Composite(window, 0, 0, winW, winH, bm, 0, 0, winW, winH)
reaper.JS_LICE_Clear(bm, 0xFFFFFF00)
reaper.JS_LICE_FillRect(bm, btnX, btnY, btnW, btnH, 0xFABB00FF, 1, "COPY")
reaper.JS_Window_InvalidateRect(window, 0, 0, winW, winH, true)

function loop()
  if reaper.ValidatePtr(window, "HWND") then
    hDC = reaper.JS_GDI_GetWindowDC(window)
    reaper.JS_GDI_SetTextBkColor(hDC, 0xFABB00FF) -- text color
    reaper.JS_GDI_DrawText(hDC, txt, string.len(txt), btnX, btnY, btnX+btnW, btnY+btnH, 'VCENTER HCENTER SINGLELINE') -- center text
    reaper.JS_GDI_ReleaseDC(window, hDC)

    -- Move borderless window with mouse - Doesn't work well if mouse is moved too fast!
    if reaper.JS_Mouse_GetState(1) == 1 then -- Left mouse button down
      if reaper.JS_Window_GetForeground() == window then -- me is foreground
        if ContainsMouse(window, btnX,btnY,btnW,btnH) then -- mouse inside area
          local mX, mY = reaper.GetMousePosition()
          local cx, cy = reaper.JS_Window_ScreenToClient(window, mX, mY) 
          -- calc new loc.
          local newX = (cx - lPosX)
          local newY = (cy - lPosY) 
          local x,y,_,_ = GetBounds(window) -- me window rect
          reaper.JS_Window_Move(window, x+newX, y+newY)
        end
      end 
    else -- save current mouse loc.
      local xx, yy = reaper.GetMousePosition()
      lPosX, lPosY = reaper.JS_Window_ScreenToClient(window, xx, yy)
    end

    ------
    reaper.defer(loop)
  end
end

function GetBounds(hwnd)
  local _, left, top, right, bottom = reaper.JS_Window_GetRect(hwnd)
  return left, top, right-left, bottom-top
end

function ContainsMouse(hwnd,x,y,w,h)
  local mX, mY = reaper.GetMousePosition() 
  local cx, cy = reaper.JS_Window_ScreenToClient(hwnd, mX, mY)
  if (cx >= x) and (cx <= x+w) and (cy <= y+h) and (cy >= y) then
    return true
  end
end
 
function exit()
  reaper.JS_Window_Destroy(window) 
  reaper.JS_LICE_DestroyBitmap(bm)
end

reaper.atexit(exit)
reaper.defer(loop)
Thanks!
Edgemeal is offline   Reply With Quote
Old 10-31-2019, 09:12 AM   #769
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by reapero View Post
I got this code by someone in this thread (Edgemeal, most likely)

I am trying to open the Project Bay editor and have the cursor already in the filter field.


Code:
reaper.Main_OnCommand( 41157, 0 )
local hWnd = reaper.JS_Window_Find("Project Bay", true)
if hWnd == nil then return end  

local search = reaper.JS_Window_FindChildByID(hWnd, "0x52C")
if search == nil then return end  
reaper.JS_Window_SetFocus(search)
Edgemeal is offline   Reply With Quote
Old 10-31-2019, 09:14 AM   #770
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Thanks Edgemeal!

Last edited by reapero; 10-31-2019 at 09:19 AM.
reapero is offline   Reply With Quote
Old 10-31-2019, 09:52 AM   #771
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by juliansader View Post
I have uploaded v0.995 with a hotfix for the bug that Edgemeal reported.
Sorry, but I can't download this from Reapack package manager...the latest version is 0.993. (ReaTeamBot indexer failure?)

Thanks for this great extension!
spk77 is offline   Reply With Quote
Old 10-31-2019, 03:24 PM   #772
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by spk77 View Post
Sorry, but I can't download this from Reapack package manager...the latest version is 0.993. (ReaTeamBot indexer failure?)
Fixed!
cfillion is offline   Reply With Quote
Old 11-01-2019, 09:37 AM   #773
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Edgemeal View Post
Looks good Julian!

Question, How do you move a borderless window with mouse? In Windows I simply do something like this, but we dont have a way to release mouse capture do we?

I tried saving mouse pos but doesn't work well if you move the mouse just a little too fast, maybe just needs better logic?
Maybe there are other (better) ways, but I'm doing it more or less like this:
Code:
wx, wy = -1, -1
lmb_drag = false
mouse = {ox = -1, oy = -1}
title = "Test"
btnX,btnY,btnW,btnH,txt = 30,30,120,33,"Drag Window"
winW,winH=300,200
window = reaper.JS_Window_Create(title, "myClass", 120, 120, winW, winH,"POPUP")
bm = reaper.JS_LICE_CreateBitmap(true, winW, winH)
reaper.JS_Composite(window, 0, 0, winW, winH, bm, 0, 0, winW, winH)
reaper.JS_LICE_Clear(bm, 0xFFFFFF00)
reaper.JS_LICE_FillRect(bm, btnX, btnY, btnW, btnH, 0xFABB00FF, 1, "COPY")
reaper.JS_Window_InvalidateRect(window, 0, 0, winW, winH, true)

function loop()
  if reaper.ValidatePtr(window, "HWND") then
    local lmb_state = reaper.JS_Mouse_GetState(1) == 1
    hDC = reaper.JS_GDI_GetWindowDC(window)
    reaper.JS_GDI_SetTextBkColor(hDC, 0xFABB00FF) -- text color
    reaper.JS_GDI_DrawText(hDC, txt, string.len(txt), btnX, btnY, btnX+btnW, btnY+btnH, 'VCENTER HCENTER SINGLELINE') -- center text
    reaper.JS_GDI_ReleaseDC(window, hDC)
    local mX, mY = reaper.GetMousePosition()
     
    -- Move borderless window with mouse - Doesn't work well if mouse is moved too fast!
    if lmb_state then -- Left mouse button down 
      if not last_lmb_state then -- ...lmb was not down on previous iteration
        if reaper.JS_Window_GetForeground() == window then -- me is foreground
          if ContainsMouse(window, btnX,btnY,btnW,btnH) then -- mouse inside area
            wx, wy = GetBounds(window) -- me window rect
            mouse.ox, mouse.oy = mX, mY -- save current mouse loc.
            lmb_drag = true
          end
        end
      -- on mouse move (lmb down)
      elseif mX ~= mouse.oy or mY ~= mouse.oy then
        if lmb_drag then
          reaper.JS_Window_Move(window, mX+wx-mouse.ox, mY+wy-mouse.oy)
        end
      end
    end
    
    -- on lmb release
    if last_lmb_state and not lmb_state then
      if lmb_drag then
        lmb_drag = false
      end
    end
    
    last_lmb_state = lmb_state
    ------
    reaper.defer(loop)
  end
end

function GetBounds(hwnd)
  local _, left, top, right, bottom = reaper.JS_Window_GetRect(hwnd)
  return left, top, right-left, bottom-top
end

function ContainsMouse(hwnd,x,y,w,h)
  local mX, mY = reaper.GetMousePosition() 
  local cx, cy = reaper.JS_Window_ScreenToClient(hwnd, mX, mY)
  if (cx >= x) and (cx <= x+w) and (cy <= y+h) and (cy >= y) then
    return true
  end
end
 
function exit()
  reaper.JS_Window_Destroy(window) 
  reaper.JS_LICE_DestroyBitmap(bm)
end

reaper.atexit(exit)

loop()


Quote:
Originally Posted by cfillion View Post
Fixed!
Thanks!
spk77 is offline   Reply With Quote
Old 11-01-2019, 09:42 AM   #774
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Q: How to remove resize grip that has been attached with reaper.JS_Window_AttachResizeGrip(identifier windowHWND)


Nitpick: The attached grip is flickering (Windows 8.1, js_ReaScriptAPI extension v0.995):
spk77 is offline   Reply With Quote
Old 11-01-2019, 10:00 AM   #775
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by spk77 View Post
Maybe there are other (better) ways, but I'm doing it more or less like this:
That works much better! Thanks for the example!
Edgemeal is offline   Reply With Quote
Old 11-02-2019, 07:02 AM   #776
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Edgemeal View Post
That works much better! Thanks for the example!
I'm using your code to get window handles, so thank you!


Q: Is it possible to pass all key presses (except some certain keys) through a focused script window to reaper's main window?
spk77 is offline   Reply With Quote
Old 11-02-2019, 10:36 AM   #777
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by spk77 View Post
Q: Is it possible to pass all key presses (except some certain keys) through a focused script window to reaper's main window?
Not that I know of.
Edgemeal is offline   Reply With Quote
Old 11-04-2019, 03:15 AM   #778
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Would it be possible with the current API version to draw a rectangular frame on top of previously selected events in a midi CC/velocity lane?

I guess its possible to activate the script, then draw the frame and make it select whats underneath it, but i´d like to know ifits possible the other way aorund.
reapero is offline   Reply With Quote
Old 11-04-2019, 06:08 AM   #779
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Sure, calculating the coordinates is a bit of a hassle, but you can use code similar to those of my "Mouse editing" scripts that draw stuff around the selected events, such as Stretch/Compress or Arch/Tilt.

Here, for example, the Multi Tool script draws several rectangles to show "active zones" for different tools:

juliansader is offline   Reply With Quote
Old 11-04-2019, 06:13 AM   #780
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by spk77 View Post
Q: Is it possible to pass all key presses (except some certain keys) through a focused script window to reaper's main window?
To the best of my knowledge, no. What we did in this thread, was to force the focus to the main window, and then just intercept the few keys that the script GUI uses.
juliansader is offline   Reply With Quote
Old 11-04-2019, 06:22 AM   #781
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Thanks!

I´ve updated Reapack and tried to look for this "Multi Tool" script but didnt find anything. Is it available outside Reapack somewhere? I attach a pic of the mouse editing scripts the Action list displays here.
Attached Images
File Type: png js_mouse_editing.png (29.5 KB, 179 views)
reapero is offline   Reply With Quote
Old 11-04-2019, 06:30 AM   #782
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

I was about to ask the same. That multi tool looks amazing. Is it in the works, maybe?
__________________
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 11-04-2019, 01:13 PM   #783
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by juliansader View Post
To the best of my knowledge, no. What we did in this thread, was to force the focus to the main window, and then just intercept the few keys that the script GUI uses.
Thanks! I'll test that.
spk77 is offline   Reply With Quote
Old 11-09-2019, 10:54 AM   #784
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Hey Julian I know that I still haven't (cough) payed you for the last script you helped me with, but is there anyway I could get an advance?

I was wondering if you wouldn't mind creating a script that selects all midi notes to the right of the mouse cursor using chunking.

I've got a script that does it without the chunks, but it really goes slow on heavy midi tracks, such as piano, for instance...

...love you!
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 11-09-2019, 11:04 AM   #785
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

When you say "chunking" are you referring to SetMIDIEvts?

If so, check my repo for:

Select notes after mouse cursor (in take under mouse or in MIDI editor)
Select notes before mouse cursor (in take under mouse or in MIDI editor)
Select notes and all CCs before edit cursor (in selected item(s) or MIDI editor)
Select notes and all CCs after edit cursor (in selected item(s) or MIDI editor)
Delete notes after edit cursor (in selected item(s) or MIDI editor)
Delete notes before edit cursor (in selected item(s) or MIDI editor)
Select notes after edit cursor (in selected item(s) or MIDI editor)
Select notes before edit cursor (in selected item(s) or MIDI editor)
__________________
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 11-09-2019, 11:41 AM   #786
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Quote:
Originally Posted by _Stevie_ View Post
When you say "chunking" are you referring to SetMIDIEvts
Dangit.

You called my bluff, I don't actually know what I'm referring to. I said 'chunks' to somebody once and they know what I meant; and it made me feel really cool.

Very fast! Works like a charm! Adding your repo!
__________________

Support my feature request!

Last edited by Dafarkias; 11-09-2019 at 11:48 AM.
Dafarkias is offline   Reply With Quote
Old 11-09-2019, 11:45 AM   #787
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Haha
No worries, I think I got it right.

The MIDI_SetAllEvts method is likey what you are looking for, since it's faster .
I try to use it wherever I can, but it's a really complicated solution.
Gives my brain regular headaches, when trying to code an algo around it
__________________
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 11-09-2019, 11:56 AM   #788
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Quote:
Originally Posted by _Stevie_ View Post
Gives my brain regular headaches, when trying to code an algo around it
Why do you think I was reaching for help from Julian? Lol

Thanks Stevie, u da best!
__________________

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

Quote:
Originally Posted by _Stevie_ View Post
I was about to ask the same. That multi tool looks amazing. Is it in the works, maybe?
I will upload it to ReaPack in the next few days.
juliansader is offline   Reply With Quote
Old 11-09-2019, 12:07 PM   #790
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

O M G !!!
__________________
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 11-10-2019, 04:47 AM   #791
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Quote:
Originally Posted by juliansader View Post
I will upload it to ReaPack in the next few days.
I feel like this is gonna be a real game changer to me.

Million thanks Julian!
reapero is offline   Reply With Quote
Old 11-17-2019, 01:18 PM   #792
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

A native action to get script window handle(s) would be useful to prevent this (the action list window gets a new window style):

(The action list window has an edit control with a text "Track tags")


I'm using reaper.JS_Window_ArrayFind to get the script window handle(s)
script.title in this is "Track Tags"
Code:
-----------------------------------------------------------------------
function set_window_style(style, attach_resize_grip)
  if gfx.dock(-1)&1 == 0 then
    local hWnd_array = reaper.new_array({}, 20)
    local num_script_windows = reaper.JS_Window_ArrayFind(script.title, true, hWnd_array)
    local handles = hWnd_array.table()
    for i=1, num_script_windows do
      local hwnd = reaper.JS_Window_HandleFromAddress(handles[i])
      if attach_resize_grip then
        reaper.JS_Window_AttachResizeGrip(hwnd)
      end
      reaper.JS_Window_SetStyle(hwnd, style)
    end
  end
end

Maybe I could use reaper.JS_Window_ArrayFind and reaper.JS_Window_GetClassName, but would it work on macOS and Linux? (script window class seems to be "Lua_LICE_gfx_standalone"
spk77 is offline   Reply With Quote
Old 11-17-2019, 01:29 PM   #793
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by spk77 View Post
A native action to get script window handle(s) would be useful to prevent this (the action list window gets a new window style):
I have long requested that gfx.init should return the HWND of the newly created script GUI. The devs are currently working on gfx.init in the pre-releases, so perhaps this is a good time to remind them of the FR.


Quote:
Originally Posted by spk77 View Post
Maybe I could use reaper.JS_Window_ArrayFind and reaper.JS_Window_GetClassName, but would it work on macOS and Linux? (script window class seems to be "Lua_LICE_gfx_standalone"
I'm not sure about script GUIs, but most swell windows don't seem to have proper class names in Linux.

You can try FindTop to find only top-level windows; or check the parent windows of all matches; or do ArrayFind twice, before and after, and compare to find any new windows.

Last edited by juliansader; 11-17-2019 at 01:35 PM.
juliansader is offline   Reply With Quote
Old 11-17-2019, 01:41 PM   #794
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by juliansader View Post
I have long requested that gfx.init should return the HWND of the newly created script GUI. The devs are currently working on gfx.init in the pre-releases, so perhaps this is a good time to remind them of the FR.




I'm not sure about script GUIs, but most swell windows don't seem to have proper class names in Linux.

You can try FindTop to find only top-level windows; or check the parent windows of all matches; or do ArrayFind twice, before and after, and compare to find any new windows.
Thanks!
I agree that gfx.init should return the HWND.
spk77 is offline   Reply With Quote
Old 11-17-2019, 04:37 PM   #795
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Regarding gfx.init:
Create the window with a temporary name, generated guid would be the best.
Find the window to get the hwnd.
Rename it to its final title.

Works on all three platforms, afaik.

I'm using this approach in Ultraschall-Api.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 11-18-2019, 05:05 PM   #796
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Is JS_Window_Destroy() limited to REAPER child windows only or something? Was trying to close a Windows notepad in Win10(1909)...

Code:
 local hwnd = reaper.JS_Window_FindTop('*Untitled - Notepad', true)
  if hwnd then
    msg('window found')  
    reaper.JS_Window_Destroy(hwnd) -- < DOESNT WORK!
    -- reaper.JS_WindowMessage_Post(hwnd, "WM_CLOSE", 0,0,0,0) -- < Works
  end
Win10 x64, REAPER v5.986+dev1118/x64, SWS v2.10.0.1, JS v0.995

Last edited by Edgemeal; 11-18-2019 at 05:11 PM. Reason: TYPO IN TITLE TEXT
Edgemeal is offline   Reply With Quote
Old 11-19-2019, 09:40 AM   #797
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Yes, the functions seem to be limited to windows opened by Reaper/WDL/Swell-applications.

Had the same problem when trying to make autoscreenrecording using LiceCap. I can access LiceCap itself to hit the recordbutton, but not the buttons of the save-file-dialog, which seems to be an os-based-dialog.

Though you can find the windows and their hwnd without a problem...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 11-19-2019 at 09:49 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 11-19-2019, 11:37 AM   #798
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Edgemeal View Post
Is JS_Window_Destroy() limited to REAPER child windows only or something? Was trying to close a Windows notepad in Win10(1909)...
Yes, it is limited to REAPER windows. According to the MS documentation:
Quote:
A thread cannot use DestroyWindow to destroy a window created by a different thread.
juliansader is offline   Reply With Quote
Old 11-19-2019, 11:44 AM   #799
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by juliansader View Post
Yes, it is limited to REAPER windows. According to the MS documentation:
Thanks!
Edgemeal is offline   Reply With Quote
Old 11-19-2019, 11:47 AM   #800
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

I have some issues with setting the z-order of a non-Reaper window.

I noticed: when changing the Z-order of a window and ALT-Tabbing right afterwards, there are some issues. As if the other windows wouldn't know which z-order they now have.
That means, the title bar is activated, but when using helper programs like Logitech's keyboard software, Stream Deck or iCue from Corsair (they change the shortcuts based on the active window name), these applications show the shortcuts from a different application but not the one where the title bar is activated.

Is it necessary to update all windows, after having changed the z-order?
__________________
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
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 01:48 AM.


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