JScript Posted June 20, 2010 Share Posted June 20, 2010 (edited) Hello,Would anyone know how to get the return value of the example below?;Private Declare Function SHShutDownDialog Lib "shell32" _ ;Alias "#60" (ByVal lType As Long) As Long ; Its only argument can be one of these constants: Global Const $EWX_LOGOFF = 0 Global Const $EWX_SHUTDOWN = 1 Global Const $EWX_REBOOT = 2 Global Const $EWX_FORCE = 4 Global Const $EWX_POWEROFF = 8 MsgBox(4096, "Teste", _SHShutDownDialog()) Func _SHShutDownDialog() $aRet = DllCall("shell32.dll", "int", 60, "long", $EWX_SHUTDOWN) If @error Then Return 0 Return $aRet[0] EndFunc ;==>SHShutDownDialogOnly returns "0" (if $EWX_LOGOFF)Only returns "1" (if $EWX_SHUTDOWN)Only returns "2" (if $EWX_REBOOT)Only returns "4" (if $EWX_FORCE)Only returns "8" (if $EWX_POWEROFF)How to get the result of the buttons were clicked?Finely, I solved!#include <SendMessage.au3> Global $cStartMenuWin = "[Class:DV2ControlHost]" Global $hCtrlShutHwnd = ControlGetHandle($cStartMenuWin, "", "[CLASS:ToolbarWindow32; INSTANCE:1]") Global $iLogoffCmdID = 0 Global $iShutdownCmdID = 1 While 1 Sleep(50) ; Intercepts "Shut Down Windows" If _IsShutDownDialog($iShutdownCmdID) Then MsgBox(4096, "Warning", "The window 'Shut Down Windows' was intercepted successfully!") ; Intercepts "Log Off Windows" If _IsShutDownDialog($iLogoffCmdID) Then MsgBox(4096, "Warning", "The window 'Log off Windows' was intercepted successfully!") WEnd ; Intercepts "Shut Down Windows" and "Log Off Windows" Func _IsShutDownDialog($iCommandID) If WinActive($cStartMenuWin) Then If _SendMessage($hCtrlShutHwnd, 0X400 + 11, $iCommandID) Then; If _GUICtrlToolbar_IsButtonPressed($hCtrlHwnd, $iCommandID) Then WinWaitActive("[Class:#32770]") If $iCommandID Then $aSHShutDlg_XY = WinGetPos("[Class:#32770]") WinKill("[Class:#32770]") WinWaitClose("[Class:#32770]") Return 1 EndIf EndIf Return 0 EndFunc ;==>_IsShutDownDialogIt works perfectly! In any language... Edited June 29, 2010 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 20, 2010 Share Posted June 20, 2010 Maybe something like this? <fairwarning>I haven't tested this..</fairwarning> ;Private Declare Function SHShutDownDialog Lib "shell32" _ ;Alias "#60" (ByVal lType As Long) As Long ; Its only argument can be one of these constants: Global Const $EWX_LOGOFF = 0 Global Const $EWX_SHUTDOWN = 1 Global Const $EWX_REBOOT = 2 Global Const $EWX_FORCE = 4 Global Const $EWX_POWEROFF = 8 Switch _SHShutDownDialog() Case 8 MsgBox(4096, "Teste", "Global Const $EWX_POWEROFF = 8") Case 4 MsgBox(4096, "Teste", "Global Const $EWX_FORCE = 4") Case 2 MsgBox(4096, "Teste", "Global Const $EWX_REBOOT = 2") Case 1 MsgBox(4096, "Teste", "Global Const $EWX_SHUTDOWN = 1") Case 0 MsgBox(4096, "Teste", "Global Const $EWX_LOGOFF = 0") EndSwitch Func _SHShutDownDialog() $aRet = DllCall("shell32.dll", "int", 60, "long", $EWX_SHUTDOWN) If @error Then Return 0 Return $aRet[0] EndFunc ;==>SHShutDownDialog - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
JScript Posted June 21, 2010 Author Share Posted June 21, 2010 @somdcomputerguy Simply not changed anything in return... http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
JScript Posted June 22, 2010 Author Share Posted June 22, 2010 (edited) I could not get the return of the dll, then how could capture (hook) the "shutdown" window shown below:The code snippet below works for Dialog Box:expandcollapse popup; MsgBoxHookEx Global $s_MSGBOX_STRUCT = DllStructCreate("long hWndOwner;long hHook") Global $h_MSGBOX_CALLBACK = DllCallbackRegister("__MsgBoxHook", "long", "long;long;long") Global $a_MSGBOXHOOK_WINSIZE Global $a_MSGBOXHOOK_CTRLPOS $aDllCall = DllCall("User32.dll", "int", "GetWindowLong", "hwnd", 0, "int", 0xFFFFFFFA) $hInstance = $aDllCall[0] $aDllCall = DllCall("Kernel32.dll", "int", "GetCurrentThreadId") $hThreadId = $aDllCall[0] $aDllCall = DllCall("User32.dll", "hwnd", "GetDesktopWindow") $hWndOwner = $aDllCall[0] DllStructSetData($s_MSGBOX_STRUCT, "hWndOwner", $hWndOwner) $aDllCall = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", 5, "ptr", DllCallbackGetPtr($h_MSGBOX_CALLBACK), "hwnd", $hInstance, "dword", $hThreadId) DllStructSetData($s_MSGBOX_STRUCT, "hHook", $aDllCall[0]) DllCall("user32.dll", "long", "MessageBox", "long", $hWndOwner, "str", "Teste", "str", "Hook", "long", 4096) MsgBox(4096, "Teste", $a_MSGBOXHOOK_WINSIZE[0] & @CRLF & $a_MSGBOXHOOK_WINSIZE[1] &@CRLF& $a_MSGBOXHOOK_CTRLPOS[0] &@CRLF& $a_MSGBOXHOOK_CTRLPOS[1]) Exit ; To get MsgBox dimensions... Func __MsgBoxHook($iMsgID, $WParam, $LParam) If $iMsgID = 5 Then DllCall("user32.dll", "long", "UnhookWindowsHookEx", "long", DllStructGetData($s_MSGBOX_STRUCT, "hHook")) Local $hwnd = HWnd($WParam) Local $WinGetSize = WinGetClientSize($hwnd) Local $CtrlGetPos = ControlGetPos($hwnd, "", "Static2") If @error Then $CtrlGetPos = ControlGetPos($hwnd, "", "Static1") If IsArray($WinGetSize) And IsArray($CtrlGetPos) Then $a_MSGBOXHOOK_WINSIZE = $WinGetSize $a_MSGBOXHOOK_CTRLPOS = $CtrlGetPos EndIf ControlClick($hwnd, "", "Button1") EndIf EndFunc ;==>__MsgBoxHookHow can I adapt it to "Shutdown" window?I would be very grateful if someone could help me... I'm still fairly limited in programming languages, I know nothing of C++...See the first post Edited June 29, 2010 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
JScript Posted June 29, 2010 Author Share Posted June 29, 2010 (edited) Solved, see the first post... Edited June 29, 2010 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
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