Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

WinMove problem with Putty


  • Please log in to reply
6 replies to this topic
ccharbo
  • Members
  • 4 posts
  • Last active: Sep 13 2008 12:49 PM
  • Joined: 08 Feb 2006
Hi all,

I know this has already been discussed earlier (6 months ago), but I would like to go further on...

In fact, I investigated a bit, and found something interesting.
Here's what this is all about:

When wanting to resize a putty window with the WinMove command, it won't work. In fact, the window "glitters" a bit, and "pouf", comes back to its original size.

But I noticed that if I try to "WinMove putty,,,,300,27", the putty window will be resized accordingly.
But now, if I try an height >27, (for example WinMove putty,,,,300,28 ), "pouf", the window glitters, and is resized to the original size (the one it had when started).

Anybody has an answer for that weird behavior ???

Thanxs in advance

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
PuTTY Configuration -> Window -> When window is resized -> ...the resize probably can't be in 1-pixel increments...it probably needs to be in about 10 or 20px increments...if set to "Change the number of rows and columns". If set to "Forbid resizing completely"...well then there's your answer. PuTTY isn't like other programs where the size can be weird...it's text-based & (for me) fixed width...command lines aren't meant to be used with a variable width font & a wierd number of rows/columns.

Chris...does WinMove send WM_WINDOWPOSCHANGING & WM_WINDOWPOSCHANGED or just WM_WINDOWPOSCHANGED...PuTTY might not expect to recieve -ED without seeing -ING.
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

  • Guests
  • Last active:
  • Joined: --
Well, I ommited to tell my putty options regarding the window behavior uppon resizing. In fact, I want putty to "Change the number of rows and columns"...

I tried the several options, and when set to "Change the size of the font", everything works nice. But that's not what I want. I want putty to change the terminal properties, ie the number of rows and columns.

I pointed out the problem might come from that. As putty only allows resizing (with mouse dragging) by steps, relative to font dimension, I also tried to send WinMove different dimensions so as it's multiple of font dimensions... But, that did not work either...

I wonder if there is really a solution for my problem ???

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
Solved!

F8::
SetTitleMatchMode, 2
IfWinExist, PuTTY ahk_class PuTTY
{
	WinGet, hwndputty, id
	;hwndputty:="ahk_id " hwndputty
	WinGetTitle, t, ahk_id %hwndputty%
	WinGetPos, x, y, w, h
	msgbox=,
	(LTrim
		hwndputty(%hwndputty%)
		t(%t%)
		x(%x%) y(%y%) w(%w%) h(%h%)
	)
	;WinMove, , , , , , % h+15
	MoveWindow(hwndputty, x, y, w, h+15)
	WinGetPos, x, y, w, h
	msgbox=,
	(LTrim
		hwndputty(%hwndputty%)
		t(%t%)
		x(%x%) y(%y%) w(%w%) h(%h%)
	)
}
Else msgbox, 16, , PuTTY not found!
return

MoveWindow(hwnd, x, y, w="", h="", repaint=1)
{
	WM_ENTERSIZEMOVE=0x0231
	 WM_EXITSIZEMOVE=0x0232
	SendMessage, WM_ENTERSIZEMOVE
	WinMove, , , x, y, w, h
	;DllCall("MoveWindow", "UInt", hwnd, "Int", x, "Int", y, "Int", w, "Int", h, "Int", repaint)
	SendMessage, WM_EXITSIZEMOVE
}
...I'm constantly amazed at how many long standing problems I solve in 5 mins...what's that other thread 5 mos old?

Chris...perhaps WinMove should natively send WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE...I don't think it could possibly hurt...
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
OK, I looked at the PuTTY code...
As I expected, it uses complex code to handle the different options and move by steps if needing to resize by text cells.
It uses a notification I didn't knew the existence until now: WM_ENTERSIZEMOVE and its companion WM_EXITSIZEMOVE.
As I understand them, this allows to reduce the repaints or, as here, of resizings (snapping to text cell sizes), when the user drags the borders with the "Display window content while moving them" option.

The workaround is therefore simple:

SetTitleMatchMode 2
WM_ENTERSIZEMOVE = 0x231
WM_EXITSIZEMOVE = 0x232

#P::
SendMessage WM_ENTERSIZEMOVE, , , , PuTTY
WinMove PuTTY, , , , 667, 756
SendMessage WM_EXITSIZEMOVE, , , , PuTTY
Return
It works! :-)

[EDIT] Mmm, I spent too much time typing my answer, JSLover was faster than me. Congratulations! :-D
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

perhaps WinMove should natively send WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE...I don't think it could possibly hurt...

It could impact performance because some apps are slow to respond to SendMessage; in the worst case, the message times out after 2 seconds because the app is too busy (and during those 2 seconds, the script is completely unresponsive because it must listen for the response).

By contrast, I think the OS directly moves the window when you call the API's MoveWindow(), which seems likely to be a lot faster than sending messages (at least in some cases).

Given the rarity of this issue, perhaps it's best simply to leave this undocumented except for this post in the forum.

Thanks for researching and posting the solutions.

  • Guests
  • Last active:
  • Joined: --
Thanks a lot, this really helped me out! Cheers!