alfredclough Posted September 11, 2023 Posted September 11, 2023 I'm trying to dynamically set the X Origin, Y Origin, etc in a Set Custom Window Bounds automation task but I cannot figure out how to pass in the variables. Do I need to use environment variables or can I set it all in JSON similar to this: https://www.alfredforum.com/topic/18701-dynamic-input-for-automation-tasks/?_fromLogin=1 ? If this can be set by JSON where do I find the config variable information necessary to set the variables?
vitor Posted September 11, 2023 Posted September 11, 2023 1 hour ago, alfredclough said: Do I need to use environment variables or can I set it all in JSON similar to this Those are the same thing; when you set the variables in the JSON, they are set as environment variables. Without knowing more about your workflow it’s not possible to give a specific answer to the best approach. Bottom like, you’ll use {var:} in the Automation Task’s configuration. How you make those variables is up to you: with an Arg and Vars Utility, or JSON Utility or something else.
alfredclough Posted September 13, 2023 Author Posted September 13, 2023 I'm trying to make sure I am not missing something obvious, but I'm not getting the expected result. I have a script option that, for example, outputs the following: "{ \"alfredworkflow\" : { \"variables\" : { \"new_x\" : 10, \"new_y\" : 100, \"new_width\" : 835, \"new_height\" : 1097 } } }" Then I have an automation task that looks like the attached. However the window is not moved properly as if the variables are not resolving correctly. If I hard code the values instead of using the variables then the window does move correctly. I cannot figure out what is wrong here.
vitor Posted September 13, 2023 Posted September 13, 2023 Please share the workflow itself. It’s impossible to diagnose that otherwise.
alfredclough Posted September 13, 2023 Author Posted September 13, 2023 38 minutes ago, vitor said: Please share the workflow itself. It’s impossible to diagnose that otherwise. Here's a link to the workflow: https://web.tresorit.com/l/fw0DE#qF-3oQJjPhobwKyyYX1iqA
vitor Posted September 13, 2023 Posted September 13, 2023 You’re stringifying a string, you have to stringify the object. Fixed correct code: return JSON.stringify({ alfredworkflow: { variables: { new_x: newX, new_y: newY, new_width: newWidth, new_height: newHeight } } } ); But why go through all that trouble? Isn’t the workflow reinventing what’s already available through the Resize Window from Preset Automation Task?
alfredclough Posted September 13, 2023 Author Posted September 13, 2023 2 hours ago, vitor said: But why go through all that trouble? Isn’t the workflow reinventing what’s already available through the Resize Window from Preset Automation Task? Thank you so muich. The reason to go through all that trouble is I want the ability to put a margin or space between windows. So this allows me to adjust the windows with margin around them. I could not see a way to do that with the preset task. In my case I can choose 1/2 screen but the workflow has a variable for margin that leaves a bit of border around the window.
alfredclough Posted September 14, 2023 Author Posted September 14, 2023 On 9/13/2023 at 7:21 AM, vitor said: You’re stringifying a string, you have to stringify the object. Fixed correct code: I'm very confused - I updated the code but now the workflow seems to only half work. The X and width coordinates are set properly, but the Y ones are not. And when I try to debug the alfred debugger says that nothing is being returned by the script. 🤔
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now