NassauSky Posted September 24, 2020 Posted September 24, 2020 The following code works great for notepad in Windows 10 but it doesn't seem to work with certain application like: Chrome Opera Calc (Windows new calculator) Probably more but didn't test too many apps $hWnd = WinGetHandle("Speed Dial - Opera") ConsoleWrite($hWnd & @CRLF) $iStyles = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) Anyone know of another way I can disable window resizing for specifically Chrome. Thanks.
seadoggie01 Posted September 24, 2020 Posted September 24, 2020 Did you check the return value of _WinAPI_SetWindowLong? It will return 0 if it fails, which might mean that these programs implement these buttons themselves All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
NassauSky Posted September 25, 2020 Author Posted September 25, 2020 (edited) Thanks @seadoggie01 it's not returning 0. Baffled. It's not like it's just 64 bit programs since Opera is a 32 bit program. Update: It actually half way works. It does keep me from resizing the windows but the Maximize and Minimize button is still there. Very strange. Edited September 25, 2020 by NassauSky
CYCho Posted September 25, 2020 Posted September 25, 2020 (edited) 6 hours ago, NassauSky said: _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) I don't know much about this, but the following seems to work with Chrome in Win10. _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitXOR($iStyles, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) Edit: I found that Chrome behaves weirdly after running this code: the links in the browser, including the favorites, are messed up. Edited September 25, 2020 by CYCho zPlayer - A Small Audio and Video Player
NassauSky Posted September 25, 2020 Author Posted September 25, 2020 (edited) @CYCho Maybe I have a type in my commands. Can you post the complete sample that seems to be (kind of) working for you for chrome? Edited September 25, 2020 by NassauSky
NassauSky Posted September 25, 2020 Author Posted September 25, 2020 (edited) OK Got it 🙂 I had to combine your code with my code @CYCho #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> $hWnd = WinGetHandle("New Tab - Google Chrome") ConsoleWrite($hWnd & @CRLF) $iStyles = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX)) _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitXOR($iStyles, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) I noticed that after I had placed your line after mine, that it kept toggling on and off the buttons. Only issue (which isn't important for me) is that with the code above is that it disables the X (close) on the window. The code above does the following: Disables resizing of the window Disables the Minimize Button (Doesn't disappear but it disables clicking it) Disables the Maximize/Restore button (Doesn't disappear but it disables clicking it) Edited September 25, 2020 by NassauSky
CYCho Posted September 25, 2020 Posted September 25, 2020 @NassauSky Did you try clicking any link in the browser after running the code? As I said above, all the links are messed up and I have no idea how this could happen. zPlayer - A Small Audio and Video Player
NassauSky Posted September 25, 2020 Author Posted September 25, 2020 (edited) @CYCho put that code alone in a separate file and try it (don't forget to open a new instance of chrome so it creates a new tab). Basically when you run it. It locks down the chrome browser resizing and window buttons. Everything else functions in the chrome browser (Links, textboxes, etc). An interesting thing about it though is when I run the code the second time with leaving the existing chrome window open, it still keeps the buttons locked but it returns the resizing of the window back to normal (meaning I can then resize the borders of the chrome window again) I actually wanted to try to get one more thing working. As I was playing with locking it down, I was able to blacken out the whole chrome windows from edge to edge. I wish I remember how I did that unless it was a windows fluke. If anyone knows how to make that magic happen, it would be great. Let me know if you find anything else out about the issue you describe @CYCho Edited September 25, 2020 by NassauSky
CYCho Posted September 25, 2020 Posted September 25, 2020 27 minutes ago, NassauSky said: Everything else functions in the chrome browser (Links, textboxes, etc). If I run the following code I repeatedly find that all the links are fouled up. When I click 'Browse' tab for example, a detailed 'Search the Community' window pops up. All my Favorites bring about different favorite pages. #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> Opt("WinTitleMatchMode", -1) ShellExecute("https://www.autoitscript.com/forum/") $hWnd = "" While $hWnd = "" $hWnd = WinGetHandle("Forums - AutoIt Forums") Sleep(10) WEnd $iStyles = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX)) _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitXOR($iStyles, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) 43 minutes ago, NassauSky said: when I run the code the second time with leaving the existing chrome window open, it still keeps the buttons locked but it returns the resizing of the window back to normal It seems that the following 2 lines act like a toggle, so if you run the code again, the resize function is disabled again. $iStyles = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX)) zPlayer - A Small Audio and Video Player
NassauSky Posted September 25, 2020 Author Posted September 25, 2020 Yep @CYCho it runs as a toggle which is great for me. I wanted to now somehow leave the X (close button) enabled but will have to keep testing.
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