Windows 7의 정기 종료를 방지하고 싶습니다.이 AutoIt 스크립트가 강제 종료 대화 상자의 취소 버튼을 클릭하지 않았 음을 알았습니다.Windows 7은 종료를 막습니다
누군가 테스트하여 정확히 무엇이 잘못 되었습니까? 이것이 autoit
방지 기능을하는 방법이 사망하기처럼
$WM_QUERYENDSESSION = 0x11
GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown")
$Hwnd = GUICreate("PreventShutdownGUI")
;~ GUISetSTate(@SW_SHOW)
_ShutdownBlockReasonCreate($hwnd, "Sorry, AutoIt > Windows")
TrayTip("Shutdown Blocker - Started", "Denies shutdowns from now on.", 20)
While Sleep(100)
WEnd
_ShutdownBlockReasonDestroy($hwnd)
Func _ShutdownBlockReasonCreate($Hwnd, $wStr)
; http://msdn.microsoft.com/en-us/library/ms...28VS.85%29.aspx
; [email protected]
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 Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam)
; This HAS to be here to capture the endsession...
AdlibRegister("Cancel_ShutdownResolver",50)
Return False
EndFunc
Func Cancel_ShutdownResolver()
Local $iOpt = Opt("WinTitleMatchMode",4),$hwnd = WinGetHandle("[CLASS:BlockedShutdownResolver]")
Opt("WinTitleMatchMode",$iOpt)
If $hwnd Then
If @OSVersion = "WIN_7" Then ControlClick($hwnd,"","[CLASS:Button; INSTANCE:1]")
If @OSVersion <> "WIN_7" Then ControlClick($hwnd,"","[CLASS:Button; INSTANCE:2]")
AdlibUnRegister("Cancel_ShutdownResolver")
TrayTip("Shutdown Blocker - Shutdown denied", "Denied shutdown successfull!", 5)
_DeineFunktion() ; <================ Hier musst du deine Funktion einfügen
EndIf
EndFunc
Func _DeineFunktion()
MsgBox(0,"","Das hier ist deine Funktion ;) - Danach musst du erneut _ShutdownBlockReasonDestroy($hwnd) aufrufen, und einen neuen Shutdown machen.")
EndFunc
코드 *는 저를 위해 * 잘 작동합니다. Windows 7 영어. –