Sgordet Posted August 22, 2021 Report Share Posted August 22, 2021 Is there a way that a non-programmer can use Macro Express to change the size of a re-sizable window? I want to be able to increase a window's length and width by a given percentage and, later, restore it to the original size. Quote Link to comment Share on other sites More sharing options...
rberq Posted August 22, 2021 Report Share Posted August 22, 2021 Yes, it certainly can be done. Presumably you would use one macro to save the initial size and re-size the window; and a second macro to restore the initial size. Command VARIABLE SET INTEGER can be used to load the original location and dimensions of the window into variables. Commands WINDOW RESIZE and/or WINDOW REPOSITION and/or WINDOW MOVE AND SIZE can change the location and dimensions. All pretty straightforward. The hardest part probably is storing the integer values somewhere so they can be retrieved when it is time to reset the window location and size to the original. Because it's simple and straightforward, I prefer writing the values to a temporary .txt file, and then reading the file when it's time to reset the window. There are other places to store the values, such as environment variables or the registry. Quote Link to comment Share on other sites More sharing options...
Sgordet Posted August 22, 2021 Author Report Share Posted August 22, 2021 Thanks, rberq. Unfortunately, this is far beyond my limited my limited macro writing capability. Best, Stephen Quote Link to comment Share on other sites More sharing options...
acantor Posted August 22, 2021 Report Share Posted August 22, 2021 Hi Stephen, Maybe start with this three-line macro, which shrinks the current window by a set amount: the window will be 50% less wide, and 60% less high. You can change the values to suit your needs. The key point is that negative values decrease the size of the window, and positive values increase it. If the macro works, then make a second macro that uses positive numbers. Use one macro to shrink the window, and the second macro to enlarge the window. These two macros may not be exactly what you're looking for, but hopefully, the solution will be good enough. If you're new to macro scripting, rberq's more versatile solution might be a lot to take on. Variable Set Integer %WidthPercent% to -50 // Shrink or enlarge the window width by this percentage Variable Set Integer %HeightPercent% to -60 // Shrink or enlarge the window height by this percentage Window Resize: <Current Window> Enlarge/Decrease by %WidthPercent% percent, %HeightPercent% percent <VARIABLE SET INTEGER Option="\x00" Destination="%WidthPercent%" Value="-50" _COMMENT="Shrink or enlarge the window width by this percentage"/> <VARIABLE SET INTEGER Option="\x00" Destination="%HeightPercent%" Value="-60" _COMMENT="Shrink or enlarge the window height by this percentage"/> <COMMENT/> <WINDOW RESIZE Option="\x00" Partial="TRUE" Wildcards="FALSE" Method="\x02" Width="%WidthPercent%" Height="%HeightPercent%" _IGNORE="0x0006"/> Quote Link to comment Share on other sites More sharing options...
Sgordet Posted August 22, 2021 Author Report Share Posted August 22, 2021 Thanks, acantor. I’ll give it a try. Quote Link to comment Share on other sites More sharing options...
Sgordet Posted September 2, 2021 Author Report Share Posted September 2, 2021 acantor, please excuse my total lack of knowledge: I tried to enter the script in the script editor, one line at a time. When going to save, I got several requests regarding creating variables, which I answered yes to. Based on the fact that the macro didn't run, I assume that this wasn't the right way to go about it. Any further help would be appreciated. Thanks, Stephen Quote Link to comment Share on other sites More sharing options...
acantor Posted September 4, 2021 Report Share Posted September 4, 2021 Hi Stephen, It sounds like you did everything right. If you open the macro in the Script Editor, the code should look something like this: Question: What activation did you choose for your macro? Quote Link to comment Share on other sites More sharing options...
Sgordet Posted September 4, 2021 Author Report Share Posted September 4, 2021 Thanks so much acantor. I've added the lines exactly as you've shown them, but I seem to need to do something additional. After I save the macro and then re-open it, I see that the script editor has prefixed the third statement with "Text Type (Simulated Keystrokes)." If I delete this added language, it re-inserts it again after I close the editing window and re-open it. I'm using Ctrl F for the activation. The way that the macro currently stands, it scrolls the page when I enter the activation keys. Quote Link to comment Share on other sites More sharing options...
acantor Posted September 4, 2021 Report Share Posted September 4, 2021 It sounds like the problem may be the method you entered the third line of code. Try doing it this way: 0. Delete third line from your script. 1. From the list of categories on the left side of the screen, choose "Windows/Programs" 2. From the group, choose "Window Resize." This should cause the "Window Resize" window to appear. 3. In the Window Resize window, double check that "Use the current window" is selected. 4. Type in the two variable names for width and height, as indicated. Save your macro, open a window you want to resize, and press Ctrl + F. Quote Link to comment Share on other sites More sharing options...
Sgordet Posted September 4, 2021 Author Report Share Posted September 4, 2021 Worked like a charm. I never would have figured it out if you hadn't taken the time to illustrate the procedure for me. I'll try to pay it forward in an area where I have some knowledge. Thanks again, Stephen Quote Link to comment Share on other sites More sharing options...
acantor Posted September 5, 2021 Report Share Posted September 5, 2021 Hi Stephen, The clarity of your explanations made it easy to figure out what was holding you back. There is a lot to puzzle out when learning to script macros. Hopefully you've arrived at the next level! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.