nf67 Posted March 27, 2010 Posted March 27, 2010 (edited) Hi there,I got stuck at this while trying to write some kind of window management tool,apparently WinSetState("[active]","",@SW_MAXIMIZE) doesn't work in some situations.After moving a window to a corner this line won't do anything. Could it be because moving a window messes up the "activeness" of that window (in which case [active] has no effect)? Minimize() always works fine however, despite its similar setup. I'm left clueless.Here's the entire script:expandcollapse popup#include <Misc.au3> ;=================VARIABLES============== $W = @DesktopWidth $H = @DesktopHeight $HW = @DesktopWidth / 2 $HH = @DesktopHeight / 2 ;======================================== ;=================HOTKEYS================ ;CORNERS HotKeySet("{NUMPAD7}", "TopLeft") HotKeySet("{NUMPAD9}", "TopRight") HotKeySet("{NUMPAD1}", "BottomLeft") HotKeySet("{NUMPAD3}", "BottomRight") ;TOP & BOTTOM HotKeySet("{NUMPAD8}", "Top") HotKeySet("{NUMPAD2}", "Bottom") ;LEFT & RIGHT HotKeySet("{NUMPAD4}", "Left") HotKeySet("{NUMPAD6}", "Right") ;FULL & MINIMIZE HotKeySet("{NUMPAD5}", "Full") HotKeySet("{NUMPAD0}", "Minimize") ;======================================== While 1 WEnd ;=================FUNCTIONS============== ;CORNERS (No resize if L-Ctrl is down) Func TopLeft() If _IsPressed("11")=1 Then MsgBox(0,"","") WinMove("[active]","",0,0) Else WinMove("[active]","",0,0,$HW,$HH) EndIf Redraw() ;Does nothing it seems, see Redraw() function below. EndFunc Func TopRight() If _IsPressed("11")=1 Then $Size = WinGetClientSize("[active]") WinMove("[active]","",$W-$Size[0],0) Else WinMove("[active]","",$HW,0,$HW,$HH) EndIf Redraw() ;Does nothing it seems, see Redraw() function below. EndFunc Func BottomLeft() If _IsPressed("11")=1 Then $Size = WinGetClientSize("[active]") WinMove("[active]","",0,$H-$Size[1]) Else WinMove("[active]","",0,$HH,$HW,$HH) EndIf Redraw() ;Does nothing it seems, see Redraw() function below. EndFunc Func BottomRight() If _IsPressed("11")=1 Then $Size = WinGetClientSize("[active]") WinMove("[active]","",$W-$Size[0],$H-$Size[1]) Else WinMove("[active]","",$HW,$HH,$HW,$HH) EndIf Redraw() ;Does nothing it seems, see Redraw() function below. EndFunc ;TOP & BOTTOM Func Top() WinMove("[active]","",0,0,$W,$HH) EndFunc Func Bottom() WinMove("[active]","",0,$HH,$W,$HH) EndFunc ;LEFT & RIGHT Func Left() WinMove("[active]","",0,0,$HW,$H) EndFunc Func Right() WinMove("[active]","",$HW,0,$HW,$H) EndFunc ;FULL & MINIMIZE Func Full() WinSetState("[active]","",@SW_MAXIMIZE) EndFunc Func Minimize() WinSetState("[active]","", @SW_MINIMIZE) EndFunc ;======================================== ;===============REDRAW=================== Func Redraw() $Handle = WinGetHandle("[active]") DllCall("user32.dll", "long", "SendMessage", "hwnd", $Handle, "int", 0x111, "int", 28931, "int", 0) EndFunc ;========================================P.S: To prevent the shadow from messing up, I took the redraw from here, didn't fix it unfortunately.Any suggestions? Edited March 27, 2010 by nf67
JohnOne Posted March 27, 2010 Posted March 27, 2010 I've no idea why @SW_MAXIMIZE dosent work, but a dirty alternative could be WinMove() which you use in your code for other things. WinMove("[active]",0,0,@Desktopwidth,@Desktoheight) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
nf67 Posted March 27, 2010 Author Posted March 27, 2010 (edited) Yeah I had already done so in a previous attempt, but was annoyed by the space wasted with window borders if you compare them side by side, @SW_MAXIMIZE gives you a much better full screen view... if it works, that is. Edited March 27, 2010 by nf67
JohnOne Posted March 27, 2010 Posted March 27, 2010 Is it not working because its moved off screen or something ? How about a quick move of it before maximize. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
KaFu Posted March 27, 2010 Posted March 27, 2010 As a workaround put a WinSetState("[active]","",@SW_RESTORE) directly before the WinSetState("[active]","",@SW_MAXIMIZE) ... And I'm still trying to figure out how to redraw the shadows after a move operation OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
nf67 Posted March 27, 2010 Author Posted March 27, 2010 Ah nice KaFu, I didn't know about @SW_RESTORE, I could also very well use this in another part of my script :-). It is indeed just a workaround but atleast it actually works
nf67 Posted March 28, 2010 Author Posted March 28, 2010 Could anyone shed some more light on this issue? Is it a bug perhaps?
Ascend4nt Posted March 29, 2010 Posted March 29, 2010 I think the 'bug' you refer to is when you resize an already-maximized window. The window will still consider itself maximized, and in fact comes up as maximized when tested. You have to 'unmaximize' it first before moving it. @SW_RESTORE is easiest My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
nf67 Posted March 29, 2010 Author Posted March 29, 2010 So you mean that the window considers itself resized even though it's not? Perhaps there's some kind of "refresh window state" or something :-/ ? Thank you for your help.
Ascend4nt Posted March 29, 2010 Posted March 29, 2010 (edited) Just change your 'Full' function to this:Func Full() WinMove("[active]","",0,0,$W,$H) EndFuncYou might want to grab the 'active' window position before making modifications so that a 'restore' is possible.. though once you minimize the window the 'active' window no longer is the same one.By the way, a 'Sleep' in the While loop would be a good idea.*Edit: Oops, just noticed someone suggested the same thing. If you don't like the borders being visible, you can get the border size, set the Window to a negative start 0-$iBorderSize and a larger-than screen width ($W+$iBorderSize). Of course, if your script exits, it'll be difficult for a user to grab onto the 'corners' for a resize unless you do it through the System menu functions.Also, to help you with that - Use GetSystemMetricsto get sizes of Windows elements Edited March 29, 2010 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
nf67 Posted March 30, 2010 Author Posted March 30, 2010 Thanks, I'll look into it... still wondering why it doesn't work, but I guess I'll have to accept that.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now