autoit写的程序能监听到关机或登出时的消息吗
答案:1 悬赏:0 手机版
解决时间 2021-11-22 09:42
- 提问者网友:咪咪
- 2021-11-21 16:18
autoit写的程序能监听到关机或登出时的消息吗
最佳答案
- 五星知识达人网友:轻雾山林
- 2021-11-21 16:42
DllCall("Kernel32", "ubyte", "SetProcessShutdownParameters", "dword", 1024, "dword", 1) ;更改关机级别 0 - 1024 级别越高程序在系统关闭时越早关闭
#cs
BOOL WINAPI SetProcessShutdownParameters(
__in DWORD dwLevel,
__in DWORD dwFlags
);
#ce
GUIRegisterMsg(0x0011, "WindowProc")
GUIRegisterMsg(0x0016, "WindowProc")
#cs
#define WM_QUERYENDSESSION 0x0011
#define WM_ENDSESSION 0x0016
#ce
#cs
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
#ce
GUICreate("test")
$Edit = GUICtrlCreateEdit("", 50, 35, 300, 330)
GUISetSTate()
Do
Until GUIGetMsg() = -3
Func WindowProc($hWnd, $MsgID, $WParam, $LParam)
GUICtrlSetData($Edit,GUICtrlRead($Edit) & "Time: " & StringFormat("%2d:%2d:%2d",@HOUR,@MIN,@SEC) & @CRLF& "Msg: 0x" & Hex($MsgID) & @CRLF& "LParam: 0x" & Hex($LParam) & @CRLF)
Return False
EndFunc
#cs
BOOL WINAPI SetProcessShutdownParameters(
__in DWORD dwLevel,
__in DWORD dwFlags
);
#ce
GUIRegisterMsg(0x0011, "WindowProc")
GUIRegisterMsg(0x0016, "WindowProc")
#cs
#define WM_QUERYENDSESSION 0x0011
#define WM_ENDSESSION 0x0016
#ce
#cs
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
#ce
GUICreate("test")
$Edit = GUICtrlCreateEdit("", 50, 35, 300, 330)
GUISetSTate()
Do
Until GUIGetMsg() = -3
Func WindowProc($hWnd, $MsgID, $WParam, $LParam)
GUICtrlSetData($Edit,GUICtrlRead($Edit) & "Time: " & StringFormat("%2d:%2d:%2d",@HOUR,@MIN,@SEC) & @CRLF& "Msg: 0x" & Hex($MsgID) & @CRLF& "LParam: 0x" & Hex($LParam) & @CRLF)
Return False
EndFunc
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯