Old 07-30-2019, 09:46 AM   #641
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 194
Default

Thanks guys! You are the best!

I see that its easier than i thought though. Hwnds can be found simply by the title bar´s name, which is something i wasnt counting on.

Thx again

EDIT: Ahh shit. The window i wanna target has appended the version of the program, and i update this every couple weeks. So i probably need to use the global commands Edgemeal was refering to.
reapero is offline   Reply With Quote
Old 07-30-2019, 11:37 AM   #642
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,250
Default

Quote:
Originally Posted by reapero View Post
The window i wanna target has appended the version of the program, and i update this every couple weeks. So i probably need to use the global commands Edgemeal was refering to.
If the app title text is unique enough you can just enter partial title, and set the exact param to false, e.g.,
Code:
hwnd = reaper.JS_Window_FindTop('REAPER v5.', false)
Edgemeal is offline   Reply With Quote
Old 07-31-2019, 01:32 AM   #643
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 194
Default

Thanks Edgemeal!

I could get the hwnd i wanted but then, unlike in Stevie´s gif with Foobar2000, i cant dive inside to look for the search field.

I think this is related with the app being done in Qt: Spyxx only detects one window (class Qt5QWindowIcon) and nothing else inside it. In fact in the windows tab of this window´s properties Spyxx displays "First Child Window Handle(None)"

Seems like an impossible task for the win32 api then?
reapero is offline   Reply With Quote
Old 07-31-2019, 05:10 AM   #644
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,774
Default

Quote:
Originally Posted by reapero View Post
I think this is related with the app being done in Qt

...

Seems like an impossible task for the win32 api then?
Yes, unfortunately not possible if the application is written with something like Qt or JUCE.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 07-31-2019, 09:08 AM   #645
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Is there a way to make a window in Reaper full-screen? Would love to have a way to make the gfx-window fullscreen or maybe the FX-Chain one in some usecases.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-31-2019, 10:00 AM   #646
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,250
Default

Quote:
Originally Posted by mespotine View Post
Is there a way to make a window in Reaper full-screen? Would love to have a way to make the gfx-window fullscreen or maybe the FX-Chain one in some usecases.
Have you tried sending maximize window message,.. (hwnd, "WM_SYSCOMMAND", 0xF030, 0,0,0), posted on reapack,..

Maximize foreground window
https://raw.githubusercontent.com/Re...d%20window.lua

Restore foreground window
https://github.com/ReaTeam/ReaScript...d%20window.lua

EDIT,
Theres also the ShowWindow function, https://docs.microsoft.com/en-us/win...ser-showwindow
Code:
reaper.BR_Win32_ShowWindow(hwnd, cmdShow)

Last edited by Edgemeal; 07-31-2019 at 11:13 AM.
Edgemeal is offline   Reply With Quote
Old 07-31-2019, 11:59 AM   #647
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,911
Default

Quote:
Originally Posted by Edgemeal View Post
posted on reapack,..
Works also with a floating docker.
Cool, thanks.
nofish is offline   Reply With Quote
Old 08-02-2019, 08:52 AM   #648
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Quote:
Originally Posted by Edgemeal View Post
Have you tried sending maximize window message,.. (hwnd, "WM_SYSCOMMAND", 0xF030, 0,0,0), posted on reapack,..

Maximize foreground window
https://raw.githubusercontent.com/Re...d%20window.lua

Restore foreground window
https://github.com/ReaTeam/ReaScript...d%20window.lua

EDIT,
Theres also the ShowWindow function, https://docs.microsoft.com/en-us/win...ser-showwindow
Code:
reaper.BR_Win32_ShowWindow(hwnd, cmdShow)
Thanx! Will look into that
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 08-05-2019, 02:28 PM   #649
AndrewFalcon
Human being with feelings
 
AndrewFalcon's Avatar
 
Join Date: Dec 2018
Posts: 16
Default

Quote:
Originally Posted by juliansader View Post
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).
Julian please can you explain how to use reaper.JS_Mouse_GetCursor()? Numbers change every session.
It can be better and more detailed replacement for BR_GetMouseCursorContext()
May be load handles when JS_API starting?Inside JS_API . And return stable handles.To facilitate use commoners))
AndrewFalcon is offline   Reply With Quote
Old 08-05-2019, 02:37 PM   #650
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,439
Default

Quote:
Originally Posted by AndrewFalcon View Post
Julian please can you explain how to use reaper.JS_Mouse_GetCursor()? Numbers change every session.
It can be better and more detailed replacement for BR_GetMouseCursorContext()
May be load handles when JS_API starting?Inside JS_API . And return stable handles.To facilitate use commoners))
Code:
local reaper_cursors =  {
                          {187,"MOVE"},  -- MOVE
                          {185,"DRAW"},  -- DRAW
                          {417,"EDGE L"},  -- LEFT EDGE
                          {418,"EDGE R"},  -- RIGHT EDGE
                          {184,"FADE L"},  -- FADE RIGHT
                          {105,"FADE R"},   -- FADE LEFT
                        }

function project_mouse_info()
    local cur_cursor = reaper.JS_Mouse_GetCursor()
    for i = 1, #reaper_cursors do
        local cursor = reaper.JS_Mouse_LoadCursor( reaper_cursors[i][1] )
        if cur_cursor == cursor then
          return reaper_cursors[i][2]
        end
    end
end
You can extract them via resource hacker

Quote:
Originally Posted by AndrewFalcon View Post
It can be better and more detailed replacement for BR_GetMouseCursorContext()
That was the general idea

Last edited by Sexan; 08-05-2019 at 02:43 PM.
Sexan is offline   Reply With Quote
Old 08-05-2019, 03:09 PM   #651
AndrewFalcon
Human being with feelings
 
AndrewFalcon's Avatar
 
Join Date: Dec 2018
Posts: 16
Default

Thank you Sexan!Understand now if you use custom cursors you get nil from this function.I get only FADEs because they reaper original

Last edited by AndrewFalcon; 08-05-2019 at 03:17 PM.
AndrewFalcon is offline   Reply With Quote
Old 08-05-2019, 03:17 PM   #652
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,439
Default

well call project_mouse_info() in your main function and when you get the value make it do something:

Code:
function main()
 cur = project_mouse_info()
 if cur == "FADE L" then
 -- do some voodoo here
 end
end
I only populated few cursors since I'm testing stuff. but you can use resource hacker to see all cursors and their ID
It works excellent as far as I've tested (tracking if you are on envelope point,item fade,edge ....)
EDIT: I did not test it with custom cursors yet
Sexan is offline   Reply With Quote
Old 08-08-2019, 09:21 AM   #653
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,670
Default

Hello

I have a big problem with the update version of Reascript API functions for Reascrpits

If I use version 0.989, the following script don't work

Code:
-- USER CONFIG AREA --

W_action_id = "_S&M_CYCLACTION_12" -- Main Tool
W_section = "Main"

-----

Wkey = 0x57 -- W -- https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes

----------------------

-- Globals
armed, section = reaper.GetArmedCommand()
 if armed == action_id then
 toggle_state = 1
 else
 toggle_state = 0 
end
-- Set ToolBar Button State
function SetButtonState( set )
  if not set then set = 0 end
  local is_new_value, filename, sec, cmd, mode, resolution, val = reaper.get_action_context()
  local state = reaper.GetToggleCommandStateEx( sec, cmd )
  reaper.SetToggleCommandState( sec, cmd, set ) -- Set ON
  reaper.RefreshToolbar2( sec, cmd )
end
  
-- Main Function (which loop in background)
function main()

  retval, state = reaper.JS_VKeys_GetState()
  window, seg, detail= reaper.BR_GetMouseCursorContext()
  

-- W Key
  if state:byte(Wkey) ~= 0 then
    if toggle_state == 0 and window ~= "tcp"  then
      reaper.ArmCommand( reaper.NamedCommandLookup(W_action_id), W_section )
      reaper.UpdateArrange()
      toggle_state = 1
    end
-- W key
  else
    if toggle_state == 1 and window ~= "tcp"  then
      reaper.ArmCommand(0, "Main")
      reaper.UpdateArrange()
      toggle_state = 0
    end
  end
  
  reaper.defer( main )
  
end

-- RUN
if not reaper.JS_VKeys_GetState then
  reaper.ShowConsoleMsg('Please Install js_ReaScriptAPI extension.\nhttps://forum.cockos.com/showthread.php?t=212174\n')
else
  reaper.ClearConsole()
  SetButtonState( 1 )
  main()
  reaper.atexit( SetButtonState )
end
Red line is buggy

With version 0.980, everything work as expected

Any idea?

Thanks in advance
Reno.thestraws is offline   Reply With Quote
Old 08-08-2019, 09:34 AM   #654
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

What is the bug that you see in the red line when you run the script?

(BTW, are you perhaps using a recent dev version of REAPER? BR_GetMouseCursorContext is temporarily broken in the dev versions, and you need to download SWS from landoleet.)
juliansader is offline   Reply With Quote
Old 08-08-2019, 09:44 AM   #655
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by AndrewFalcon View Post
Julian please can you explain how to use reaper.JS_Mouse_GetCursor()? Numbers change every session.
It can be better and more detailed replacement for BR_GetMouseCursorContext()
May be load handles when JS_API starting?Inside JS_API . And return stable handles.To facilitate use commoners))
JS_Mouse_GetCursor is an interface to the Win32 function GetCursor, and a good place to start is MS's documentation for the function. The returned value is a handle created by the operating system, so it unfortunately it will likely change every session.

For help on using Resource Hacker, check out the thread WDL/SWELL and C++ extensions: How to change mouse cursor?.
juliansader is offline   Reply With Quote
Old 08-08-2019, 10:08 AM   #656
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,670
Default

@Julian

I use last officiel version pc both reaper and sws

In the same config, same version, pc, everything, the script work with your api extension v0.980. If I switch to 0.989 via reapack, script don't work anymore

switch back to 0.980 and it work again

the script is base on continuous key.

in short, the script is a defer waiting for the W key to be pressed. If the key is pressed, then it execute a cycle action
Reno.thestraws is offline   Reply With Quote
Old 08-08-2019, 10:09 AM   #657
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,250
Default

Quote:
Originally Posted by Reno.thestraws View Post
Red line is buggy
With version 0.980, everything work as expected
IIRC in early JS versions VKeys_GetState didn't require any params, but then he added a cutoffTime param, so now if I don't enter a value (like 0.1) VKeys_GetState will error.

test,
Code:
function main() -- testing REAPER v5.981+dev0807/x64, JS v0.989
  state = reaper.JS_VKeys_GetState(0.1)
  if state:byte(0x57) ~= 0 then msg('W key') end 
  reaper.defer(main)
end
main()
@ juliansader,
JS_VKeys_GetState should probably raise an error if cutoffTime param is not set.
Or are we using it wrong?

Last edited by Edgemeal; 08-08-2019 at 10:49 AM.
Edgemeal is offline   Reply With Quote
Old 08-08-2019, 10:30 AM   #658
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,670
Default

@edgemeal

Thanks a milion

you nailed it

state = reaper.JS_VKeys_GetState(0.1)

instead of

retvalue, state = reaper.JS_VKeys_GetState()
Reno.thestraws is offline   Reply With Quote
Old 08-09-2019, 04:52 AM   #659
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,921
Default

Hi,


Is it possible to populate a search field with a string ?


I suppose I could just enter several keyword event but that seems overkill (and a bit hard to code as all character have to be converted to a certain key :P)


Thx !
X-Raym is offline   Reply With Quote
Old 08-09-2019, 06:12 AM   #660
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

If you are on Windows, you can send a pointer to the string via a window message as described in this post above.

Sending a string requires a bit of a workaround to recreate the Lua string in memory, so I would have liked to add an optional string parameter to the window messaging functions, but optional string parameters are still buggy.
juliansader is offline   Reply With Quote
Old 08-09-2019, 06:15 AM   #661
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Try JS_Window_SetTitle. If that fails, you can also add a mouseclickevent into the searcharea-hwnd. That often triggers Reaper to accept changes done by scripts.

Would be my naive approach.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 08-09-2019, 07:20 AM   #662
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,921
Default

Thanks you both :P


mespotine JS_Window_SetTitle trick work in my case (media explorer search field) so as it is cross-platform and only one line to use, I'll for it ! :P
X-Raym is offline   Reply With Quote
Old 08-09-2019, 09:32 AM   #663
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

v0.990 uploaded:
* Fix: JS_Window_SetOpacity works on macOS. (Finally figured this one out!)
* New: JS_Window_Create. (Including transparent frameless windows!)
* New: JS_ListView_EnsureVisible.
* New: More options for Window_Show.
* New: JS_Window_SetZOrder options work on macOS. (Bit of a hack to replace the WDL/swell functions.)

EDIT: Here is an example of a frameless and a default framed window on Linux, both animated:

Last edited by juliansader; 08-09-2019 at 01:51 PM.
juliansader is offline   Reply With Quote
Old 08-09-2019, 10:57 AM   #664
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,600
Default

Wow, awesome, thanks Julian!

Quote:
* New: More options for Window_Show
Are they documented somewhere?
__________________
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 online now   Reply With Quote
Old 08-09-2019, 12:11 PM   #665
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by _Stevie_ View Post
Are they documented somewhere?
In the ReaScript help:
Quote:
"Sets the specified window's show state.

Parameters:
* state: One of the following options: "SHOW", "SHOWNA", "SHOWMINIMIZED", "HIDE", "SHOWNOACTIVATE", "NORMAL", "SHOWNORMAL", "SHOWMAXIMIZED", "SHOWDEFAULT" or "RESTORE". On Linux and macOS, only the first four options are fully implemented.
and MS's documentation for ShowWindow.


Quote:
Originally Posted by Edgemeal View Post
EDIT,
Theres also the ShowWindow function, https://docs.microsoft.com/en-us/win...ser-showwindow
Code:
reaper.BR_Win32_ShowWindow(hwnd, cmdShow)
Warning: WDL/swell on Linux/macOS uses different integers to represent these options than Win32 does on Windows, so if you use BR_Win32_ShowWindow, you must check which OS the script is running on, and use the numbers in swell-types.h if you are on Linux/macOS.

Last edited by juliansader; 08-09-2019 at 12:18 PM.
juliansader is offline   Reply With Quote
Old 08-10-2019, 08:25 AM   #666
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,600
Default

Quote:
Originally Posted by juliansader View Post
In the ReaScript help:
Awesome, didn't know that this is the first place to look, thanks!


Btw, this can't be used to remove the frame/borders from an existing window, right?:
Quote:
* New: JS_Window_Create. (Including transparent frameless windows!)
__________________
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...

Last edited by _Stevie_; 08-10-2019 at 08:33 AM.
_Stevie_ is online now   Reply With Quote
Old 08-11-2019, 05:15 PM   #667
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,921
Default

is reaper.JS_Window_SetTitle supposed to support UTF-8 characters ?


These dont works in Media Explorer search field.
X-Raym is offline   Reply With Quote
Old 08-13-2019, 12:01 PM   #668
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Quote:
Originally Posted by X-Raym View Post
is reaper.JS_Window_SetTitle supposed to support UTF-8 characters ?


These dont works in Media Explorer search field.
Can you enter successfuly UTF-8 characters by keyboard and read them out with Lua?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 08-13-2019, 12:54 PM   #669
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,921
Default

@mespotine
Hmm it works if UTF-8 characters are sampled from the search bar itself.



But not if injected from script:


Code:
function GetMediaExplorer()
  local title = reaper.JS_Localize("Media Explorer", "common")
  local arr = reaper.new_array({}, 1024)
  reaper.JS_Window_ArrayFind(title, true, arr)
  local adr = arr.table()
  for j = 1, #adr do
    local hwnd = reaper.JS_Window_HandleFromAddress(adr[j])
    -- verify window by checking if it also has a specific child.
    if reaper.JS_Window_FindChildByID(hwnd, 1045) then -- 1045:ID of volume control in media explorer.
      return hwnd
    end 
  end
end

function UpdateMediaExplorerSearch( str )

  hWnd = GetMediaExplorer()
  search = reaper.JS_Window_FindChildByID(hWnd, 1015) 
  
  if search then
    if not reaper.JS_Window_IsVisible(search) then -- when docked but not visible
      reaper.Main_OnCommand(50124, 0) -- Media explorer: Show/hide media explorer 
    end
    reaper.JS_Window_SetFocus(search)
  end
  
  -- Change keyword
  reaper.JS_Window_SetTitle( search, str )
end

UpdateMediaExplorerSearch( "héhé" )
X-Raym is offline   Reply With Quote
Old 08-13-2019, 01:31 PM   #670
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Could you try to convert the string using the utf8-functions Lua provides?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 08-13-2019, 02:21 PM   #671
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,921
Default

@mespotine

I tried some utf-8 libraries without sucess but I dont see any native lua functions to try...


You can test my code if you want to test, it is ready to use :P


I see the utf8 function but it is limited. I tried utf8.char(233) and it appears as "é" in the field. Weird.

Last edited by X-Raym; 08-13-2019 at 02:27 PM.
X-Raym is offline   Reply With Quote
Old 08-13-2019, 02:53 PM   #672
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Hmm...usually a sign, that the conversion to utf isn't done completely. Happens to me from time to time with gfx.getchar.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 08-14-2019, 07:05 PM   #673
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Thanks for pointing this out. I will shortly upload a new version with better UTF-8 / Unicode support.
juliansader is offline   Reply With Quote
Old 08-15-2019, 12:56 PM   #674
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396
Default

Julian: You Rock!
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine 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 04:11 PM.


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