Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-03-2017, 02:35 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
Script to resize window?

I would like to create a script to resize the SecureCRT window. I'm not able to find an example or document for the objects/API that would do this. The end goal is to map Alt-R to the script so that it resizes the window to a set size (50 rows, 100 columns). Any help would be appreciated.

Last edited by jake1138; 05-04-2017 at 12:26 PM.
Reply With Quote
  #2  
Old 05-03-2017, 03:23 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi jake1138,

I think this may be something better suited bot the Button Bar.

The Button Bar
--> View > Button bar

Use the button bar to map buttons to the script.
https://www.vandyke.com/support/tips/button_bar.html

I've included a very brief script example that seems to accomplish what you are looking for.

Code:
# $language = "VBScript"
# $interface = "1.0"

crt.session.config.setoption "Rows", "50"
crt.session.config.setoption "Cols", "100"
Does this help?

There are a few additional things you may want to keep in mind when working with screen geometry.

When you connect a session, the window will resize based on the settings in that session regarding rows/columns and the "On resize" configuration. When not connected, SecureCRT should be getting that info from the Default Session. Those configuration options are found in the 'Terminal / Emulation' category of Session Options (or Default Session):

https://www.vandyke.com/support/tips/defaultset.html

Every connection from then on, if you are connecting sessions in tabs, is also going to be controlled by the configuration in that first tabbed session.

This will mean if you have multiple sessions opened and you try to set the rows/columns for a tab other than the first tab it will not have an effect.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 05-03-2017, 05:30 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
That almost does what I want. It dynamically resizes the window height to 50 rows but it resizes the window width to 256 columns! It doesn't matter what value I give it for Cols, it always resizes to 256.
Reply With Quote
  #4  
Old 05-03-2017, 05:45 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi jake1138,

If you navigate to Options > Session Options then select the Terminal > Emulation category you will find a On Resize option. What do you have selected?

This might also be affecting the way your text is displayed. The "Synchronize view to size" option will allow you to set your font size, but when you resize the window, your rows and columns settings will change to fill up the window. The "Scale the font" option will allow you to set your rows and columns settings and when you resize the window, the font will grow or shrink so that your rows and columns can stay constant so that the whole window gets filled up. The "Retain size and font" option will allow you to set your font size and your rows and columns so that they all remain constant, even if it means that you have extra blank space in your window or if the window is too small to see everything.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 05-03-2017, 06:05 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
If I go to Options > Session Options > Emulation and set the "Logical rows" and "Logical columns" it works as expected. If I set the rows to 50 and columns to 100 and click OK, the Windows resizes just fine. Why doesn't the script behave the same way?

Under "On resize", I have it set to "Synchronize view to size" which I assume is the default because I've never changed that. The "Scale the font" option definitely isn't what I want as that makes the font tiny and it only shows text in a small portion of the window (and resizing the window doesn't change that). I looked further and found that it changed my font from "vt100 10pt" to "vt100 5pt". I had to manually change that back to fix the problem.
Reply With Quote
  #6  
Old 05-03-2017, 07:23 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
SOLVED: I upgraded to SecureCRT 8.1.2 and now the script works as expected. So it looks like it was a bug in the old version (7.1.1).

By the way, I mapped Alt-R to execute the script and it does exactly what I want. Thanks for your help!
Reply With Quote
  #7  
Old 05-04-2017, 08:59 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi jake1138,

Glad to hear that it is working for you. There is one slight modification to my original script that may make it a little more stable. To help ensure that the information is applied correctly every time you could remove the "" around the number of rows and columns. For example instead of "50" modify it to just be 50.

Please don't hesitate to reach out if you have any other questions or concerns.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #8  
Old 05-04-2017, 12:25 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
It seemed to be working fine as-is but I went ahead and removed the double quotes as you suggested. All good. Thanks.

Last edited by jake1138; 05-04-2017 at 12:28 PM.
Reply With Quote
  #9  
Old 05-04-2017, 05:12 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
I found that if I have two separate windows open for a given session (I don't use tabs) and I execute the script in one, it'll apply the change to the other window and it moves that other window immediately under the current window. In other words, it stacks it underneath the current window. Same thing occurs if I have more than two windows. It stacks them all. The same thing happens if I go into Session Options and set the rows and columns there.

Is there no way to write a script that would affect only the current window? I can drag and resize the current window with my mouse, why can't I programmatically do the same thing? I'm actually fine with it applying to all the windows but why does it stack the windows?
Reply With Quote
  #10  
Old 05-04-2017, 05:30 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi jake1138,

That is an interesting issue. How are you opening the multiple windows?

I've tried several ways and can't seem to reproduce the issue.
  • Right clicked on a session in the Session Manager and used Connect in New Window
  • Right clicking on the tab and choosing Clone in New Window.
  • Tested with Tabs/Tile/Cascade Window options.
Can you provide more exact steps to reproduce the issue?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #11  
Old 05-04-2017, 05:40 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
I have a hotkey Alt-D mapped to MENU_TAB_CLONE_IN_NEW_WINDOW which I use to open a new window for the current session. That is my standard procedure for opening additional windows for the current session. I don't use tabs because I need to be able to see multiple windows at the same time.

So it would seem that while these look like different windows, they still belong to the master window as if they were tabs. Is that why this is happening? Is there a different way that I can clone windows without involving tab logic?
Reply With Quote
  #12  
Old 05-04-2017, 06:03 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
I found that this only happens if one of the two windows has been resized so it is not 50x100. If they're both 50x100, then the windows stay in place. If I resize either window and do the Alt-R hotkey (or show tabs and use Clone In New Window from tab right-click menu), they get stacked.

If I use Connect In New Window from the Session Manager, then everything works as expected. If I do Alt-R, it only affects the current window. If I resize the other window and do Alt-R, again it only affects the current window. So the stacking and resizing of windows seems to only happen with windows created using Clone In New Window.

Last edited by jake1138; 05-04-2017 at 06:15 PM.
Reply With Quote
  #13  
Old 05-04-2017, 06:15 PM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
I suspect the reason why "Clone In New Window" works the way it does is because it lets you re-attach that window to the tab bar. Because if you create a window using Connect In New Window, that window cannot be attached to another window's tab bar. So what I really need is a way to clone a session to a new window without any tab logic at all. Imagine if we had the option under File that reads "Clone Session in New Window" that behaved the way the "Connect In New Window" does in Session Manager. Then I could map Alt-R to that and side step all this tab logic.

Even if you didn't add the "Clone Session in New Window" option on the File menu, if there was a way to do that in script, that would be sufficient for my purposes. But I would say anyone who doesn't want to use tabs, having a "Clone Session in New Window" option would be useful. Because if you're not showing tabs, there is no way to clone sessions without setting up a custom hotkey like I did.

Last edited by jake1138; 05-04-2017 at 06:24 PM.
Reply With Quote
  #14  
Old 05-05-2017, 10:49 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi jake1138,

It sound like Save window state for each session may be enabled and leading to this behavior. If you navigate to Options > Global Options and select the Terminal category, is Save window state for each session enabled? Does disabling this option provide the behavior you are looking for?

I know you've indicated you don't use tabs and that you need to view multiple sessions at once, have you tried utilizing Tab Groups (Connect in New Tab Group)? It provides a nice way to view multiple sessions at once.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #15  
Old 05-08-2017, 11:06 AM
jake1138 jake1138 is offline
Registered User
 
Join Date: Jan 2013
Posts: 19
With "Save window state for each session" disabled, the behavior is better for sure. Alt-R resizes all the session windows without moving them so that is better. Alt-D opens a new session window with the same size as the one I'm duplicating and it also cascades it so you can see the original window behind it. That is an improvement to prior behavior where it would stack the new window directly on top.

I would still prefer that Alt-R did not resize all the windows, just the one I'm on. So I think "Clone Session in New Window" would still be a good option to have. Could you submit a feature request for that?
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 -6. The time now is 01:51 AM.