Jump to content
t_bear

(Solved) Not recieving WM_QUERYENDSESSION messages on WinXp

Recommended Posts

t_bear

I'm trying to prevent accidental logoff/shutdown/restart while an install is running, but cannot make this work on WinXp with Service Pack 3

Seems to me that autoit no longer recieves WM_QUERYENDSESSION messages for WinXp.

Tried the same code in Windows 7 (64bit with SP1), and there we get the QUERYENDSESSION message. (even though you have to do a bit more for win7 to block shutdown, but that's beside the point)

Is there any other way I can run GUIRegisterMsg to try getting those WM_QUERYENDSESSION messages?

Opt("TrayIconHide", 1)
$WM_QUERYENDSESSION = 0x11
GUICreate("PreventShutdownGUI")
GUISetSTate(@SW_HIDE)
GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown")
ConsoleWrite("wait forever" & @CRLF)
While 1
    sleep(100)
WEnd
exit 0
Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam)
    ConsoleWrite("Prevent shutdown" & @CRLF)
    Return False
EndFunc

Best regards

T_Bear

Edited by t_bear

Share this post


Link to post
Share on other sites
guinness

There's an example showing you how to correctly achieve this by Yashied, I found it easily.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
t_bear

I did search (for several days actually), And I've tried most of the scripts containing the GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown")

As pointed out by adom in this post:

the VM_QUERYENDSESSION is no longer recognized/recieved by autoit.

Seems to me that this is a bug,the VM_QUERYENDSESSION and VM_ENDSESSION, is not recieved by autoit in WinXp (with sp3), but is recieved in Windows 7 (64bit with sp1), using the exact same code.

Share this post


Link to post
Share on other sites
guinness

I can't possibly comment as I don't use XP anymore nor am I a developer of AutoIt.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
t_bear

Anyone else?

How to file this as an potential autoit bug?

Share this post


Link to post
Share on other sites
Manko

As pointed out by adom in this post:

Did you read through it? He succeded. (Just not under certain specific circumstances... he might, he has not reported back.)

Besides the tip below, read through his thread carefully and see if your problems actually match...

To your problem... Are you using this? _WinAPI_SetProcessShutdownParameters(0x03FF) (Don't forget includes.)

Might be your program is not receiving message since it is too late in queue?

I have XP-SP3 and it's working flawlessly... :oops:

(Tested my own code though... will test yours...)

/Manko

Edited by Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites
rover

This code by prog@ndy

works for me in XP Pro SP3

on versions 3.3.8.1 and beta 3.3.9.2


I see fascists...

Share this post


Link to post
Share on other sites
t_bear

Thanks!!!! it was the _WinAPI_SetProcessShutdownParameters(0x03FF) that did the trick!

As you said, without it, I'm just too late in queue.

But no... I'm not using the WinAPI UDF, I just implemented it from your code at

I also added code for windows 7 by adding : _ThreadExecutionState_Set and _ShutdownBlockReasonCreate

Full code here:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..Stockage.ico
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Comment=Shutdown blocker, test app comment
#AutoIt3Wrapper_Res_Description=Shutdown blocker, test app desc
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;http://www.autoitscript.com/forum/topic/133896-prevent-shutdownsleep-in-vista7/
;by /Manko, modified by T_Bear
AutoItSetOption("TrayAutoPause","0")
AutoItSetOption("MustDeclareVars", True)
AutoItSetOption("TrayIconHide", True)
AutoItSetOption("ExpandEnvStrings", True)
AutoItSetOption("TrayOnEventMode", True)
#include <Debug.au3>
Global Const $ES_AWAYMODE_REQUIRED=0x00000040
Global Const $ES_CONTINUOUS=0x80000000
Global Const $ES_DISPLAY_REQUIRED=0x00000002
Global Const $ES_SYSTEM_REQUIRED=0x00000001
Global Const $ES_USER_PRESENT=0x00000004
Global Const $PBT_APMSUSPEND = 0x0004
Global Const $WM_QUERYENDSESSION = 0x0011
Global Const $WM_ENDSESSION = 0x0016
Global Const $WM_POWERBROADCAST = 0x0218
Global $bQuit=False
HotKeySet("^x","quit")
HotKeySet("^X","quit")
Global $hGUI=GUICreate("BatchExecuter-Block-Shutdown+Restart+Logoff",1,1)
GUISetSTate(@SW_HIDE)
_DebugSetup("BatchExecuter-Block-Shutdown+Restart+Logoff",False,1)
_DebugOut ("@OSBuild: " & @OSBuild & @LF)
;_DebugOut ("@OSVersion_@OSArch: " & @OSVersion & "_" & @OSArch & @LF)
;Init/Setup
if @OSBuild <= 2600 Then ;Winxp or lower
Register_WM_QUERYENDSESSION()
Register_SetProcessShutdownParameters()
;Register_WM_ENDSESSION()
;Register_WM_POWERBROADCAST()
Else ;Vista or higher
Register_WM_QUERYENDSESSION()
Register_WM_ENDSESSION()
Register_WM_POWERBROADCAST()
Register_SetProcessShutdownParameters()
Register_ShutdownBlockReason()
Register_ThreadExecutionState()
EndIf
;@OSVersion "WIN_2008R2", "WIN_7", "WIN_8", "WIN_2008", "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_XPe", "WIN_2000".
;Wait loop... somehow after two logoff attempts.. it stops blocking shutdown...
_DebugOut("Waiting for Control+x to quit" & @LF)
While 1
if $bQuit = True then ExitLoop
Sleep(250)
WEnd
_DebugOut("Stopping Blocking shutdown, cleanup and exit." & @LF)
;Cleanup
if @OSBuild <= 2600 Then ;Winxp or lower
;Nothing to do
Else ;Vista or higher
DeRegister_ThreadExecutionState()
DeRegister_ShutdownBlockReason()
EndIf
;Sleep(3000)
exit 0

Func Register_WM_QUERYENDSESSION()
_DebugOut("Registrering for GUIMsg WM_QUERYENDSESSION." & @LF)
;For Xp, register for WM_QUERYENDSESSION, then abort the shutdown/logoff
If Not GUIRegisterMsg($WM_QUERYENDSESSION, "HANDLE_WM_QUERYENDSESSION") then ; enough for windows xp, but in Vista/7, we will add "Shutdownblockreason"...
  _DebugOut("Error registrering WM_QUERYENDSESSION" & @LF)
  Sleep(3000)
EndIf
EndFunc
Func Register_WM_ENDSESSION()
_DebugOut("Registrering for GUIMsg WM_ENDSESSION" & @LF)
;See if we can trap endsessions
If Not GUIRegisterMsg($WM_ENDSESSION, "HANDLE_WM_ENDSESSION") then ; enough for windows xp, but in Vista/7, we will add "Shutdownblockreason"...
  _DebugOut("Error registrering WM_ENDSESSION" & @LF)
  Sleep(3000)
EndIf
EndFunc
Func Register_WM_POWERBROADCAST()
_DebugOut("Registrering for GUIMsg WM_POWERBROADCAST" & @LF)
; ***************** In Vista/7 there is no longer a way to prevent Sleep/hibernate instigated by user action, cause of the risk of backpack-attack.... ********* ;
If Not GUIRegisterMsg($WM_POWERBROADCAST, "HANDLE_WM_POWERBROADCAST") THEN ; But we still have about 2secs to do some cleanup...
  _DebugOut("Error registrering WM_POWERBROADCAST" & @LF)
  Sleep(3000)
EndIf
EndFunc
Func Register_SetProcessShutdownParameters()
_DebugOut("Setting ProcessShutdownParameters" & @LF)
; We wanna be first in the queue when notifications come about shutdown/sleep...
If Not _SetProcessShutdownParameters(0xFFF) Then ; MSDN says maximum is 0x4FF, but it worked for me (Prog@ndy)
  _DebugOut("Error setting SetProgressShutdownParameters to 0xFFF (try1/4)" & @LF)
  Sleep(3000)
  If Not _SetProcessShutdownParameters(0x4FF) Then ; MSDN says this is reserved for System, but worked for me (Prog@ndy)
   _DebugOut("Error setting SetProgressShutdownParameters to 0x4FF (try2/4)" & @LF)
   Sleep(3000)
   If Not _SetProcessShutdownParameters(0x3FF) Then ; highest not reserved number, if everything else does not work
    _DebugOut("Error setting SetProgressShutdownParameters to 0x3FF (try 3/4)" & @LF)
    Sleep(3000)
    if Not _SetProcessShutdownParameters(0x300) Then ;
     _DebugOut("Error setting SetProgressShutdownParameters to 0x3FF (try 4/4), total falure, cannot control if apps are closed under windows vista/7." & @LF)
     Sleep(3000)
    EndIf
   EndIf
  EndIf
EndIf
EndFunc
Func Register_ShutdownBlockReason()
_DebugOut("Setting ShutdownBlockReason" & @LF)
; without this, computer will sometimes shutdown but sometimes be saved by the app_unresponsive screen after some or no apps close...
; The descriptive text should be short and to the point or users might ignore....
if not _ShutdownBlockReasonCreate($hGUI,"WARNING: Software job in progress. Do not shutdown, reboot or logoff your computer! Doing so may harm the computer.") Then
  _DebugOut("Error setting _ShutdownBlockReasonCreate" & @LF)
  Sleep(3000)
EndIf
EndFunc
Func Register_ThreadExecutionState()
_DebugOut("Setting TreadExecutionState" & @LF)
;To prevent sleep, telling the OS that we're running an app that cannot be interrupted
;The ES_AWAYMODE_REQUIRED value should be used only when absolutely necessary by media applications that require the system
;to perform background tasks such as recording television content or streaming media to other devices while the system appears to be sleeping
If Not _ThreadExecutionState_Set() Then
  _DebugOut("Error setting _ThreadExecutionState_Set" & @LF)
  Sleep(3000)
EndIf
EndFunc
Func DeRegister_ThreadExecutionState()
_DebugOut("Disabling ThreadExecutionState" & @LF)
if not _ThreadExecutionState_Disable() Then
  _DebugOut("Error setting _ThreadExecutionState_Disable" & @LF)
  Sleep(3000)
EndIf
EndFunc
Func DeRegister_ShutdownBlockReason()
_DebugOut("Disabling ShutdownBlockReason" & @LF)
if not _ShutdownBlockReasonDestroy($hGUI) Then
  _DebugOut("Error setting _ThreadExecutionState_Disable" & @LF)
  Sleep(3000)
EndIf
EndFunc

Func HANDLE_WM_QUERYENDSESSION($hWndGUI, $MsgID, $WParam, $LParam)
    ; DO NOT ADD A MSGBOX HERE
    ; Windows shows a not responding box after ~5 secs and allows to kill your app.
;
; http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx#CommunityContent'
; $LParam:
; ENDSESSION_CLOSEAPP
; 0x00000001 The application is using a file that must be replaced, the system is being serviced, or system resources are exhausted. For more information, see Guidelines for Applications.
;
; ENDSESSION_CRITICAL
; 0x40000000 The application is forced to shut down.
;
; ENDSESSION_LOGOFF
; 0x80000000 The user is logging off. For more information, see Logging Off.
_DebugOut("WM_QUERYENDSESSION, cancel session change: " & $LParam & @LF)
    Return False ; DO NOT SHUTDOWN
EndFunc

Func HANDLE_WM_ENDSESSION($hWndGUI, $MsgID, $WParam, $LParam)
    ; DO NOT ADD A MSGBOX HERE
    ; Windows shows a not responding box after ~5 secs and allows to kill your app.
;
; http://msdn.microsoft.com/en-us/library/aa376889(v=vs.85).aspx
; $LParam:
; ENDSESSION_CLOSEAPP
; 0x00000001 The application is using a file that must be replaced, the system is being serviced, or system resources are exhausted. For more information, see Guidelines for Applications.
;
; ENDSESSION_CRITICAL
; 0x40000000 The application is forced to shut down.
;
; ENDSESSION_LOGOFF
; 0x80000000 The user is logging off. For more information, see Logging Off.
_DebugOut("WM_ENDSESSION, system going down. " & $LParam & @LF)
    Return False ; DO NOT SHUTDOWN
EndFunc
Func HANDLE_WM_POWERBROADCAST($hwnd, $msg, $wparam, $lparam)
_DebugOut("WM_POWERBROADCAST recieved!" & @LF)
if $wparam=$PBT_APMSUSPEND then
  ; We have about 2 secs...
  ; Do some cleanup!
  ; ...or whatever
  _DebugOut("WM_POWERBROADCAST, Shutdown with powerbutton, do cleanup within 2 sec's, cause then you'll die!" & @LF)
EndIf
Return 1 ;Try to cancel the powerbroadcast.
EndFunc
Func _SetProcessShutdownParameters($dwLevel, $dwFlags=0)
    ; http://msdn.microsoft.com/en-us/library/ms686227%28VS.85%29.aspx
    ; Prog@ndy
    Local $aResult = DllCall("Kernel32.dll", "int", "SetProcessShutdownParameters", "dword", $dwLevel, "dword", $dwFlags)
    If @error Then Return SetError(1,0,0)
    Return $aResult[0]
EndFunc
Func _ShutdownBlockReasonCreate($Hwnd, $wStr)
Local $aResult = DllCall("User32.dll", "int", "ShutdownBlockReasonCreate", "hwnd", $Hwnd, "wstr", $wStr)
    If @error Then Return SetError(1,0,0)
    Return $aResult[0]
EndFunc
Func _ShutdownBlockReasonDestroy($Hwnd)
    Local $aResult = DllCall("User32.dll", "int", "ShutdownBlockReasonDestroy", "hwnd", $Hwnd)
    If @error Then Return SetError(1,0,0)
    Return $aResult[0]
EndFunc
Func _ThreadExecutionState_Set()
;The ES_AWAYMODE_REQUIRED value should be used only when absolutely necessary by media applications that require the system
;to perform background tasks such as recording television content or streaming media to other devices while the system appears to be sleeping
Local $aResult = DllCall("kernel32.dll", "int", "SetThreadExecutionState", "int", BitOR($ES_CONTINUOUS, $ES_SYSTEM_REQUIRED, $ES_AWAYMODE_REQUIRED)) ;$ES_AWAYMODE_REQUIRED
if @error Then Return SetError(1,0,0)
Return $aResult[0]
EndFunc
Func _ThreadExecutionState_Disable()
;// Clear EXECUTION_STATE flags to disable away mode and allow the system to idle to sleep normally.
Local $aResult = DllCall("kernel32.dll", "int", "SetThreadExecutionState", "int", $ES_CONTINUOUS)
if @error Then Return SetError(1,0,0)
Return $aResult[0]
EndFunc
Func quit()
$bQuit=True
EndFunc
Edited by t_bear

Share this post


Link to post
Share on other sites
t_bear

The really strange thing is,, without the _WinAPI_SetProcessShutdownParameters, the WM_QUERYENDSESSION is not recieved at all.

(I'm using another shutdownblocker at the same time so the session don't end. So I can see the result if the window message is recieved or not)

Share this post


Link to post
Share on other sites
Yashied

I'm using another shutdownblocker at the same time so the session don't end. So I can see the result if the window message is recieved or not.

You do not carefully read the MSDN.

The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero.

The WM_QUERYENDSESSION message just does not come to your script because your "shutdownblocker" receives it first and returns 0. After using the _WinAPI_SetProcessShutdownParameters() function, your script will have the highest priority to receive the WM_QUERYENDSESSION message, and if you return 0, your "shutdownblocker" did not receive this message.

Edited by Yashied

Share this post


Link to post
Share on other sites
t_bear

Well then, I guess I'm using a higher number in the SetProcessShutdownParameters than that other shutdownblocker, cause I'm getting those QUERYENDSESSION messages now :oops:

But you're right, I did not catch that I had to use SetProcessShutdownParameters in order to recieve those QUERYENDSESSION messages at all. I guess I was fooled by the other examples at the autoit forum that didn't contain it, where they claimed it to be working.

But.. it's working now, and I'll post the code when I'm done with it... If others find it useful.

Thank you very much for your help :bye:

Share this post


Link to post
Share on other sites
t_bear

This app made as a helper app for an installation app, to block shutdown while an installation is running. But can be used as a standalone solution (but it has no visible gui, besides the /debug window)

It consists of two scripts, one to block, and another to thell the blocking app to stop.

  • Input params for shutdownblocker:

    • shutdownblocker.exe "Title to be displayed" "Message to be displayed" [/debug]
  • Input params for shutdownblocker_close:

    • shutdownblocker_close.exe "title of shutdownblocker.exe" [/debug]
The code can be found below, tested on WinXp with sp3 and Windows 7 64bit, with sp1

Note:

  • For the close app to work, the scripts must be compiled. (window matching won't work if not compiled, thus the WM_CLOSE won't be recieved)
  • Will not work if compiled as an console app.
Thanks:

This code was based on an example by /manko at:

Thanks to /manko, Yashied and guinness for help

Also a lot of thanx to Nenad from softwareok.com, for a lot of help making the Win7 solution work

shutdownblocker.au3

shutdownblocker_close.au3

Share this post


Link to post
Share on other sites
t_bear

Can I change the title/topic to "(Solved)Not recieving WM_QUERYENDSESSION messages on WinXp" ?

I can't figure out how...

Share this post


Link to post
Share on other sites
guinness

Edit the first post and select Full Editor, then you can edit the Title.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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

×