Jump to content

How to Set Dynamic Input to Set Custom Window Bounds Automation


Recommended Posts

Posted

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? 

 

Posted
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.

Posted

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.

 

Screenshot 2023-09-12 at 8.43.36 PM.png

Posted

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?

Posted
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.

Posted
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. 🤔

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...