Jump to content

Recommended Posts

Posted

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.

 

 

Posted

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 functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted (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 by NassauSky
Posted (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 by CYCho
Posted (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 by NassauSky
Posted (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 by NassauSky
Posted
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))


 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...