Tomas Posted August 10, 2006 Posted August 10, 2006 Hi Everyone,I need to disable minimize, maximize and close buttons on a open window. I've found couple of posts discussing how to do it, but I'm not having much luck making it work.I've tried following with no luck at all:WinWait("Notepad")$calcHwnd = WinGetHandle("Notepad")Global Const $SC_CLOSE = 0xF060Global Const $SC_MINIMIZE = 0xF020Global Const $MF_GRAYED = 0x00000001$hMenu = DllCall('user32.dll', 'int', 'GetSystemMenu', 'hwnd', $calcHwnd, 'int', 0); This should gray out x button?!DllCall('user32.dll', 'int', 'EnableMenuItem', 'hwnd', $hMenu[0], 'int', $SC_CLOSE, 'int', $MF_GRAYED); This should gray out Minimize button?!DllCall('user32.dll', 'int', 'EnableMenuItem', 'hwnd', $hMenu[0], 'int', $SC_MINIMIZE, 'int', $MF_GRAYED)WHat am I doing wrong here?? I am using wrong function??I managed to get following code working, unfortunately it only removes context menu items. Buttons, except for X button, are still functional and visible.WinWait("Notepad")$calcHwnd = WinGetHandle("Notepad")Global Const $SC_CLOSE = 0xF060Global Const $SC_MINIMIZE = 0xF020Global Const $SC_MAXIMIZE = 0xF030Global Const $SC_RESTORE = 0xF120$menu = DllCall("user32.dll","hwnd","GetSystemMenu","hwnd", $calcHwnd, "int",0)DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_MINIMIZE, "int", 0x0)DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_MAXIMIZE, "int", 0x0)DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_CLOSE, "int", 0x0)DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", $SC_RESTORE, "int", 0x0)Any ideas?? I am desperate.ThanksTomas
Tomas Posted August 10, 2006 Author Posted August 10, 2006 It turns out that the script works on Windows 2003 server, but not on Win Xp.
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