You can fetch some properties of scene items with the fetchprops command. The properties are saved in the deck variables that you specify.
The parameters are;
- scene=<scene name>
- item=<item name>
- group=<group name> (optional)
- delay=<time in ms> (optional)
- x=<variable name> (optional) - the x position of the scene item
- y=<variable name> (optional) - the y position of the scene item
- bw=<variable name> (optional) - the bounds width
- bh=<variable name> (optional) - the bounds height
- text=<variable name> (optional) - the text displayed if the item is a text field
The scene, item and group parameters are case sensistive, so must be exactly as they appear in OBS.
The group parameter must be used if the scene item is in a group (available from OBS Studio v22).
The optional delay specifies a time (in milliseconds) to wait before running the command.
For more info on bounds : Bounding_Box_Type
Example - fetch the x and y co-ordinates of the Message item and put the values in $message_x and $message_y
Fetch message position fetchprops scene=Studio item=Message x=message_x y=message_y |
Note : no $ before the variable names for fetchprops (they are just the names to assign the values to).
Gotchas
Due to fetchprops having to request and receive values from the desktop app (which takes time), those values are not immediately available, so the following commands would NOT work as expected;
Get current message fetchprops scene=Studio item=Message text=message_text
Put message in featured field text source=Featured text=$message_text |
The variables in the commands are substituted and processed before the requested values are received, so the $message_text in the second command is substituted before the first command receives the current value from OBS! There are a couple of ways to work around this.
1. Put the first command in a button and then call another button containing the second command.....
First button (example : button 29);
Get current message fetchprops scene=Studio item=Message text=message_text
Update featured field button id=30 |
Second button (button 30);
Put message in featured field text source=Featured text=$message_text |
2. Create a toggle button - same method, but put the commands above into the two states of the button and let the button press itself.....
First button state (example : button 29 - note the button presses itself);
Get current message fetchprops scene=Studio item=Message text=$message_text
Press this button again id=29 |
Second button state;
Put message in featured field text source=Featured text=$message_text |
Both button states are processed and the button is reset to its orignal state.