CountyIT Posted October 24, 2012 Share Posted October 24, 2012 (edited) I am at the point of burn out. I have a little notepad window I am trying to turn off the ability to minimize, maximize or resize. I am missing someting: $PriorityHandle = WinGetHandle("TestThree.txt - Notepad") WinActivate($PriorityHandle) $iStyle = _WinAPI_GetWindowLong($PriorityHandle, $GWL_STYLE) $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX) GUISetState($iStyle, $PriorityHandle) Can anyone clue me in Edited October 26, 2012 by CountyIT Link to comment Share on other sites More sharing options...
FireFox Posted October 24, 2012 Share Posted October 24, 2012 (edited) Hi, GUI* functions are used to manipulate GUIs created with your script, not external windows. #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> Global $hWnd, $iStyles $hWnd = WinGetHandle("[CLASS:Notepad]") $iStyles = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) Edit : Fixed code so the window is not "disabled" after setting the new styles, which is not far from yours : shame ! Br, FireFox. Edited October 24, 2012 by FireFox Link to comment Share on other sites More sharing options...
CountyIT Posted October 24, 2012 Author Share Posted October 24, 2012 Thanks FireFox! I see one obvious blunder on my part. Not using _WinAPI_SetWindowLong to set the style. Is that what you were refering to above in the "Edit : Fixed code so the window is not "disabled" after setting the new styles, which is not far from yours : shame !" or was that a comment to yourself? I have seen references to the comment you made "GUI* functions are used to manipulate GUIs created with your script, not external windows" many times. I am going to confess. The script I am writing does nothing but manipulate external windows. You think I am going to wind up in big trouble here? Link to comment Share on other sites More sharing options...
FireFox Posted October 24, 2012 Share Posted October 24, 2012 or was that a comment to yourself?No that was for you You think I am going to wind up in big trouble here?What do you mean?Br, FireFox. Link to comment Share on other sites More sharing options...
CountyIT Posted October 24, 2012 Author Share Posted October 24, 2012 I like to learn What was it that I did in the original script that would have disabled the WIndow? The GUISetState($iStyle, $PriorityHandle)? This script I am writing runs in the background and manipulates a major commercial package. The instance above is just one small example. You mentioned it and I have seen it mentioned before. That these AutoIt Window manipulation functions were designed to be used with AutoIt Scripts and not external Windows. I am using AutoIt strictly to manipulate external Windows. So far it has been working great but do you think it is just a matter of time until I crash and burn? Link to comment Share on other sites More sharing options...
FireFox Posted October 24, 2012 Share Posted October 24, 2012 What was it that I did in the original script that would have disabled the WIndow?No, it was in my code before the edit, I was setting "non complete styles" (something like this) that blocked the window.This script I am writing runs in the background and manipulates a major commercial package. The instance above is just one small example. You mentioned it and I have seen it mentioned before. That these AutoIt Window manipulation functions were designed to be used with AutoIt Scripts and not external Windows. I am using AutoIt strictly to manipulate external Windows. So far it has been working great but do you think it is just a matter of time until I crash and burn?It depends on the external applications you want to deal with; if their controls are easy to read then It's not a problem and autoit has been made at first for automating.You have still the forum and the great helpfile, you won't crash Br, FireFox. Link to comment Share on other sites More sharing options...
CountyIT Posted October 25, 2012 Author Share Posted October 25, 2012 Once again a million thanks! Link to comment Share on other sites More sharing options...
KaFu Posted October 25, 2012 Share Posted October 25, 2012 (edited) Keep this MSDN comment on SetWindowLong in mind.Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly. Edited October 25, 2012 by KaFu FireFox 1 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) Link to comment Share on other sites More sharing options...
CountyIT Posted October 26, 2012 Author Share Posted October 26, 2012 Thanks for the info KaFu. I knew I was missing something. I had to activate a different window then activate mine yet again for the change to take effect. Your way is much more elegant Link to comment Share on other sites More sharing options...
KaFu Posted October 26, 2012 Share Posted October 26, 2012 #include <Constants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $iPID = Run("notepad.exe") Global $hWnd, $iTimer = TimerInit() While Not IsHWnd($hWnd) $hWnd = WinGetHandle("[CLASS:Notepad]") Sleep(10) If TimerDiff($iTimer) > 5000 Then MsgBox(0, "", "Notepad Window not found in time...") Exit EndIf WEnd $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)) 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) Link to comment Share on other sites More sharing options...
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