Sign in to follow this  
Followers 0
GrahamT

Stopping MS Outlook from exiting

2 posts in this topic

This is part of a program I wrote to stop myself accidentally closing Outlook by clicking the Red "X". Worked fine, until I upgraded to Office 2007. I already made sure the path was to OFFICE12, but it still doesn't work.

I presume the dll calls have changed . . .

Opt("WinTitleMatchMode", 4)

Run("C:\Program Files\Microsoft Office\OFFICE12\outlook.exe")
WinWait("Outlook"); tried WinWaitActive also
$calcHwnd = WinGetHandle("classname=rctrl_renwnd32"); got classname by using 'AutoIt Window Info' utility

$menu = DllCall("user32.dll", "hwnd", "GetSystemMenu", "hwnd", $calcHwnd, "int", 0)
DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0], "int", 0xF060, "int", 0x0); SC_CLOSE

Any ideas what I need to change?

Thanks,

G

Share this post


Link to post
Share on other sites



I doubt you will find a fix for this. With the following code you can see it change the actual "System Menu", but the custom menu that is being used still remains.

Global Const $MF_BYCOMMAND = 0x0
Global Const $MF_GRAYED = 0x1
Global Const $SC_CLOSE = 0xF060

Opt("WinTitleMatchMode", 4)

$hWnd = WinGetHandle("classname=rctrl_renwnd32")
If @error Then
    ConsoleWrite("Error: Unable to get window handle." & @CR)
    Exit
EndIf
$hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", "hwnd", $hWnd, "int", 0)
If @error Then
    ConsoleWrite("Error: Unable to get system menu." & @CR)
    Exit
EndIf
$vResult = DllCall("user32.dll", "int", "EnableMenuItem", "hwnd", $hMenu[0], "int", $SC_CLOSE, "int", $MF_GRAYED)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0