AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

(Possible) Bug with WinSet, Region?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
antonyb



Joined: 26 May 2004
Posts: 61

PostPosted: Wed Mar 09, 2005 4:37 pm    Post subject: (Possible) Bug with WinSet, Region? Reply with quote

Hi,

When I run the following code, the final WinMaximize doesn't behave as I'd expect it to. The window I run the code on maximises, but I can't see it all - the visible area seems to be exactly the same size as the previously unmaximized window. Hard to explain, but you'll see what I mean.

I presume its something to do with "WinSet, Region, , A" not properly reseting the visible region?

Code:
#k::
  WinMaximize, A
  Sleep, 2000
  WinRestore, A
  Sleep, 2000
  WinGetPos , , , ws_width, , A
  WinSet, Region, 0-0 W%ws_width% H27, A
  Sleep, 2000
  WinSet, Region, , A
  Sleep, 2000
  WinMaximize, A
  return 


Open a new window - anything'll do - and hit Win-k, then wait.

Thanks

Ant.
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Wed Mar 09, 2005 4:43 pm    Post subject: Reply with quote

Hi,
Trying it myself on WinXP Pro it seems to be fine, the last command, maximise has no problems (atlest, none I notice or expect).
_________________

Back to top
View user's profile Send private message Visit poster's website
antonyb



Joined: 26 May 2004
Posts: 61

PostPosted: Wed Mar 09, 2005 4:54 pm    Post subject: Reply with quote

Oh really?

How weird. Its absolutely repeatable here. Hmm. Will look into it further.

Thanks for trying, titan.

Ant.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Mar 09, 2005 5:08 pm    Post subject: Reply with quote

Well, I tried it on Notepad and it seems to work okay, but maybe I'm missing something. It's also quite possible that certain types of windows don't like their regions being changed. If you find out more, please post here so that the documentation can be updated with any known limitations.

By the way, your idea of rolling up windows to their title bars using "Region" is a great one. It probably has advantages over the WinMove method.
Back to top
View user's profile Send private message Send e-mail
antonyb



Joined: 26 May 2004
Posts: 61

PostPosted: Wed Mar 09, 2005 5:12 pm    Post subject: Reply with quote

Very strange. Happens to me with Notepad, Explorer, in fact everything.

Will keep investigating, but can't really imagine what it could be.

Yes - I prefer this to the WinMove method - I found that didn't work on some windows.

Ant.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Mar 09, 2005 5:15 pm    Post subject: Reply with quote

My understanding is that your window vanishes or that its region doesn't get properly restored by "WinSet, Region, , WinTitle". If this is correct, perhaps you could work around it with one of these:

WinSet, Redraw, , WinTitle
WinMove, WinTitle, , 0, 0 ; Move anywhere to try to force it to redraw.

Last resort:
WinHide, WinTitle
WinShow, WinTitle ; probably best to use ahk_id for WinTitle in both of these.
Back to top
View user's profile Send private message Send e-mail
antonyb



Joined: 26 May 2004
Posts: 61

PostPosted: Wed Mar 09, 2005 5:47 pm    Post subject: Reply with quote

Hi Chris,

Unfortunately neither of those work.

Thats not exactly the problem. If I have a window, size X,Y, and I call
Code:
  WinGetPos , , , ws_width, , ahk_id %winid%
  WinSet, Region, 0-0 W%ws_width% H27, ahk_id %winid%

on it, it "rolls up in to its titlebar", size X,27. If I then call
Code:
WinSet, Region, , ahk_id %winid%

the window reappears, size X,Y. If I then maximise that window (either by clicking on the maximise button or by calling WinMaximize from ahk), the window appears to maximise - i.e. moves to 0,0 and appears much wider and taller, but I can only see a section of that window, starting at 0,0, size X,Y.

If I call WinGetPos on the sort-of-maximised window it reports back 1600x1200. If I calling the first bit of code above it rolls up to a proper full length titlebar, and then will unroll properly with the second bit of code (i.e. I can now see the entire window).

Ant.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Thu Mar 10, 2005 1:19 am    Post subject: Reply with quote

Thanks for the details. As a workaround, you might try explicitly setting the region to be as large as it was originally, rather than relying on "WinSet, Region, , WinTitle" to restore it.

I'm don't yet understand all the side-effects and inner workings of regions, so if you or I find out more about how it works, I'll either document the limitations or try to improve the program.
Back to top
View user's profile Send private message Send e-mail
antonyb



Joined: 26 May 2004
Posts: 61

PostPosted: Fri Mar 11, 2005 10:23 am    Post subject: Reply with quote

Hi,
Quote:
As a workaround, you might try explicitly setting the region to be as large as it was originally, rather than relying on "WinSet, Region, , WinTitle" to restore it.

Makes no difference. However:
Code:
SysGet, sys_xres, 61
SysGet, sys_yres, 62
WinSet, Region, 0-0 W%sys_xres% H%sys_yres%, ahk_id %ws_id%

Seems to work fine.

The only odd effect I still get is, if I use WinSet to display only the titlebar of a window, as above, and while the window is in this state I click the "Maximize" button, I get a similar effect to the one I describe above.

Ant.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Fri Mar 11, 2005 12:05 pm    Post subject: Reply with quote

antonyb wrote:
The only odd effect I still get is, if I use WinSet to display only the titlebar of a window, as above, and while the window is in this state I click the "Maximize" button, I get a similar effect to the one I describe above.
Once a smaller-than-usual region is in effect, I think it's normal for the window to be a little traumatized and be unable to maximize and change its shape as it normally does.

Thanks for posting the partial workaround.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Fri Apr 29, 2005 1:19 pm    Post subject: Reply with quote

I don't know why I could reproduce it before, but I see the maximize-problem when using skrommel's script at http://www.autohotkey.com/forum/viewtopic.php?t=1870

This issue has hopefully been fixed in today's update. Thanks.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group