KaFu Posted January 28, 2010 Share Posted January 28, 2010 Can you run this real quick and post your output?I get exactly the same results. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
wraithdu Posted January 28, 2010 Share Posted January 28, 2010 (edited) Well, then I have no idea why things look different on our systems... grr. Edited January 28, 2010 by wraithdu Link to comment Share on other sites More sharing options...
KaFu Posted January 29, 2010 Share Posted January 29, 2010 Still tinkering on it... latest version added below ... @wraithdu: Hmmm, still trying to figure out the borders. In your example above you use $a_WinGetPosEx[2] -= (2*_WinAPI_GetSystemMetrics(33)) ; width of vertical frames If BitAND(_WinAPI_GetWindowLong($hwnd_calc, $GWL_STYLE), $WS_CAPTION) Then ; height of horizontal frames + height of caption $a_WinGetPosEx[3] -= ((2*_WinAPI_GetSystemMetrics(32)) + _WinAPI_GetSystemMetrics(4)) Else $a_WinGetPosEx[3] -= (2*_WinAPI_GetSystemMetrics(32)) Endif which results in a little blur on my computer, but if I exchange 32 with 7 and 33 with 8 it looks good! ; subtract the frame sizes $a_WinGetPosEx[2] -= (2*_WinAPI_GetSystemMetrics(8)) ; width of vertical frames If BitAND(_WinAPI_GetWindowLong($hwnd_calc, $GWL_STYLE), $WS_CAPTION) Then ; height of horizontal frames + height of caption $a_WinGetPosEx[3] -= ((2*_WinAPI_GetSystemMetrics(7)) + _WinAPI_GetSystemMetrics(4)) Else $a_WinGetPosEx[3] -= (2*_WinAPI_GetSystemMetrics(7)) Endif Strange, maybe has something to do with the windows theme? What does following code return for you? expandcollapse popupIf @OSVersion = "WIN_7" Then $Class_Calc = "[CLASS:CalcFrame]" ElseIf @OSVersion = "WIN_VISTA" Then $Class_Calc = "[CLASS:SciCalc]" Else MsgBox(16, "Error", "Vista or Win7 needed to run example.") Exit EndIf $iPID = Run("calc.exe") If WinWait($Class_Calc, "", 3) = 0 Then MsgBox(16, "Error", "Window not found.") Exit EndIf $hwnd_Source = WinGetHandle($Class_Calc) While not BitAND(WinGetState($hwnd_Source,""),2) sleep(10) wend $a_WinGetPos = WinGetPos($hwnd_Source) $a_WinGetClientSize = WinGetClientSize($hwnd_Source) $a_WinGetPosEx = _WinGetPosEx($hwnd_Source) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ProcessClose($iPID) Exit EndIf $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) ConsoleWrite("WinGetPos: " & $a_WinGetPos[0] & @tab & $a_WinGetPos[1] & @tab & $a_WinGetPos[2] & @tab & $a_WinGetPos[3] & @crlf) ConsoleWrite("WinGetClientSize: " & $a_WinGetClientSize[0] & @tab & $a_WinGetClientSize[1] & @crlf) ConsoleWrite("_WinGetPosEx: " & $a_WinGetPosEx[0] & @tab & $a_WinGetPosEx[1] & @tab & $a_WinGetPosEx[2] & @tab & $a_WinGetPosEx[3] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Window: " & $a_GetWindowInfo[1][1] & @tab & $a_GetWindowInfo[2][1] & @tab & $a_GetWindowInfo[3][1] & @tab & $a_GetWindowInfo[4][1] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Window-Width: " & $a_GetWindowInfo[3][1]-$a_GetWindowInfo[1][1] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Window-Heigth: " & $a_GetWindowInfo[4][1]-$a_GetWindowInfo[2][1] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Client: " & $a_GetWindowInfo[5][1] & @tab & $a_GetWindowInfo[6][1] & @tab & $a_GetWindowInfo[7][1] & @tab & $a_GetWindowInfo[8][1] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Client-Width: " & $a_GetWindowInfo[7][1]-$a_GetWindowInfo[5][1] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Client-Heigth: " & $a_GetWindowInfo[8][1]-$a_GetWindowInfo[6][1] & @crlf) ConsoleWrite("_WinAPI_Ex_GetWindowInfo - Borders: " & $a_GetWindowInfo[12][1] & @tab & $a_GetWindowInfo[13][1] & @crlf) ProcessClose($iPID) Func _WinAPI_Ex_GetWindowInfo($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) ; http://msdn.microsoft.com/en-us/library/ms632610(VS.85).aspx $tWINDOWINFO = DllStructCreate("dword cbSize;int rcWindow_Left;int rcWindow_Top;int rcWindow_Right;int rcWindow_Bottom;int rcClient_Left;int rcClient_Top;int rcClient_Right;int rcClient_Bottom;dword dwStyle;dword dwExStyle;dword dwWindowStatus;uint cxWindowBorders;uint cyWindowBorders;byte atomWindowType;byte wCreatorVersion;") DllStructSetData($tWINDOWINFO, 1, DllStructGetSize($tWINDOWINFO)) ; http://msdn.microsoft.com/en-us/library/ms633516(VS.85).aspx $aRet = DllCall("user32.dll", "hwnd", "GetWindowInfo", "hwnd", HWnd($hwnd), "ptr", DllStructGetPtr($tWINDOWINFO)) If $aRet[0] <> 1 Then Return SetError(2, 0, 0) Local $aRes[16][2] $aRes[0][0] = "cbSize" $aRes[1][0] = "rcWindow_Left" $aRes[2][0] = "rcWindow_Top" $aRes[3][0] = "rcWindow_Right" $aRes[4][0] = "rcWindow_Bottom" $aRes[5][0] = "rcClient_Left" $aRes[6][0] = "rcClient_Top" $aRes[7][0] = "rcClient_Right" $aRes[8][0] = "rcClient_Bottom" $aRes[9][0] = "dwStyle" $aRes[10][0] = "dwExStyle" $aRes[11][0] = "dwWindowStatus" $aRes[12][0] = "cxWindowBorders" $aRes[13][0] = "cyWindowBorders" $aRes[14][0] = "atomWindowType" $aRes[15][0] = "wCreatorVersion" For $i = 1 To 16 $aRes[$i - 1][1] = DllStructGetData($tWINDOWINFO, $i) Next Return $aRes EndFunc ;==>_WinAPI_Ex_GetWindowInfo ; #FUNCTION# ======================================================= ; Name...........: _WinGetPosEx ; Description ...: Retrieves Window size and position similar to WinGetPos() but regards possible Aero effects on Vista and Win7 ; Syntax.........: _WinGetPosEx($hWnd) ; Parameters ....: $hWnd - Handle to Window to measure ; Return values .: Success: Returns a 4-element array containing the following information: ; $array[0] = X position ; $array[1] = Y position ; $array[2] = Width ; $array[3] = Height ; Sets @extended = 0 for Aero effect is OFF for $hWnd ; = 1 for Aero effect is ON for $hWnd ; ; Failure: Returns 0 and sets @error to 1 if windows is not found. ; Author ........: KaFu ; Link ..........; http://msdn.microsoft.com/en-us/library/aa969515%28VS.85%29.aspx ; Example .......; Yes ; ================================================================== Func _WinGetPosEx($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) Local $aPos[4], $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom") Local Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 DllCall("dwmapi.dll", "hwnd", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hwnd), "dword", $DWMWA_EXTENDED_FRAME_BOUNDS, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error Then Return SetError(0, 0, WinGetPos($hwnd)) Local $iRectLeft = DllStructGetData($tRect, "Left") Local $iRectTop = DllStructGetData($tRect, "Top") Local $iRectRight = DllStructGetData($tRect, "Right") Local $iRectBottom = DllStructGetData($tRect, "Bottom") If Abs($iRectLeft) + Abs($iRectTop) + Abs($iRectRight) + Abs($iRectBottom) > 0 Then $aPos[0] = $iRectLeft $aPos[1] = $iRectTop $aPos[2] = $iRectRight - $iRectLeft $aPos[3] = $iRectBottom - $iRectTop Return SetError(0, 1, $aPos) EndIf Return SetError(0, 0, WinGetPos($hwnd)) EndFunc ;==>_WinGetPosEx My results are: WinGetPos: 792 248 218 312 WinGetClientSize: 212 264 _WinGetPosEx: 792 248 218 312 _WinAPI_Ex_GetWindowInfo - Window: 792 248 1010 560 _WinAPI_Ex_GetWindowInfo - Window-Width: 218 _WinAPI_Ex_GetWindowInfo - Window-Heigth: 312 _WinAPI_Ex_GetWindowInfo - Client: 795 293 1007 557 _WinAPI_Ex_GetWindowInfo - Client-Width: 212 _WinAPI_Ex_GetWindowInfo - Client-Heigth: 264 _WinAPI_Ex_GetWindowInfo - Borders: 3 3 Plus my latest version: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Misc.au3> #include <Constants.au3> #include <array.au3> Global $hwnd_Thumbnail, $hThumbID, $iPID Global $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Width_Save Global $i_hwnd_Thumbnail_Height, $i_hwnd_Thumbnail_Height_Save Global $iClientAreaOnly = 0 ; set to 1 to paint only client area Global $aWinGetPos Global $GetSystemMetrics_4 = _WinAPI_GetSystemMetrics(4) Global Const $DWM_TNP_RECTDESTINATION = 0x00000001 Global Const $DWM_TNP_RECTSOURCE = 0x00000002 Global Const $DWM_TNP_OPACITY = 0x00000004 Global Const $DWM_TNP_VISIBLE = 0x00000008 Global Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 If @OSVersion = "WIN_7" Then $Class_Calc = "[CLASS:CalcFrame]" ElseIf @OSVersion = "WIN_VISTA" Then $Class_Calc = "[CLASS:SciCalc]" Else MsgBox(16, "Error", "Vista or Win7 needed to run example.") Exit EndIf Opt("GUIOnEventMode", 1) ;Opt("WinWaitDelay", 10) $tTimer_Doubleclick = 0 $hM_Hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr(DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")), _WinAPI_GetModuleHandle(0)) HotKeySet("{ESC}", "_exit") ;$Class_Calc = "[CLASS:MozillaUIWindowClass]" ;$Class_Calc = "[CLASS:SciTEWindow]" $iPID = Run("calc.exe") If WinWait($Class_Calc, "", 3) = 0 Then MsgBox(16, "Error", "Window not found.") _exit() EndIf $hwnd_Source = WinGetHandle($Class_Calc) If $iPID = 0 Then $iPID = WinGetProcess($hwnd_Source) Global $iZoomFactor_Large = 1 ; to set "large" thumbnail size to width = source width ;$iZoomFactor_Large = 300 / $i_hwnd_Thumbnail_Width ; to set "large" thumbnail size to width = 300 Global $iZoomFactor_Small = 100 ; to set "small" thumbnail size to width = 100 $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ProcessClose($iPID) Exit EndIf $i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] $i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) If UBound($a_GetWindowInfo) <> 16 Then MsgBox(16, "Error", "_WinAPI_Ex_GetWindowInfo() did not return result.") ProcessClose($iPID) Exit EndIf $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf While Not BitAND(WinGetState($hwnd_Source, ""), 2) Sleep(10) WEnd $hwnd_Thumbnail = GUICreate("Vista Thumbnail", 100, 100, 100, 100, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_WindowDrag") $hThumbID = _DWM_Thumbnail_Register($hwnd_Thumbnail, $hwnd_Source) If @error Then MsgBox(16, "Error", "Registration of Thumbnail failed.") _exit() EndIf ;_check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True AdlibRegister("_check_GUI") Sleep(500) ; works for me, otherwise the inital thumb is resized / flickering a bit GUISetState() While Sleep(250) If Not ProcessExists($iPID) Then ExitLoop WEnd _exit() Func _exit() If IsHWnd($hwnd_Thumbnail) Then WinSetState($hwnd_Thumbnail, "", @SW_HIDE) _DWM_Thumbnail_Unregister($hThumbID) ProcessClose($iPID) _WinAPI_UnhookWindowsHookEx($hM_Hook) Exit EndFunc ;==>_exit Func _check_GUI() If Not IsHWnd($hwnd_Thumbnail) Or Not IsHWnd($hwnd_Source) Then Return If _WindowFromPoint() <> $hwnd_Thumbnail Then If $Big Then _check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $i_hwnd_Thumbnail_Height To $iZoomFactor_Small Step -$iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = False ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf Else If Not $Big Then _check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $iZoomFactor_Small To $i_hwnd_Thumbnail_Height Step $iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf EndIf EndFunc ;==>_check_GUI Func _check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) $i_hwnd_Source_State = WinGetState($hwnd_Source, "") If BitAND($i_hwnd_Source_State, 2) And Not BitAND($i_hwnd_Source_State, 16) Then ; Update only if source is visible and not minimized $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) $i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] $i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] if $iClientAreaOnly = 1 then $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf EndIf $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width * $iZoomFactor_Large $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height * $iZoomFactor_Large EndIf EndFunc ;==>_check_GUI_Pos Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $aRet = DllCall("User32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint Func _WindowDrag() DllCall("user32.dll", "int", "SendMessage", "hWnd", $hwnd_Thumbnail, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>_WindowDrag Func _DWM_Thumbnail_Register($hwnd, $hWndOw) $aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", 0) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Register thumbnail failed Return $aRet[3] EndFunc ;==>_DWM_Thumbnail_Register Func _DWM_Thumbnail_Unregister($hThumbID) $aRet = DllCall("dwmapi.dll", "int", "DwmUnregisterThumbnail", "hwnd", $hThumbID) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Unregister thumbnail failed Return $aRet[0] EndFunc ;==>_DWM_Thumbnail_Unregister Func _DWM_Thumbnail_Update_Properties($hThumbID, $rcDest_X, $rcDest_Y, $rcDest_Width, $rcDest_Height, $rcOpacity = 255, $rcReadOnly = True, $rcClientAreaOnly = 0) $tDWM_THUMBNAIL_PROPERTIES = DllStructCreate("dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;int fVisible;int fSourceClientAreaOnly") DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "dwFlags", BitOR($DWM_TNP_RECTDESTINATION, $DWM_TNP_OPACITY, $DWM_TNP_VISIBLE, $DWM_TNP_SOURCECLIENTAREAONLY)) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_X, 1) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Y, 2) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Width, 3) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Height, 4) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "opacity", $rcOpacity) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fVisible", $rcReadOnly) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fSourceClientAreaOnly", $rcClientAreaOnly) $pDWM_THUMBNAIL_PROPERTIES = DllStructGetPtr($tDWM_THUMBNAIL_PROPERTIES) $aRet = DllCall("dwmapi.dll", "int", "DwmUpdateThumbnailProperties", "ptr", $hThumbID, "ptr", $pDWM_THUMBNAIL_PROPERTIES) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Update thumbnail failed EndFunc ;==>_DWM_Thumbnail_Update_Properties Func _WinAPI_Ex_GetWindowInfo($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) ; http://msdn.microsoft.com/en-us/library/ms632610(VS.85).aspx $tWINDOWINFO = DllStructCreate("dword cbSize;int rcWindow_Left;int rcWindow_Top;int rcWindow_Right;int rcWindow_Bottom;int rcClient_Left;int rcClient_Top;int rcClient_Right;int rcClient_Bottom;dword dwStyle;dword dwExStyle;dword dwWindowStatus;uint cxWindowBorders;uint cyWindowBorders;byte atomWindowType;byte wCreatorVersion;") DllStructSetData($tWINDOWINFO, 1, DllStructGetSize($tWINDOWINFO)) ; http://msdn.microsoft.com/en-us/library/ms633516(VS.85).aspx $aRet = DllCall("user32.dll", "hwnd", "GetWindowInfo", "hwnd", HWnd($hwnd), "ptr", DllStructGetPtr($tWINDOWINFO)) If $aRet[0] <> 1 Then Return SetError(2, 0, 0) Local $aRes[16][2] $aRes[0][0] = "cbSize" $aRes[1][0] = "rcWindow_Left" $aRes[2][0] = "rcWindow_Top" $aRes[3][0] = "rcWindow_Right" $aRes[4][0] = "rcWindow_Bottom" $aRes[5][0] = "rcClient_Left" $aRes[6][0] = "rcClient_Top" $aRes[7][0] = "rcClient_Right" $aRes[8][0] = "rcClient_Bottom" $aRes[9][0] = "dwStyle" $aRes[10][0] = "dwExStyle" $aRes[11][0] = "dwWindowStatus" $aRes[12][0] = "cxWindowBorders" $aRes[13][0] = "cyWindowBorders" $aRes[14][0] = "atomWindowType" $aRes[15][0] = "wCreatorVersion" For $i = 1 To 16 $aRes[$i - 1][1] = DllStructGetData($tWINDOWINFO, $i) Next Return $aRes EndFunc ;==>_WinAPI_Ex_GetWindowInfo Func _Mouse_Proc($nCode, $wParam, $lParam) ;$mouseData = DllStructGetData(DllStructCreate("int X;int Y" & ";dword mouseData", $lParam), 3) ;If $wParam = 0x020A Then $mouseEvent = BitShift($mouseData, 16) ; ConsoleWrite($nCode & @tab & $wParam & @tab & $lParam & @CRLF) If $wParam = 0x00000201 Then If TimerDiff($tTimer_Doubleclick) < 500 Then WinSetState($hwnd_Source, "", @SW_RESTORE) WinSetOnTop($hwnd_Source, "", 1) WinSetOnTop($hwnd_Source, "", 0) EndIf If _WindowFromPoint() = $hwnd_Thumbnail Then $tTimer_Doubleclick = TimerInit() EndIf EndFunc ;==>_Mouse_Proc ; #FUNCTION# ======================================================= ; Name...........: _WinGetPosEx ; Description ...: Retrieves Window size and position similar to WinGetPos() but regards possible Aero effects on Vista and Win7 ; Syntax.........: _WinGetPosEx($hWnd) ; Parameters ....: $hWnd - Handle to Window to measure ; Return values .: Success: Returns a 4-element array containing the following information: ; $array[0] = X position ; $array[1] = Y position ; $array[2] = Width ; $array[3] = Height ; Sets @extended = 0 for Aero effect is OFF for $hWnd ; = 1 for Aero effect is ON for $hWnd ; ; Failure: Returns 0 and sets @error to 1 if windows is not found. ; Author ........: KaFu ; Link ..........; http://msdn.microsoft.com/en-us/library/aa969515%28VS.85%29.aspx ; Example .......; Yes ; ================================================================== Func _WinGetPosEx($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) Local $aPos[4], $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom") Local Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 DllCall("dwmapi.dll", "hwnd", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hwnd), "dword", $DWMWA_EXTENDED_FRAME_BOUNDS, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error Then Return SetError(0, 0, WinGetPos($hwnd)) Local $iRectLeft = DllStructGetData($tRect, "Left") Local $iRectTop = DllStructGetData($tRect, "Top") Local $iRectRight = DllStructGetData($tRect, "Right") Local $iRectBottom = DllStructGetData($tRect, "Bottom") If Abs($iRectLeft) + Abs($iRectTop) + Abs($iRectRight) + Abs($iRectBottom) > 0 Then $aPos[0] = $iRectLeft $aPos[1] = $iRectTop $aPos[2] = $iRectRight - $iRectLeft $aPos[3] = $iRectBottom - $iRectTop Return SetError(0, 1, $aPos) EndIf Return SetError(0, 0, WinGetPos($hwnd)) EndFunc ;==>_WinGetPosEx OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
wraithdu Posted January 29, 2010 Share Posted January 29, 2010 (edited) My results with calc in scientific mode:WinGetPos: 117 162 423 322WinGetClientSize: 407 264_WinGetPosEx: 117 162 423 322_WinAPI_Ex_GetWindowInfo - Window: 117 162 540 484_WinAPI_Ex_GetWindowInfo - Window-Width: 423_WinAPI_Ex_GetWindowInfo - Window-Heigth: 322_WinAPI_Ex_GetWindowInfo - Client: 125 212 532 476_WinAPI_Ex_GetWindowInfo - Client-Width: 407_WinAPI_Ex_GetWindowInfo - Client-Heigth: 264_WinAPI_Ex_GetWindowInfo - Borders: 3 3This is on my Win7 x64 desktop. I'll try to test my laptop later, tomorrow at the worst. Edited January 29, 2010 by wraithdu Link to comment Share on other sites More sharing options...
KaFu Posted January 29, 2010 Share Posted January 29, 2010 (edited) Switched to scientific mode too.WinGetPos: 655 403 413 312WinGetClientSize: 407 264_WinGetPosEx: 655 403 413 312_WinAPI_Ex_GetWindowInfo - Window: 655 403 1068 715_WinAPI_Ex_GetWindowInfo - Window-Width: 413_WinAPI_Ex_GetWindowInfo - Window-Heigth: 312_WinAPI_Ex_GetWindowInfo - Client: 658 448 1065 712_WinAPI_Ex_GetWindowInfo - Client-Width: 407_WinAPI_Ex_GetWindowInfo - Client-Heigth: 264_WinAPI_Ex_GetWindowInfo - Borders: 3 3 KaFu wraithduWindow - Heigth 312 322Window - Width 413 423Client - Heigth 264 264Client - Width 407 407Now that's odd ... the windows-borders seem to be 5px per side wider on your computer then on mine. That's also why _WinAPI_GetSystemMetrics(7) = 3px works for me and _WinAPI_GetSystemMetrics(32) = 8px works for you!http://msdn.microsoft.com/en-us/library/ms724385%28VS.85%29.aspx_WinAPI_GetSystemMetrics(7)"The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels."_WinAPI_GetSystemMetrics(32)"The thickness of the sizing border around the perimeter of a window that can be resized, in pixels."Okay, seems like the calc window does have a slightly different style on your computer... we have to add a switch to the calc method depending on the style responsible for this... which one is it ? AU3Info returns following styles for my calc.exeStyle: 0x14CA0000ExStyle: 0x00000100 Edited January 29, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
KaFu Posted January 29, 2010 Share Posted January 29, 2010 (edited) One more idea... before creating another work-around , let's try DwmQueryThumbnailSourceSize. Here's an example I threw together (still quiet dirty), please test if it works. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Misc.au3> #include <Constants.au3> #include <array.au3> Global $hwnd_Thumbnail, $hThumbID, $iPID Global $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Width_Save Global $i_hwnd_Thumbnail_Height, $i_hwnd_Thumbnail_Height_Save Global $iClientAreaOnly = 1 ; set to 1 to paint only client area Global $aWinGetPos Global $GetSystemMetrics_4 = _WinAPI_GetSystemMetrics(4) Global Const $DWM_TNP_RECTDESTINATION = 0x00000001 Global Const $DWM_TNP_RECTSOURCE = 0x00000002 Global Const $DWM_TNP_OPACITY = 0x00000004 Global Const $DWM_TNP_VISIBLE = 0x00000008 Global Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 Global Const $S_OK = 0 Global Const $S_FALSE = 1 If @OSVersion = "WIN_7" Then $Class_Calc = "[CLASS:CalcFrame]" ElseIf @OSVersion = "WIN_VISTA" Then $Class_Calc = "[CLASS:SciCalc]" Else MsgBox(16, "Error", "Vista or Win7 needed to run example.") Exit EndIf #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $GUI = GUICreate("(UDF Created) ListView Create", 520, 410) $a_WinGetPosEx_Source = _WinGetPosEx($GUI) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 500, 300) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Window Title", 300) _GUICtrlListView_InsertColumn($hListView, 1, "Window Handle", 90) _GUICtrlListView_InsertColumn($hListView, 2, "Window Process", 120) ; ;_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) $line = 0 $var = WinList() For $i = 1 To $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then _GUICtrlListView_AddItem($hListView, $var[$i][0], 0) _GUICtrlListView_AddSubItem($hListView, $line, $var[$i][1], 1) $WinGetProcess = WinGetProcess($var[$i][1]) $ProcessList = ProcessList() If $ProcessList[0][0] > 0 Then For $y = 1 To $ProcessList[0][0] If $ProcessList[$y][1] = $WinGetProcess Then _GUICtrlListView_AddSubItem($hListView, $line, $ProcessList[$y][0], 2) ExitLoop EndIf Next Else _GUICtrlListView_AddSubItem($hListView, $line, "PID: " & $WinGetProcess, 2) EndIf $line += 1 EndIf Next $cButtonselect = GUICtrlCreateButton("Select",50,350,100,20) $cButtonCancel = GUICtrlCreateButton("Cancel",200,350,100,20) GUIStartGroup() $cRadioWindow = GUICtrlCreateRadio("Whole window", 350, 350, 100, 20) $cRadioClient = GUICtrlCreateRadio("Client area only", 350, 370, 100, 20) GUICtrlSetState($cRadioWindow, $GUI_CHECKED) GUISetState() while sleep(10) $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE or $msg = $cButtonCancel then exit endif if $msg = $cButtonselect Then if _GUICtrlListView_GetSelectedCount($hListView) > 0 Then $aSelected = _GUICtrlListView_GetSelectedIndices($hListView,True) $hwnd_Source = HWnd(_GUICtrlListView_GetItemText($hListView, $aSelected[1], 1)) if WinExists($hwnd_Source) then if GUICtrlRead($cRadioWindow) = $GUI_CHECKED then $iClientAreaOnly = 0 Else $iClientAreaOnly = 1 endif GUIDelete($GUI) ExitLoop Else MsgBox(16,"Error","Window not found...") endif Else MsgBox(64,"Select a Window","You have to select a window to proced.") endif endif WEnd Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Opt("GUIOnEventMode", 1) $tTimer_Doubleclick = 0 $hM_Hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr(DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")), _WinAPI_GetModuleHandle(0)) HotKeySet("{ESC}", "_exit") ;$Class_Calc = "[CLASS:MozillaUIWindowClass]" ;$Class_Calc = "[CLASS:SciTEWindow]" ;$iPID = Run("calc.exe") #cs If WinWait($Class_Calc, "", 3) = 0 Then MsgBox(16, "Error", "Window not found.") _exit() EndIf #ce ;$hwnd_Source = WinGetHandle($Class_Calc) If $iPID = 0 Then $iPID = WinGetProcess($hwnd_Source) Global $iZoomFactor_Large = 1 ; to set "large" thumbnail size to width = source width ;$iZoomFactor_Large = 300 / $i_hwnd_Thumbnail_Width ; to set "large" thumbnail size to width = 300 Global $iZoomFactor_Small = 100 ; to set "small" thumbnail size to width = 100 $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf ;$i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] ;$i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) If UBound($a_GetWindowInfo) <> 16 Then MsgBox(16, "Error", "_WinAPI_Ex_GetWindowInfo() did not return result.") ProcessClose($iPID) Exit EndIf While Not BitAND(WinGetState($hwnd_Source, ""), 2) Sleep(10) WEnd $hwnd_Thumbnail = GUICreate("Vista Thumbnail", 100, 100, 100, 100, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_WindowDrag") $hThumbID = _DWM_Thumbnail_Register($hwnd_Thumbnail, $hwnd_Source) If @error Then MsgBox(16, "Error", "Registration of Thumbnail failed.") _exit() EndIf if _DwmQueryThumbnailSourceSize($hThumbID) = False Then MsgBox(16, "Error", "Thumbnail Source Size could not be determined.") _exit() endif $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf ;_check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True AdlibRegister("_check_GUI") Sleep(500) ; works for me, otherwise the inital thumb is resized / flickering a bit GUISetState() While Sleep(250) If Not ProcessExists($iPID) Then ExitLoop WEnd _exit() Func _exit() If IsHWnd($hwnd_Thumbnail) Then WinSetState($hwnd_Thumbnail, "", @SW_HIDE) _DWM_Thumbnail_Unregister($hThumbID) ;ProcessClose($iPID) _WinAPI_UnhookWindowsHookEx($hM_Hook) Exit EndFunc ;==>_exit Func _check_GUI() If Not IsHWnd($hwnd_Thumbnail) Or Not IsHWnd($hwnd_Source) Then Return If _WindowFromPoint() <> $hwnd_Thumbnail Then If $Big Then _check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $i_hwnd_Thumbnail_Height To $iZoomFactor_Small Step -$iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = False ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf Else If Not $Big Then _check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $iZoomFactor_Small To $i_hwnd_Thumbnail_Height Step $iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf EndIf EndFunc ;==>_check_GUI Func _check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) $i_hwnd_Source_State = WinGetState($hwnd_Source, "") If BitAND($i_hwnd_Source_State, 2) And Not BitAND($i_hwnd_Source_State, 16) Then ; Update only if source is visible and not minimized $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) $i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] $i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] If $iClientAreaOnly = 1 Then $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf EndIf $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width * $iZoomFactor_Large $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height * $iZoomFactor_Large EndIf EndFunc ;==>_check_GUI_Pos Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $aRet = DllCall("User32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint Func _WindowDrag() DllCall("user32.dll", "int", "SendMessage", "hWnd", $hwnd_Thumbnail, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>_WindowDrag Func _DWM_Thumbnail_Register($hwnd, $hWndOw) $aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", 0) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Register thumbnail failed Return $aRet[3] EndFunc ;==>_DWM_Thumbnail_Register Func _DWM_Thumbnail_Unregister($hThumbID) $aRet = DllCall("dwmapi.dll", "int", "DwmUnregisterThumbnail", "hwnd", $hThumbID) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Unregister thumbnail failed Return $aRet[0] EndFunc ;==>_DWM_Thumbnail_Unregister Func _DWM_Thumbnail_Update_Properties($hThumbID, $rcDest_X, $rcDest_Y, $rcDest_Width, $rcDest_Height, $rcOpacity = 255, $rcReadOnly = True, $rcClientAreaOnly = 0) $tDWM_THUMBNAIL_PROPERTIES = DllStructCreate("dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;int fVisible;int fSourceClientAreaOnly") DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "dwFlags", BitOR($DWM_TNP_RECTDESTINATION, $DWM_TNP_OPACITY, $DWM_TNP_VISIBLE, $DWM_TNP_SOURCECLIENTAREAONLY)) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_X, 1) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Y, 2) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Width, 3) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Height, 4) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "opacity", $rcOpacity) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fVisible", $rcReadOnly) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fSourceClientAreaOnly", $rcClientAreaOnly) $pDWM_THUMBNAIL_PROPERTIES = DllStructGetPtr($tDWM_THUMBNAIL_PROPERTIES) $aRet = DllCall("dwmapi.dll", "int", "DwmUpdateThumbnailProperties", "ptr", $hThumbID, "ptr", $pDWM_THUMBNAIL_PROPERTIES) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Update thumbnail failed EndFunc ;==>_DWM_Thumbnail_Update_Properties Func _WinAPI_Ex_GetWindowInfo($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) ; http://msdn.microsoft.com/en-us/library/ms632610(VS.85).aspx $tWINDOWINFO = DllStructCreate("dword cbSize;int rcWindow_Left;int rcWindow_Top;int rcWindow_Right;int rcWindow_Bottom;int rcClient_Left;int rcClient_Top;int rcClient_Right;int rcClient_Bottom;dword dwStyle;dword dwExStyle;dword dwWindowStatus;uint cxWindowBorders;uint cyWindowBorders;byte atomWindowType;byte wCreatorVersion;") DllStructSetData($tWINDOWINFO, 1, DllStructGetSize($tWINDOWINFO)) ; http://msdn.microsoft.com/en-us/library/ms633516(VS.85).aspx $aRet = DllCall("user32.dll", "hwnd", "GetWindowInfo", "hwnd", HWnd($hwnd), "ptr", DllStructGetPtr($tWINDOWINFO)) If $aRet[0] <> 1 Then Return SetError(2, 0, 0) Local $aRes[16][2] $aRes[0][0] = "cbSize" $aRes[1][0] = "rcWindow_Left" $aRes[2][0] = "rcWindow_Top" $aRes[3][0] = "rcWindow_Right" $aRes[4][0] = "rcWindow_Bottom" $aRes[5][0] = "rcClient_Left" $aRes[6][0] = "rcClient_Top" $aRes[7][0] = "rcClient_Right" $aRes[8][0] = "rcClient_Bottom" $aRes[9][0] = "dwStyle" $aRes[10][0] = "dwExStyle" $aRes[11][0] = "dwWindowStatus" $aRes[12][0] = "cxWindowBorders" $aRes[13][0] = "cyWindowBorders" $aRes[14][0] = "atomWindowType" $aRes[15][0] = "wCreatorVersion" For $i = 1 To 16 $aRes[$i - 1][1] = DllStructGetData($tWINDOWINFO, $i) Next Return $aRes EndFunc ;==>_WinAPI_Ex_GetWindowInfo Func _Mouse_Proc($nCode, $wParam, $lParam) ;$mouseData = DllStructGetData(DllStructCreate("int X;int Y" & ";dword mouseData", $lParam), 3) ;If $wParam = 0x020A Then $mouseEvent = BitShift($mouseData, 16) ; ConsoleWrite($nCode & @tab & $wParam & @tab & $lParam & @CRLF) If $wParam = 0x00000201 Then If TimerDiff($tTimer_Doubleclick) < 500 Then WinSetState($hwnd_Source, "", @SW_RESTORE) WinSetOnTop($hwnd_Source, "", 1) WinSetOnTop($hwnd_Source, "", 0) EndIf If _WindowFromPoint() = $hwnd_Thumbnail Then $tTimer_Doubleclick = TimerInit() EndIf EndFunc ;==>_Mouse_Proc ; #FUNCTION# ======================================================= ; Name...........: _WinGetPosEx ; Description ...: Retrieves Window size and position similar to WinGetPos() but regards possible Aero effects on Vista and Win7 ; Syntax.........: _WinGetPosEx($hWnd) ; Parameters ....: $hWnd - Handle to Window to measure ; Return values .: Success: Returns a 4-element array containing the following information: ; $array[0] = X position ; $array[1] = Y position ; $array[2] = Width ; $array[3] = Height ; Sets @extended = 0 for Aero effect is OFF for $hWnd ; = 1 for Aero effect is ON for $hWnd ; ; Failure: Returns 0 and sets @error to 1 if windows is not found. ; Author ........: KaFu ; Link ..........; http://msdn.microsoft.com/en-us/library/aa969515%28VS.85%29.aspx ; Example .......; Yes ; ================================================================== Func _WinGetPosEx($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) Local $aPos[4], $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom") Local Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 DllCall("dwmapi.dll", "hwnd", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hwnd), "dword", $DWMWA_EXTENDED_FRAME_BOUNDS, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error Then Return SetError(0, 0, WinGetPos($hwnd)) Local $iRectLeft = DllStructGetData($tRect, "Left") Local $iRectTop = DllStructGetData($tRect, "Top") Local $iRectRight = DllStructGetData($tRect, "Right") Local $iRectBottom = DllStructGetData($tRect, "Bottom") If Abs($iRectLeft) + Abs($iRectTop) + Abs($iRectRight) + Abs($iRectBottom) > 0 Then $aPos[0] = $iRectLeft $aPos[1] = $iRectTop $aPos[2] = $iRectRight - $iRectLeft $aPos[3] = $iRectBottom - $iRectTop Return SetError(0, 1, $aPos) EndIf Return SetError(0, 0, WinGetPos($hwnd)) EndFunc ;==>_WinGetPosEx Func _DwmQueryThumbnailSourceSize($hThumbID) #cs http://msdn.microsoft.com/en-us/library/aa969520%28VS.85%29.aspx HRESULT DwmQueryThumbnailSourceSize( HTHUMBNAIL hThumbnail, PSIZE pSize ); typedef struct tagSIZE { LONG cx; LONG cy; }SIZE, *PSIZE; #ce $tSize = DllStructCreate("int X;int Y") $aRet = DllCall("dwmapi.dll", "hwnd", "DwmQueryThumbnailSourceSize", "hwnd",$hThumbID, "ptr", DllStructGetPtr($tSize)) if $aRet[0] = $S_OK Then $i_hwnd_Thumbnail_Width = DllStructGetData($tSize, 1) $i_hwnd_Thumbnail_Height = DllStructGetData($tSize, 2) Return True Else Return False endif EndFunc ;==>_DwmQueryThumbnailSourceSize Edited January 29, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
wraithdu Posted January 29, 2010 Share Posted January 29, 2010 Here's my run on my laptop:WinGetPos: 374 73 423 322WinGetClientSize: 407 264_WinGetPosEx: 374 73 423 322_WinAPI_Ex_GetWindowInfo - Window: 374 73 797 395_WinAPI_Ex_GetWindowInfo - Window-Width: 423_WinAPI_Ex_GetWindowInfo - Window-Heigth: 322_WinAPI_Ex_GetWindowInfo - Client: 382 123 789 387_WinAPI_Ex_GetWindowInfo - Client-Width: 407_WinAPI_Ex_GetWindowInfo - Client-Heigth: 264_WinAPI_Ex_GetWindowInfo - Borders: 3 3Hmm, do you run any window managers or skins or custom scripts that modify windows (like NVidia's NView or something)?Your new method produces the same results. I have to switch to the GetSystemMetrics method, then it works perfectly for 'Client area only'. Full window mode works fine without adjustments. Link to comment Share on other sites More sharing options...
wraithdu Posted January 29, 2010 Share Posted January 29, 2010 AutoIt Window Info shows the same style and exstyle for calc on my laptop as what you posted. Are you using any windows themes or accessibility tools? Link to comment Share on other sites More sharing options...
KaFu Posted January 29, 2010 Share Posted January 29, 2010 Are you using any windows themes or accessibility tools? No. Maybe it's the AERO settings? I've set them to custom and enabled all checkboxes. Above code contained an error, DwmQueryThumbnailSourceSize was only called on creation but not on the sub-sequent adlib calls . Additionally I deleted all GetSystemMetrics() calls, let's see if windows can handle it by itself ...works "fine" for me, pls test. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Misc.au3> #include <Constants.au3> #include <array.au3> Global $hwnd_Thumbnail, $hThumbID, $iPID Global $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Width_Save Global $i_hwnd_Thumbnail_Height, $i_hwnd_Thumbnail_Height_Save Global $iClientAreaOnly = 1 ; set to 1 to paint only client area Global $aWinGetPos Global $GetSystemMetrics_4 = _WinAPI_GetSystemMetrics(4) Global Const $DWM_TNP_RECTDESTINATION = 0x00000001 Global Const $DWM_TNP_RECTSOURCE = 0x00000002 Global Const $DWM_TNP_OPACITY = 0x00000004 Global Const $DWM_TNP_VISIBLE = 0x00000008 Global Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 Global Const $S_OK = 0 Global Const $S_FALSE = 1 If @OSVersion = "WIN_7" Then $Class_Calc = "[CLASS:CalcFrame]" ElseIf @OSVersion = "WIN_VISTA" Then $Class_Calc = "[CLASS:SciCalc]" Else MsgBox(16, "Error", "Vista or Win7 needed to run example.") Exit EndIf #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $GUI = GUICreate("(UDF Created) ListView Create", 520, 410) $a_WinGetPosEx_Source = _WinGetPosEx($GUI) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 500, 300) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Window Title", 300) _GUICtrlListView_InsertColumn($hListView, 1, "Window Handle", 90) _GUICtrlListView_InsertColumn($hListView, 2, "Window Process", 120) ; ;_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) $line = 0 $var = WinList() For $i = 1 To $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then _GUICtrlListView_AddItem($hListView, $var[$i][0], 0) _GUICtrlListView_AddSubItem($hListView, $line, $var[$i][1], 1) $WinGetProcess = WinGetProcess($var[$i][1]) $ProcessList = ProcessList() If $ProcessList[0][0] > 0 Then For $y = 1 To $ProcessList[0][0] If $ProcessList[$y][1] = $WinGetProcess Then _GUICtrlListView_AddSubItem($hListView, $line, $ProcessList[$y][0], 2) ExitLoop EndIf Next Else _GUICtrlListView_AddSubItem($hListView, $line, "PID: " & $WinGetProcess, 2) EndIf $line += 1 EndIf Next $cButtonselect = GUICtrlCreateButton("Select",50,350,100,20) $cButtonCancel = GUICtrlCreateButton("Cancel",200,350,100,20) GUIStartGroup() $cRadioWindow = GUICtrlCreateRadio("Whole window", 350, 350, 100, 20) $cRadioClient = GUICtrlCreateRadio("Client area only", 350, 370, 100, 20) GUICtrlSetState($cRadioWindow, $GUI_CHECKED) GUISetState() while sleep(10) $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE or $msg = $cButtonCancel then exit endif if $msg = $cButtonselect Then if _GUICtrlListView_GetSelectedCount($hListView) > 0 Then $aSelected = _GUICtrlListView_GetSelectedIndices($hListView,True) $hwnd_Source = HWnd(_GUICtrlListView_GetItemText($hListView, $aSelected[1], 1)) if WinExists($hwnd_Source) then if GUICtrlRead($cRadioWindow) = $GUI_CHECKED then $iClientAreaOnly = 0 Else $iClientAreaOnly = 1 endif GUIDelete($GUI) ExitLoop Else MsgBox(16,"Error","Window not found...") endif Else MsgBox(64,"Select a Window","You have to select a window to proced.") endif endif WEnd Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Opt("GUIOnEventMode", 1) $tTimer_Doubleclick = 0 $hM_Hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr(DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")), _WinAPI_GetModuleHandle(0)) HotKeySet("{ESC}", "_exit") ;$Class_Calc = "[CLASS:MozillaUIWindowClass]" ;$Class_Calc = "[CLASS:SciTEWindow]" ;$iPID = Run("calc.exe") #cs If WinWait($Class_Calc, "", 3) = 0 Then MsgBox(16, "Error", "Window not found.") _exit() EndIf #ce ;$hwnd_Source = WinGetHandle($Class_Calc) If $iPID = 0 Then $iPID = WinGetProcess($hwnd_Source) Global $iZoomFactor_Large = 1 ; to set "large" thumbnail size to width = source width ;$iZoomFactor_Large = 300 / $i_hwnd_Thumbnail_Width ; to set "large" thumbnail size to width = 300 Global $iZoomFactor_Small = 100 ; to set "small" thumbnail size to width = 100 $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf ;$i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] ;$i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) If UBound($a_GetWindowInfo) <> 16 Then MsgBox(16, "Error", "_WinAPI_Ex_GetWindowInfo() did not return result.") ProcessClose($iPID) Exit EndIf While Not BitAND(WinGetState($hwnd_Source, ""), 2) Sleep(10) WEnd $hwnd_Thumbnail = GUICreate("Vista Thumbnail", 100, 100, 100, 100, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_WindowDrag") $hThumbID = _DWM_Thumbnail_Register($hwnd_Thumbnail, $hwnd_Source) If @error Then MsgBox(16, "Error", "Registration of Thumbnail failed.") _exit() EndIf if _DwmQueryThumbnailSourceSize($hThumbID) = False Then MsgBox(16, "Error", "Thumbnail Source Size could not be determined.") _exit() endif #cs $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf #ce ;_check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True AdlibRegister("_check_GUI") Sleep(500) ; works for me, otherwise the inital thumb is resized / flickering a bit GUISetState() While Sleep(250) If Not ProcessExists($iPID) or not WinExists($hwnd_Source) Then ExitLoop WEnd _exit() Func _exit() AdlibUnRegister("_check_GUI") If IsHWnd($hwnd_Thumbnail) Then WinSetState($hwnd_Thumbnail, "", @SW_HIDE) _DWM_Thumbnail_Unregister($hThumbID) ;ProcessClose($iPID) _WinAPI_UnhookWindowsHookEx($hM_Hook) Exit EndFunc ;==>_exit Func _check_GUI() If Not IsHWnd($hwnd_Thumbnail) Or Not IsHWnd($hwnd_Source) Then Return If _WindowFromPoint() <> $hwnd_Thumbnail Then If $Big Then _check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $i_hwnd_Thumbnail_Height To $iZoomFactor_Small Step -$iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = False ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf Else If Not $Big Then _check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $iZoomFactor_Small To $i_hwnd_Thumbnail_Height Step $iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf EndIf EndFunc ;==>_check_GUI Func _check_GUI_Pos() ;$aWinGetPos = WinGetPos($hwnd_Thumbnail) $i_hwnd_Source_State = WinGetState($hwnd_Source, "") If BitAND($i_hwnd_Source_State, 2) And Not BitAND($i_hwnd_Source_State, 16) Then ; Update only if source is visible and not minimized ;$a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) ;$a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) ;$i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] ;$i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] _DwmQueryThumbnailSourceSize($hThumbID) #cs If $iClientAreaOnly = 1 Then $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf EndIf #ce $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width * $iZoomFactor_Large $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height * $iZoomFactor_Large EndIf EndFunc ;==>_check_GUI_Pos Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $aRet = DllCall("User32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint Func _WindowDrag() DllCall("user32.dll", "int", "SendMessage", "hWnd", $hwnd_Thumbnail, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>_WindowDrag Func _DWM_Thumbnail_Register($hwnd, $hWndOw) $aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", 0) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Register thumbnail failed Return $aRet[3] EndFunc ;==>_DWM_Thumbnail_Register Func _DWM_Thumbnail_Unregister($hThumbID) $aRet = DllCall("dwmapi.dll", "int", "DwmUnregisterThumbnail", "hwnd", $hThumbID) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Unregister thumbnail failed Return $aRet[0] EndFunc ;==>_DWM_Thumbnail_Unregister Func _DWM_Thumbnail_Update_Properties($hThumbID, $rcDest_X, $rcDest_Y, $rcDest_Width, $rcDest_Height, $rcOpacity = 255, $rcReadOnly = True, $rcClientAreaOnly = 0) $tDWM_THUMBNAIL_PROPERTIES = DllStructCreate("dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;int fVisible;int fSourceClientAreaOnly") DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "dwFlags", BitOR($DWM_TNP_RECTDESTINATION, $DWM_TNP_OPACITY, $DWM_TNP_VISIBLE, $DWM_TNP_SOURCECLIENTAREAONLY)) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_X, 1) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Y, 2) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Width, 3) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Height, 4) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "opacity", $rcOpacity) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fVisible", $rcReadOnly) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fSourceClientAreaOnly", $rcClientAreaOnly) $pDWM_THUMBNAIL_PROPERTIES = DllStructGetPtr($tDWM_THUMBNAIL_PROPERTIES) $aRet = DllCall("dwmapi.dll", "int", "DwmUpdateThumbnailProperties", "ptr", $hThumbID, "ptr", $pDWM_THUMBNAIL_PROPERTIES) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Update thumbnail failed EndFunc ;==>_DWM_Thumbnail_Update_Properties Func _WinAPI_Ex_GetWindowInfo($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) ; http://msdn.microsoft.com/en-us/library/ms632610(VS.85).aspx $tWINDOWINFO = DllStructCreate("dword cbSize;int rcWindow_Left;int rcWindow_Top;int rcWindow_Right;int rcWindow_Bottom;int rcClient_Left;int rcClient_Top;int rcClient_Right;int rcClient_Bottom;dword dwStyle;dword dwExStyle;dword dwWindowStatus;uint cxWindowBorders;uint cyWindowBorders;byte atomWindowType;byte wCreatorVersion;") DllStructSetData($tWINDOWINFO, 1, DllStructGetSize($tWINDOWINFO)) ; http://msdn.microsoft.com/en-us/library/ms633516(VS.85).aspx $aRet = DllCall("user32.dll", "hwnd", "GetWindowInfo", "hwnd", HWnd($hwnd), "ptr", DllStructGetPtr($tWINDOWINFO)) If $aRet[0] <> 1 Then Return SetError(2, 0, 0) Local $aRes[16][2] $aRes[0][0] = "cbSize" $aRes[1][0] = "rcWindow_Left" $aRes[2][0] = "rcWindow_Top" $aRes[3][0] = "rcWindow_Right" $aRes[4][0] = "rcWindow_Bottom" $aRes[5][0] = "rcClient_Left" $aRes[6][0] = "rcClient_Top" $aRes[7][0] = "rcClient_Right" $aRes[8][0] = "rcClient_Bottom" $aRes[9][0] = "dwStyle" $aRes[10][0] = "dwExStyle" $aRes[11][0] = "dwWindowStatus" $aRes[12][0] = "cxWindowBorders" $aRes[13][0] = "cyWindowBorders" $aRes[14][0] = "atomWindowType" $aRes[15][0] = "wCreatorVersion" For $i = 1 To 16 $aRes[$i - 1][1] = DllStructGetData($tWINDOWINFO, $i) Next Return $aRes EndFunc ;==>_WinAPI_Ex_GetWindowInfo Func _Mouse_Proc($nCode, $wParam, $lParam) ;$mouseData = DllStructGetData(DllStructCreate("int X;int Y" & ";dword mouseData", $lParam), 3) ;If $wParam = 0x020A Then $mouseEvent = BitShift($mouseData, 16) ; ConsoleWrite($nCode & @tab & $wParam & @tab & $lParam & @CRLF) If $wParam = 0x00000201 Then If TimerDiff($tTimer_Doubleclick) < 500 Then WinSetState($hwnd_Source, "", @SW_RESTORE) WinSetOnTop($hwnd_Source, "", 1) WinSetOnTop($hwnd_Source, "", 0) EndIf If _WindowFromPoint() = $hwnd_Thumbnail Then $tTimer_Doubleclick = TimerInit() EndIf EndFunc ;==>_Mouse_Proc ; #FUNCTION# ======================================================= ; Name...........: _WinGetPosEx ; Description ...: Retrieves Window size and position similar to WinGetPos() but regards possible Aero effects on Vista and Win7 ; Syntax.........: _WinGetPosEx($hWnd) ; Parameters ....: $hWnd - Handle to Window to measure ; Return values .: Success: Returns a 4-element array containing the following information: ; $array[0] = X position ; $array[1] = Y position ; $array[2] = Width ; $array[3] = Height ; Sets @extended = 0 for Aero effect is OFF for $hWnd ; = 1 for Aero effect is ON for $hWnd ; ; Failure: Returns 0 and sets @error to 1 if windows is not found. ; Author ........: KaFu ; Link ..........; http://msdn.microsoft.com/en-us/library/aa969515%28VS.85%29.aspx ; Example .......; Yes ; ================================================================== Func _WinGetPosEx($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) Local $aPos[4], $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom") Local Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 DllCall("dwmapi.dll", "hwnd", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hwnd), "dword", $DWMWA_EXTENDED_FRAME_BOUNDS, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error Then Return SetError(0, 0, WinGetPos($hwnd)) Local $iRectLeft = DllStructGetData($tRect, "Left") Local $iRectTop = DllStructGetData($tRect, "Top") Local $iRectRight = DllStructGetData($tRect, "Right") Local $iRectBottom = DllStructGetData($tRect, "Bottom") If Abs($iRectLeft) + Abs($iRectTop) + Abs($iRectRight) + Abs($iRectBottom) > 0 Then $aPos[0] = $iRectLeft $aPos[1] = $iRectTop $aPos[2] = $iRectRight - $iRectLeft $aPos[3] = $iRectBottom - $iRectTop Return SetError(0, 1, $aPos) EndIf Return SetError(0, 0, WinGetPos($hwnd)) EndFunc ;==>_WinGetPosEx Func _DwmQueryThumbnailSourceSize($hThumbID) #cs http://msdn.microsoft.com/en-us/library/aa969520%28VS.85%29.aspx HRESULT DwmQueryThumbnailSourceSize( HTHUMBNAIL hThumbnail, PSIZE pSize ); typedef struct tagSIZE { LONG cx; LONG cy; }SIZE, *PSIZE; #ce $tSize = DllStructCreate("int X;int Y") $aRet = DllCall("dwmapi.dll", "hwnd", "DwmQueryThumbnailSourceSize", "hwnd",$hThumbID, "ptr", DllStructGetPtr($tSize)) if $aRet[0] = $S_OK Then $i_hwnd_Thumbnail_Width = DllStructGetData($tSize, 1) $i_hwnd_Thumbnail_Height = DllStructGetData($tSize, 2) Return True Else Return False endif EndFunc ;==>_DwmQueryThumbnailSourceSize OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
wraithdu Posted January 29, 2010 Share Posted January 29, 2010 (edited) Yeah, that one works both full and client only Nice job. BTW, I think you'll want to use _GUICtrlListView_GetItemChecked instead of Selected for your listview. Now, where are you changing the Aero settings with a bunch of checkmarks? I'm having a hard time finding that menu. Edited January 29, 2010 by wraithdu Link to comment Share on other sites More sharing options...
KaFu Posted January 29, 2010 Share Posted January 29, 2010 Yeah, that one works both full and client only Nice job. great to hear, already tinkering on a better GUI ...BTW, I think you'll want to use _GUICtrlListView_GetItemChecked instead of Selected for your listview.Will do!Now, where are you changing the Aero settings with a bunch of checkmarks? I'm having a hard time finding that menu.Yeah, Win7 system settings are hell . System Settings => System => Advanced => Performance / Visual Effects OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
wraithdu Posted January 29, 2010 Share Posted January 29, 2010 Oh, that one. Yeah, that shouldn't make a difference. Link to comment Share on other sites More sharing options...
wraithdu Posted January 30, 2010 Share Posted January 30, 2010 Here's a fix to your _WindowFromPoint() function for x64 compatibility (incidentally the same fix in _WinAPI_WindowFromPoint). Reference #1362. Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $pt = DllStructCreate("long;long") Local $pt64 = DllStructCreate("int64", DllStructGetPtr($pt)) DllStructSetData($pt, 1, MouseGetPos(0)) DllStructSetData($pt, 2, MouseGetPos(1)) Local $aRet = DllCall("User32.dll", "hwnd", "WindowFromPoint", _ "int64", DllStructGetData($pt64, 1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint Link to comment Share on other sites More sharing options...
KaFu Posted January 30, 2010 Share Posted January 30, 2010 (edited) Here's a fix to your _WindowFromPoint() function for x64 compatibility (incidentally the same fix in _WinAPI_WindowFromPoint). Reference #1362. Hu, hadn't seen that bug-report. As I'm utilizing this function quiet often this comes in really handy, thanks for the heads up ! But what's bothering me more... it seems that the OS stops updating / redrawing minimized windows. Monitor a window which is constantly redrawing, e.g. a firefox window, and then minimize it to taskbar... you'll see that the thumbnail will stop updating too... aaarrrghhh, windows! Edit: The only way to prevent the source window from stopping to redraw I see atm is to add something like this ElseIf BitAND($i_hwnd_Source_State, 16) then WinSetState($hwnd_Source,"",@SW_SHOWNOACTIVATE) Not really nice. BUT what I observed is, when you add that code, then press the "Show Desktop" button in the lower right (WIN-D doesn't work), the window is still updated. There has to be something like a mixed mode somewhere, will look into what windows does when the user presses that button . expandcollapse popup#NoTrayIcon #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Misc.au3> #include <Constants.au3> #include <array.au3> Global $hwnd_Thumbnail, $hThumbID, $iPID Global $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Width_Save Global $i_hwnd_Thumbnail_Height, $i_hwnd_Thumbnail_Height_Save Global $iClientAreaOnly = 1 ; set to 1 to paint only client area Global $aWinGetPos Global Const $DWM_TNP_RECTDESTINATION = 0x00000001 Global Const $DWM_TNP_RECTSOURCE = 0x00000002 Global Const $DWM_TNP_OPACITY = 0x00000004 Global Const $DWM_TNP_VISIBLE = 0x00000008 Global Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 Global Const $S_OK = 0 Global Const $S_FALSE = 1 If @OSVersion = "WIN_7" Then $Class_Calc = "[CLASS:CalcFrame]" ElseIf @OSVersion = "WIN_VISTA" Then $Class_Calc = "[CLASS:SciCalc]" Else MsgBox(16, "Error", "Vista or Win7 needed to run example.") Exit EndIf #include <GuiConstantsEx.au3> #include <GuiListView.au3> $ILC_MASK = 0x1 $ILC_COLOR32 = 0x20 $ILC_COLOR24 = 0x18 $ILC_PERITEMMIRROR = 0x00008000 $lvFlags = $ILC_COLOR32 + $ILC_MASK + $ILC_PERITEMMIRROR $guiWinList = GUICreate("SAT - Simple AERO Thumbnailer") $a_WinGetPosEx_Source = _WinGetPosEx($guiWinList) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf ;_GetPrivilege_SEDEBUG() $mylist = GUICtrlCreateListView("Window Title |Process |Handle ", 10, 10, 380, 320, $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($mylist) $mylistImageList = DllCall("ComCtl32.dll", "hwnd", "ImageList_Create", "int", 16, "int", 16, "int", $lvFlags, "int", 0, "int", 1) $mylistImageList = $mylistImageList[0] $var = WinList() $ProcessList = ProcessList() $AutoItPID = @AutoItPID For $i = 1 To $var[0][0] $winHandle = $var[$i][1] $winTitle = $var[$i][0] $WinGetProcessName = "" $WinGetProcess = WinGetProcess($winHandle) $winHandleDesktop = WinGetHandle("Program Manager","") If ($winTitle <> "" And IsVisible($winHandle) And $WinGetProcess <> $AutoItPID) or $winHandle = $winHandleDesktop Then if $winHandle = $winHandleDesktop then $winTitle = "Desktop" If $ProcessList[0][0] > 0 Then For $y = 1 To $ProcessList[0][0] If $ProcessList[$y][1] = $WinGetProcess Then $WinGetProcessName = $ProcessList[$y][0] ExitLoop EndIf Next Else $WinGetProcessName = "PID: " & $WinGetProcess EndIf $lvitem = GUICtrlCreateListViewItem($winTitle & "|" & $WinGetProcessName & "|" & $winHandle, $mylist) GUICtrlSetImage($lvitem, "shell32.dll", 224);have to set something, or there'll be no image list to swap out! $hIcon = getIconHandleByHwnd($var[$i][1]) $nIndex = DllCall('comctl32.dll', 'int', 'ImageList_AddIcon', 'hwnd', $mylistImageList, 'hwnd', $hIcon) DllCall('user32.dll', 'int', 'DestroyIcon', 'hwnd', $hIcon) EndIf Next _SendMessage($hListView, $LVM_SETIMAGELIST, 1, $mylistImageList) _GUICtrlListView_SetColumnWidth($hListView, 0, 230) $cButtonselect = GUICtrlCreateButton("Select",150,345,100,40) $cButtonCancel = GUICtrlCreateButton("Cancel",280,345,100,40) GUIStartGroup() $cRadioWindow = GUICtrlCreateRadio("Whole window", 30, 345, 100, 20) $cRadioClient = GUICtrlCreateRadio("Client area only", 30, 365, 100, 20) GUICtrlSetState($cRadioWindow, $GUI_CHECKED) GUISetState() while sleep(10) $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE or $msg = $cButtonCancel then exit endif if $msg = $cButtonselect Then if _GUICtrlListView_GetSelectedCount($hListView) > 0 Then $aSelected = _GUICtrlListView_GetSelectedIndices($hListView,True) $hwnd_Source = HWnd(_GUICtrlListView_GetItemText($hListView, $aSelected[1], 2)) if WinExists($hwnd_Source) then if GUICtrlRead($cRadioWindow) = $GUI_CHECKED then $iClientAreaOnly = 0 Else $iClientAreaOnly = 1 endif GUIDelete($guiWinList) ExitLoop Else MsgBox(16,"Error","Window not found...") endif Else MsgBox(64,"Select a Window","You have to select a window to proced.") endif endif WEnd Func IsVisible($handle) if $handle = _WinAPI_GetDesktopWindow() then Return 1 If BitAND(WinGetState($handle), 2) And Not BitAND(_WinAPI_GetWindowLong($handle, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) AND Not _WinAPI_GetParent($handle)Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Func getIconHandleByFile($pszPath) ; http://www.autoitscript.com/forum/index.php?showtopic=40762&st=0&p=303247&hl=icon%20handle%20window&fromsearch=1&#entry303247 ; lod3n $SHGFI_ICON = 0x100 ;Get icon $SHGFI_SMALLICON = 0x1 ;Get Small Icon $dwFileAttributes = 0 $psfi = DllStructCreate("uint;int;dword;char[260];char[80]") ; thanks Holger! $cbSizeFileInfo = DllStructGetSize($psfi) $uFlags = BitOR($SHGFI_ICON, $SHGFI_SMALLICON) $hImgSmall = DllCall('shell32.dll', 'int', 'SHGetFileInfo', _ 'str', $pszPath, _ 'uint', $dwFileAttributes, _ 'ptr', DllStructGetPtr($psfi), _ 'uint', $cbSizeFileInfo, _ 'uint', $uFlags) Return DllStructGetData($psfi, 1) EndFunc ;==>getIconHandleByFile Func getIconHandleByHwnd($hwnd) ; http://www.autoitscript.com/forum/index.php?showtopic=40762&st=0&p=303247&hl=icon%20handle%20window&fromsearch=1&#entry303247 ; lod3n $hwnd = HWnd($hwnd) ;$WM_GETICON = 0x7F $GCL_HICONSM = -34 $GCL_HICON = -14 ;$IDI_APPLICATION = 32512 $hIcon = 0 $hIcon = _SendMessage($hwnd, $WM_GETICON, False, 0) If ($hIcon == 0) Then $hIcon = _SendMessage($hwnd, $WM_GETICON, True, 0) If ($hIcon == 0) Then $hIcon = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hwnd, "int", $GCL_HICONSM) $hIcon = $hIcon[0] EndIf If ($hIcon == 0) Then $hIcon = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hwnd, "int", $GCL_HICON) $hIcon = $hIcon[0] EndIf If ($hIcon == 0) Then $pid = WinGetProcess(HWnd($hwnd)) $path = getExePathByPid($pid) $hIcon = getIconHandleByFile($path) EndIf Return $hIcon EndFunc ;==>getIconHandleByHwnd Func getExePathByPid($pid) $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Return $objItem.ExecutablePath Next EndIf EndFunc ;==>getExePathByPid #cs Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc ;==>_ProcessGetLocation ; By wraithdu ; http://www.autoitscript.com/forum/index.php?showtopic=88214&view=findpost&p=634408 ; ####################### Below Func is Part of example - Needed to get commandline from more processes. ############ ; ####################### Thanks for this function, wraithdu! (Didn't know it was your.) smile.gif ######################### Func _GetPrivilege_SEDEBUG() Local $tagLUIDANDATTRIB = "int64 Luid;dword Attributes" Local $count = 1 Local $tagTOKENPRIVILEGES = "dword PrivilegeCount;byte LUIDandATTRIB[" & $count * 12 & "]" ; count of LUID structs * sizeof LUID struct Local $TOKEN_ADJUST_PRIVILEGES = 0x20 Local $call = DllCall("advapi32.dll", "int", "OpenProcessToken", "ptr", _WinAPI_GetCurrentProcess(), "dword", $TOKEN_ADJUST_PRIVILEGES, "ptr*", "") Local $hToken = $call[3] $call = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", Chr(0), "str", "SeDebugPrivilege", "int64*", "") ;msgbox(262144,"",$call[3] & " " & _WinAPI_GetLastErrorMessage()) Local $iLuid = $call[3] Local $TP = DllStructCreate($tagTOKENPRIVILEGES) Local $LUID = DllStructCreate($tagLUIDANDATTRIB, DllStructGetPtr($TP, "LUIDandATTRIB")) DllStructSetData($TP, "PrivilegeCount", $count) DllStructSetData($LUID, "Luid", $iLuid) DllStructSetData($LUID, "Attributes", $SE_PRIVILEGE_ENABLED) $call = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "ptr", $hToken, "int", 0, "ptr", DllStructGetPtr($TP), "dword", 0, "ptr", Chr(0), "ptr", Chr(0)) Return ($call[0] <> 0) ; $call[0] <> 0 is success EndFunc ;==>_GetPrivilege_SEDEBUG #ce Opt("GUIOnEventMode", 1) Opt("WinWaitDelay", 50) $tTimer_Doubleclick = 0 $hM_Hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr(DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")), _WinAPI_GetModuleHandle(0)) HotKeySet("{ESC}", "_exit") ;$Class_Calc = "[CLASS:MozillaUIWindowClass]" ;$Class_Calc = "[CLASS:SciTEWindow]" ;$iPID = Run("calc.exe") #cs If WinWait($Class_Calc, "", 3) = 0 Then MsgBox(16, "Error", "Window not found.") _exit() EndIf #ce ;$hwnd_Source = WinGetHandle($Class_Calc) If $iPID = 0 Then $iPID = WinGetProcess($hwnd_Source) Global $iZoomFactor_Large = 1 ; to set "large" thumbnail size to width = source width $iZoomFactor_Large = 500 / $i_hwnd_Thumbnail_Width ; to set "large" thumbnail size to width = 300 Global $iZoomFactor_Small = 200 ; to set "small" thumbnail size to width = 100 $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf ;$i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] ;$i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] $a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) If UBound($a_GetWindowInfo) <> 16 Then MsgBox(16, "Error", "_WinAPI_Ex_GetWindowInfo() did not return result.") ProcessClose($iPID) Exit EndIf While Not BitAND(WinGetState($hwnd_Source, ""), 2) Sleep(10) WEnd $hwnd_Thumbnail = GUICreate("Vista Thumbnail", 100, 100, 100, 100, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_WindowDrag") $hThumbID = _DWM_Thumbnail_Register($hwnd_Thumbnail, $hwnd_Source) If @error Then MsgBox(16, "Error", "Registration of Thumbnail failed.") _exit() EndIf if _DwmQueryThumbnailSourceSize($hThumbID) = False Then MsgBox(16, "Error", "Thumbnail Source Size could not be determined.") _exit() endif $iZoomFactor_Large = 600 / $i_hwnd_Thumbnail_Width ; to set "large" thumbnail size to width = 300 #cs $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf #ce ;_check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True AdlibRegister("_check_GUI") Sleep(500) ; works for me, otherwise the inital thumb is resized / flickering a bit GUISetState() While Sleep(250) If Not ProcessExists($iPID) or not WinExists($hwnd_Source) Then ExitLoop WEnd _exit() Func _exit() AdlibUnRegister("_check_GUI") If IsHWnd($hwnd_Thumbnail) Then WinSetState($hwnd_Thumbnail, "", @SW_HIDE) _DWM_Thumbnail_Unregister($hThumbID) ;ProcessClose($iPID) _WinAPI_UnhookWindowsHookEx($hM_Hook) Exit EndFunc ;==>_exit Func _check_GUI() If Not IsHWnd($hwnd_Thumbnail) Or Not IsHWnd($hwnd_Source) Then Return _check_GUI_Pos() If _WindowFromPoint() <> $hwnd_Thumbnail Then If $Big Then WinSetTrans($hwnd_Thumbnail,"",160) ;_check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $i_hwnd_Thumbnail_Height To $iZoomFactor_Small Step -$iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = False ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed ;_check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf Else If Not $Big Then WinSetTrans($hwnd_Thumbnail,"",255) ;_check_GUI_Pos() $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $iZoomFactor_Small To $i_hwnd_Thumbnail_Height Step $iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed ;_check_GUI_Pos() _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf EndIf EndFunc ;==>_check_GUI Func _check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) $i_hwnd_Source_State = WinGetState($hwnd_Source, "") If BitAND($i_hwnd_Source_State, 2) And Not BitAND($i_hwnd_Source_State, 16) Then ; Update only if source is visible and not minimized ;$a_GetWindowInfo = _WinAPI_Ex_GetWindowInfo($hwnd_Source) ;$a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) ;$i_hwnd_Thumbnail_Width = $a_WinGetPosEx_Source[2] ;$i_hwnd_Thumbnail_Height = $a_WinGetPosEx_Source[3] _DwmQueryThumbnailSourceSize($hThumbID) #cs If $iClientAreaOnly = 1 Then $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width - (2 * $a_GetWindowInfo[13][1]) If BitAND($a_GetWindowInfo[9][1], $WS_CAPTION) Then $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) - $GetSystemMetrics_4 Else $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height - (2 * $a_GetWindowInfo[13][1]) EndIf EndIf #ce $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width * $iZoomFactor_Large $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height * $iZoomFactor_Large ElseIf BitAND($i_hwnd_Source_State, 16) then ;$aWinGetPosSource = WinGetPos($hwnd_Source) ; http://stackoverflow.com/questions/938793/vista-application-thumbnail ;WinMove($hwnd_Source,"",9999,9999,$aWinGetPosSource[2],$aWinGetPosSource[3],0) ;$hwnd_active = WinGetHandle("[ACTIVE]", "") WinSetState($hwnd_Source,"",@SW_SHOWNOACTIVATE) ;Send("#d") ;WinSetState($hwnd_active,"",@SW_SHOW) ;WinSetState($winHandleDesktop,"",@SW_SHOWNOACTIVATE) ;_WinAPI_SetWindowPos($hwnd_Source, $HWND_BOTTOM, $aWinGetPosSource[0], $aWinGetPosSource[1], $aWinGetPosSource[2], $aWinGetPosSource[3], BitOR($SWP_NOACTIVATE,$SWP_SHOWWINDOW)) ;WinSetState($hwnd_Source,"",@SW_SHOWNOACTIVATE) ;_WinAPI_RedrawWindow($hwnd_Source) EndIf EndFunc ;==>_check_GUI_Pos Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; x64 FIX! http://www.autoitscript.com/trac/autoit/ticket/1362 ; http://www.autoitscript.com/forum/index.php?showtopic=77831&view=findpost&p=768190 ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $pt = DllStructCreate("long;long") Local $pt64 = DllStructCreate("int64", DllStructGetPtr($pt)) DllStructSetData($pt, 1, MouseGetPos(0)) DllStructSetData($pt, 2, MouseGetPos(1)) Local $aRet = DllCall("User32.dll", "hwnd", "WindowFromPoint", _ "int64", DllStructGetData($pt64, 1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint #cs Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $aRet = DllCall("User32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint #ce Func _WindowDrag() DllCall("user32.dll", "int", "SendMessage", "hWnd", $hwnd_Thumbnail, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>_WindowDrag Func _DWM_Thumbnail_Register($hwnd, $hWndOw) $aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", 0) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Register thumbnail failed Return $aRet[3] EndFunc ;==>_DWM_Thumbnail_Register Func _DWM_Thumbnail_Unregister($hThumbID) $aRet = DllCall("dwmapi.dll", "int", "DwmUnregisterThumbnail", "hwnd", $hThumbID) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Unregister thumbnail failed Return $aRet[0] EndFunc ;==>_DWM_Thumbnail_Unregister Func _DWM_Thumbnail_Update_Properties($hThumbID, $rcDest_X, $rcDest_Y, $rcDest_Width, $rcDest_Height, $rcOpacity = 255, $rcReadOnly = True, $rcClientAreaOnly = 0) $tDWM_THUMBNAIL_PROPERTIES = DllStructCreate("dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;int fVisible;int fSourceClientAreaOnly") DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "dwFlags", BitOR($DWM_TNP_RECTDESTINATION, $DWM_TNP_OPACITY, $DWM_TNP_VISIBLE, $DWM_TNP_SOURCECLIENTAREAONLY)) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_X, 1) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Y, 2) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Width, 3) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Height, 4) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "opacity", $rcOpacity) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fVisible", $rcReadOnly) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fSourceClientAreaOnly", $rcClientAreaOnly) $pDWM_THUMBNAIL_PROPERTIES = DllStructGetPtr($tDWM_THUMBNAIL_PROPERTIES) $aRet = DllCall("dwmapi.dll", "int", "DwmUpdateThumbnailProperties", "ptr", $hThumbID, "ptr", $pDWM_THUMBNAIL_PROPERTIES) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Update thumbnail failed EndFunc ;==>_DWM_Thumbnail_Update_Properties Func _WinAPI_Ex_GetWindowInfo($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) ; http://msdn.microsoft.com/en-us/library/ms632610(VS.85).aspx $tWINDOWINFO = DllStructCreate("dword cbSize;int rcWindow_Left;int rcWindow_Top;int rcWindow_Right;int rcWindow_Bottom;int rcClient_Left;int rcClient_Top;int rcClient_Right;int rcClient_Bottom;dword dwStyle;dword dwExStyle;dword dwWindowStatus;uint cxWindowBorders;uint cyWindowBorders;byte atomWindowType;byte wCreatorVersion;") DllStructSetData($tWINDOWINFO, 1, DllStructGetSize($tWINDOWINFO)) ; http://msdn.microsoft.com/en-us/library/ms633516(VS.85).aspx $aRet = DllCall("user32.dll", "hwnd", "GetWindowInfo", "hwnd", HWnd($hwnd), "ptr", DllStructGetPtr($tWINDOWINFO)) If $aRet[0] <> 1 Then Return SetError(2, 0, 0) Local $aRes[16][2] $aRes[0][0] = "cbSize" $aRes[1][0] = "rcWindow_Left" $aRes[2][0] = "rcWindow_Top" $aRes[3][0] = "rcWindow_Right" $aRes[4][0] = "rcWindow_Bottom" $aRes[5][0] = "rcClient_Left" $aRes[6][0] = "rcClient_Top" $aRes[7][0] = "rcClient_Right" $aRes[8][0] = "rcClient_Bottom" $aRes[9][0] = "dwStyle" $aRes[10][0] = "dwExStyle" $aRes[11][0] = "dwWindowStatus" $aRes[12][0] = "cxWindowBorders" $aRes[13][0] = "cyWindowBorders" $aRes[14][0] = "atomWindowType" $aRes[15][0] = "wCreatorVersion" For $i = 1 To 16 $aRes[$i - 1][1] = DllStructGetData($tWINDOWINFO, $i) Next Return $aRes EndFunc ;==>_WinAPI_Ex_GetWindowInfo Func _Mouse_Proc($nCode, $wParam, $lParam) ;$mouseData = DllStructGetData(DllStructCreate("int X;int Y" & ";dword mouseData", $lParam), 3) ;If $wParam = 0x020A Then $mouseEvent = BitShift($mouseData, 16) ; ConsoleWrite($nCode & @tab & $wParam & @tab & $lParam & @CRLF) If $wParam = 0x00000201 Then If TimerDiff($tTimer_Doubleclick) < 500 Then WinSetState($hwnd_Source, "", @SW_RESTORE) WinSetOnTop($hwnd_Source, "", 1) WinSetOnTop($hwnd_Source, "", 0) EndIf If _WindowFromPoint() = $hwnd_Thumbnail Then $tTimer_Doubleclick = TimerInit() EndIf EndFunc ;==>_Mouse_Proc ; #FUNCTION# ======================================================= ; Name...........: _WinGetPosEx ; Description ...: Retrieves Window size and position similar to WinGetPos() but regards possible Aero effects on Vista and Win7 ; Syntax.........: _WinGetPosEx($hWnd) ; Parameters ....: $hWnd - Handle to Window to measure ; Return values .: Success: Returns a 4-element array containing the following information: ; $array[0] = X position ; $array[1] = Y position ; $array[2] = Width ; $array[3] = Height ; Sets @extended = 0 for Aero effect is OFF for $hWnd ; = 1 for Aero effect is ON for $hWnd ; ; Failure: Returns 0 and sets @error to 1 if windows is not found. ; Author ........: KaFu ; Link ..........; http://msdn.microsoft.com/en-us/library/aa969515%28VS.85%29.aspx ; Example .......; Yes ; ================================================================== Func _WinGetPosEx($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) Local $aPos[4], $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom") Local Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 DllCall("dwmapi.dll", "hwnd", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hwnd), "dword", $DWMWA_EXTENDED_FRAME_BOUNDS, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error Then Return SetError(0, 0, WinGetPos($hwnd)) Local $iRectLeft = DllStructGetData($tRect, "Left") Local $iRectTop = DllStructGetData($tRect, "Top") Local $iRectRight = DllStructGetData($tRect, "Right") Local $iRectBottom = DllStructGetData($tRect, "Bottom") If Abs($iRectLeft) + Abs($iRectTop) + Abs($iRectRight) + Abs($iRectBottom) > 0 Then $aPos[0] = $iRectLeft $aPos[1] = $iRectTop $aPos[2] = $iRectRight - $iRectLeft $aPos[3] = $iRectBottom - $iRectTop Return SetError(0, 1, $aPos) EndIf Return SetError(0, 0, WinGetPos($hwnd)) EndFunc ;==>_WinGetPosEx Func _DwmQueryThumbnailSourceSize($hThumbID) #cs http://msdn.microsoft.com/en-us/library/aa969520%28VS.85%29.aspx HRESULT DwmQueryThumbnailSourceSize( HTHUMBNAIL hThumbnail, PSIZE pSize ); typedef struct tagSIZE { LONG cx; LONG cy; }SIZE, *PSIZE; #ce $tSize = DllStructCreate("int X;int Y") $aRet = DllCall("dwmapi.dll", "hwnd", "DwmQueryThumbnailSourceSize", "hwnd",$hThumbID, "ptr", DllStructGetPtr($tSize)) if $aRet[0] = $S_OK Then $i_hwnd_Thumbnail_Width = DllStructGetData($tSize, 1) $i_hwnd_Thumbnail_Height = DllStructGetData($tSize, 2) Return True Else Return False endif EndFunc ;==>_DwmQueryThumbnailSourceSize Edited January 30, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
wraithdu Posted January 30, 2010 Share Posted January 30, 2010 Not even the Windows superbar thumbnails update while the window is minimized, so I wouldn't worry too much if you can't find a solution. One more thing, while your _WindowDrag() function works fine, you don't really need it. You just have to give the thumbnail GUI the $WS_EX_CONTROLPARENT extended style: $hwnd_Thumbnail = GUICreate("Vista Thumbnail", 100, 100, 100, 100, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) Link to comment Share on other sites More sharing options...
KaFu Posted May 11, 2010 Share Posted May 11, 2010 Hu, seems like I didn't publish the latest version . expandcollapse popup#NoTrayIcon #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=SAT.ico #AutoIt3Wrapper_Outfile=SAT.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Res_Comment=© SAT - Simple AERO Thumbnailer 2010 by Karsten Funk. All rights reserved. http://www.funk.eu #AutoIt3Wrapper_Res_Description=SAT - Simple AERO Thumbnailer #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_LegalCopyright=Creative Commons License "by-nc-sa 3.0", this program is freeware under Creative Commons License "by-nc-sa 3.0" (http://creativecommons.org/licenses/by-nc-sa/3.0/us/) #AutoIt3Wrapper_res_requestedExecutionLevel=highestAvailable ://////=__= ://////=__= ://////=__= #AutoIt3Wrapper_Au3Check_Stop_OnWarning=y #AutoIt3Wrapper_Run_Tidy=y #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** ; AutoIt Version: 3.3.4.0 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <Misc.au3> Global $s_versionnumber = "v1.0.0.1 (2010-Jan-31)" Global $s_mainguititel = "SAT - Simple AERO Thumbnailer - " & $s_versionnumber Opt("WinWaitDelay", 50) Global $hwnd_Thumbnail, $hThumbID, $iPID Global $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Width_Save Global $i_hwnd_Thumbnail_Height, $i_hwnd_Thumbnail_Height_Save Global $iClientAreaOnly = 1 ; set to 1 to paint only client area Global $aWinGetPos Global Const $DWM_TNP_RECTDESTINATION = 0x00000001 Global Const $DWM_TNP_RECTSOURCE = 0x00000002 Global Const $DWM_TNP_OPACITY = 0x00000004 Global Const $DWM_TNP_VISIBLE = 0x00000008 Global Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 Global Const $S_OK = 0 Global Const $S_FALSE = 1 Global $tTimer_Doubleclick = 0, $iPID = 0 Global $iZoomFactor_Large = 1 ; to set "large" thumbnail size to width = source width Global $iZoomFactor_Large_PX = 600 Global $iZoomFactor_Small = 200 ; to set "small" thumbnail size to width = 100 Global $Big = True Global $bExitPreview = False Global $hMO_Hook, $hKB_Hook, $hStub_KeyProc, $hStub_MouseProc Global $winTitle_Buffer If Not @OSVersion = "WIN_7" And Not @OSVersion = "WIN_VISTA" Then MsgBox(16, "Error", "Vista or Win7 needed to run example.") Exit EndIf $guiWinList = GUICreate($s_mainguititel) $a_WinGetPosEx_Source = _WinGetPosEx($guiWinList) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system, SAT will not work.") Exit EndIf $hListView = _GUICtrlListView_Create($guiWinList, "", 10, 10, 380, 320) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) _GUICtrlListView_InsertColumn($hListView, 0, "Window Title", 300) _GUICtrlListView_InsertColumn($hListView, 1, "Process", 80) _GUICtrlListView_InsertColumn($hListView, 2, "Handle", 0) $hImage = _GUIImageList_Create(16, 16, 5, 1 + 2, 0, 1) _GUICtrlListView_SetImageList($hListView, $hImage, 1) $var = WinList() $ProcessList = ProcessList() $AutoItPID = @AutoItPID $line = 0 Global $aImagePos[1][2] $winHandleDesktop = WinGetHandle("Program Manager", "") For $i = 1 To $var[0][0] $winHandle = $var[$i][1] $winTitle = $var[$i][0] $WinGetProcessName = "" $WinGetProcess = WinGetProcess($winHandle) If ($winTitle <> "" And IsVisible($winHandle) And $WinGetProcess <> $AutoItPID) Then If $ProcessList[0][0] > 0 Then For $y = 1 To $ProcessList[0][0] If $ProcessList[$y][1] = $WinGetProcess Then $WinGetProcessName = $ProcessList[$y][0] ExitLoop EndIf Next Else $WinGetProcessName = "PID: " & $WinGetProcess EndIf $hIcon = getIconHandleByHwnd($winHandle) _GUIImageList_ReplaceIcon($hImage, -1, $hIcon) _GUICtrlListView_AddItem($hListView, $winTitle, 0) _GUICtrlListView_AddSubItem($hListView, $line, $WinGetProcessName, 1) _GUICtrlListView_AddSubItem($hListView, $line, $winHandle, 2) ReDim $aImagePos[$line + 1][2] $aImagePos[$line][0] = $winHandle $aImagePos[$line][1] = $line $line += 1 EndIf Next $vDescending = False _GUICtrlListView_SimpleSort($hListView, $vDescending, 0) For $y = 0 To _GUICtrlListView_GetItemCount($hListView) For $i = 0 To UBound($aImagePos) - 1 If $aImagePos[$i][0] = _GUICtrlListView_GetItemText($hListView, $y, 2) Then _GUICtrlListView_SetItemImage($hListView, $y, $i) ExitLoop EndIf Next Next $hIcon = getIconHandleByHwnd($winHandleDesktop) _GUICtrlListView_InsertItem($hListView, "Desktop", 0, _GUIImageList_ReplaceIcon($hImage, -1, $hIcon)) _GUICtrlListView_SetItemText($hListView, 0, "explorer.exe", 1) _GUICtrlListView_SetItemText($hListView, 0, WinGetHandle($winHandleDesktop), 2) $cButtonselect = GUICtrlCreateButton("Select", 150, 345, 100, 40) $cButtonCancel = GUICtrlCreateButton("Cancel", 280, 345, 100, 40) GUIStartGroup() $cRadioWindow = GUICtrlCreateRadio("Whole window", 30, 345, 100, 20) $cRadioClient = GUICtrlCreateRadio("Client area only", 30, 365, 100, 20) GUICtrlSetState($cRadioWindow, $GUI_CHECKED) GUISetState() While Sleep(10) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $cButtonCancel Then Exit EndIf If $msg = $cButtonselect Then If _GUICtrlListView_GetSelectedCount($hListView) > 0 Then $aSelected = _GUICtrlListView_GetSelectedIndices($hListView, True) $hwnd_Source = HWnd(_GUICtrlListView_GetItemText($hListView, $aSelected[1], 2)) If WinExists($hwnd_Source) Then If GUICtrlRead($cRadioWindow) = $GUI_CHECKED Then $iClientAreaOnly = 0 Else $iClientAreaOnly = 1 EndIf GUISetState(@SW_HIDE, $guiWinList) If Not BitAND(WinGetState($hwnd_Source, ""), 2) Then WinSetState($hwnd_Source, "", @SW_SHOW) If $hwnd_Source = $winHandleDesktop Then $winTitle_Buffer = "SAT preview of the Desktop" Else $winTitle_Buffer = $winTitle_Buffer = "SAT preview of '" & WinGetTitle($hwnd_Source, "") & "'" EndIf _Show_Thumbnail() GUISetState(@SW_SHOW, $guiWinList) WinSetOnTop($guiWinList, "", 1) WinSetOnTop($guiWinList, "", 0) Else MsgBox(16, "Error", "Window not found...") EndIf Else MsgBox(64, "Select a Window", "You have to select a window to proced.") EndIf EndIf WEnd Func IsVisible($handle) If BitAND(WinGetState($handle), 2) And Not BitAND(_WinAPI_GetWindowLong($handle, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) And Not _WinAPI_GetParent($handle) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Func getIconHandleByFile($pszPath) ; http://www.autoitscript.com/forum/index.php?showtopic=40762&st=0&p=303247&hl=icon%20handle%20window&fromsearch=1&#entry303247 ; lod3n $SHGFI_ICON = 0x100 ;Get icon $SHGFI_SMALLICON = 0x1 ;Get Small Icon $dwFileAttributes = 0 $psfi = DllStructCreate("uint;int;dword;char[260];char[80]") ; thanks Holger! $cbSizeFileInfo = DllStructGetSize($psfi) $uFlags = BitOR($SHGFI_ICON, $SHGFI_SMALLICON) $hImgSmall = DllCall('shell32.dll', 'int', 'SHGetFileInfo', _ 'str', $pszPath, _ 'uint', $dwFileAttributes, _ 'ptr', DllStructGetPtr($psfi), _ 'uint', $cbSizeFileInfo, _ 'uint', $uFlags) Return DllStructGetData($psfi, 1) EndFunc ;==>getIconHandleByFile Func getIconHandleByHwnd($hwnd) ; http://www.autoitscript.com/forum/index.php?showtopic=40762&st=0&p=303247&hl=icon%20handle%20window&fromsearch=1&#entry303247 ; lod3n $hwnd = HWnd($hwnd) ;$WM_GETICON = 0x7F $GCL_HICONSM = -34 $GCL_HICON = -14 ;$IDI_APPLICATION = 32512 $hIcon = 0 $hIcon = _SendMessage($hwnd, $WM_GETICON, False, 0) If ($hIcon == 0) Then $hIcon = _SendMessage($hwnd, $WM_GETICON, True, 0) If ($hIcon == 0) Then $hIcon = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hwnd, "int", $GCL_HICONSM) $hIcon = $hIcon[0] EndIf If ($hIcon == 0) Then $hIcon = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hwnd, "int", $GCL_HICON) $hIcon = $hIcon[0] EndIf If ($hIcon == 0) Then $pid = WinGetProcess(HWnd($hwnd)) $path = getExePathByPid($pid) $hIcon = getIconHandleByFile($path) EndIf Return $hIcon EndFunc ;==>getIconHandleByHwnd Func getExePathByPid($pid) $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Return $objItem.ExecutablePath Next EndIf EndFunc ;==>getExePathByPid Func _Show_Thumbnail() Opt("GUIOnEventMode", 1) $hStub_MouseProc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hMO_Hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub_MouseProc), _WinAPI_GetModuleHandle(0)) $hStub_KeyProc = DllCallbackRegister("_Key_Proc", "long", "int;wparam;lparam") $hKB_Hook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), _WinAPI_GetModuleHandle(0)) If $iPID = 0 Then $iPID = WinGetProcess($hwnd_Source) $a_WinGetPosEx_Source = _WinGetPosEx($hwnd_Source) If @extended <> 1 Then MsgBox(16, "Error", "AERO not enabled on your system. Example will not work.") ;ProcessClose($iPID) Exit EndIf While Not BitAND(WinGetState($hwnd_Source, ""), 2) Sleep(10) WEnd $hwnd_Thumbnail = GUICreate($winTitle_Buffer, 100, 100, 100, 100, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) GUISetOnEvent($GUI_EVENT_CLOSE, "_exitGui") $hThumbID = _DWM_Thumbnail_Register($hwnd_Thumbnail, $hwnd_Source) If @error Then MsgBox(16, "Error", "Registration of Thumbnail failed.") _Exit() EndIf If _DwmQueryThumbnailSourceSize($hThumbID) = False Then MsgBox(16, "Error", "Thumbnail Source Size could not be determined.") _Exit() EndIf $iZoomFactor_Large = $iZoomFactor_Large_PX / $i_hwnd_Thumbnail_Width ; to set "large" thumbnail size to width = 300 $aWinGetPos = WinGetPos($hwnd_Thumbnail) _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True AdlibRegister("_check_GUI") Sleep(500) ; works for me, otherwise the inital thumb is resized / flickering a bit GUISetState() $bExitPreview = False Local Const $VK_ESC = 0x1B While Sleep(250) If Not ProcessExists($iPID) Or Not WinExists($hwnd_Source) Or $bExitPreview = True Then ExitLoop WEnd _Exit() EndFunc ;==>_Show_Thumbnail Func _exitGui() $bExitPreview = True EndFunc ;==>_exitGui Func _Exit() AdlibUnRegister("_check_GUI") If IsHWnd($hwnd_Thumbnail) Then WinSetState($hwnd_Thumbnail, "", @SW_HIDE) _DWM_Thumbnail_Unregister($hThumbID) _WinAPI_UnhookWindowsHookEx($hMO_Hook) DllCallbackFree($hStub_MouseProc) _WinAPI_UnhookWindowsHookEx($hKB_Hook) DllCallbackFree($hStub_KeyProc) GUIDelete($hwnd_Thumbnail) Opt("GUIOnEventMode", 0) EndFunc ;==>_Exit Func _check_GUI() If Not IsHWnd($hwnd_Thumbnail) Or Not IsHWnd($hwnd_Source) Then Return _check_GUI_Pos() If $winHandleDesktop <> $hwnd_Source Then If Not $winTitle_Buffer = "SAT preview of '" & WinGetTitle($hwnd_Source, "") & "'" Then $winTitle_Buffer = "SAT preview of '" & WinGetTitle($hwnd_Source, "") & "'" WinSetTitle($hwnd_Thumbnail, "", $winTitle_Buffer) EndIf EndIf If _WindowFromPoint() <> $hwnd_Thumbnail Then If $Big Then ;ConsoleWrite("_WinAPI_SetWindowLong: " & _WinAPI_SetWindowLong($hwnd_Thumbnail,$GWL_STYLE,$WS_POPUP) & @crlf) ;ConsoleWrite("_WinAPI_SetWindowLong: " & _WinAPI_SetWindowLong($hwnd_Thumbnail,$GWL_EXSTYLE,BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) & @crlf) $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $i_hwnd_Thumbnail_Height To $iZoomFactor_Small Step -$iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width GUISetState(@SW_HIDE, $hwnd_Thumbnail) _WinAPI_SetWindowLong($hwnd_Thumbnail, $GWL_STYLE, $WS_POPUP) _WinAPI_SetWindowLong($hwnd_Thumbnail, $GWL_EXSTYLE, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) GUISetState(@SW_SHOW, $hwnd_Thumbnail) $Big = False ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($iZoomFactor_Small / $i_hwnd_Thumbnail_Height), $iZoomFactor_Small) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf Else If Not $Big Then ;ConsoleWrite("NB _WinAPI_SetWindowLong: " & _WinAPI_SetWindowLong($hwnd_Thumbnail,$GWL_STYLE,$GUI_SS_DEFAULT_GUI) & @crlf) ;ConsoleWrite("NB _WinAPI_SetWindowLong: " & _WinAPI_SetWindowLong($hwnd_Thumbnail,$GWL_EXSTYLE,BitOR($WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) & @crlf) GUISetState(@SW_HIDE, $hwnd_Thumbnail) _WinAPI_SetWindowLong($hwnd_Thumbnail, $GWL_STYLE, 80478208) _WinAPI_SetWindowLong($hwnd_Thumbnail, $GWL_EXSTYLE, BitOR($WS_EX_TOPMOST, $WS_EX_CLIENTEDGE)) GUISetState(@SW_SHOW, $hwnd_Thumbnail) $iStep = $i_hwnd_Thumbnail_Height / 10 For $i = $iZoomFactor_Small To $i_hwnd_Thumbnail_Height Step $iStep _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width * ($i / $i_hwnd_Thumbnail_Height), $i) Next _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width $Big = True ElseIf $i_hwnd_Thumbnail_Height <> $i_hwnd_Thumbnail_Height_Save Or $i_hwnd_Thumbnail_Width <> $i_hwnd_Thumbnail_Width_Save Then ;source size changed _DWM_Thumbnail_Update_Properties($hThumbID, 0, 0, $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height, 255, True, $iClientAreaOnly) WinMove($hwnd_Thumbnail, "", $aWinGetPos[0], $aWinGetPos[1], $i_hwnd_Thumbnail_Width, $i_hwnd_Thumbnail_Height) $i_hwnd_Thumbnail_Height_Save = $i_hwnd_Thumbnail_Height $i_hwnd_Thumbnail_Width_Save = $i_hwnd_Thumbnail_Width EndIf EndIf EndFunc ;==>_check_GUI Func _check_GUI_Pos() $aWinGetPos = WinGetPos($hwnd_Thumbnail) $i_hwnd_Source_State = WinGetState($hwnd_Source, "") If BitAND($i_hwnd_Source_State, 2) And Not BitAND($i_hwnd_Source_State, 16) Then ; Update only if source is visible and not minimized _DwmQueryThumbnailSourceSize($hThumbID) $i_hwnd_Thumbnail_Width = $i_hwnd_Thumbnail_Width * $iZoomFactor_Large $i_hwnd_Thumbnail_Height = $i_hwnd_Thumbnail_Height * $iZoomFactor_Large ElseIf BitAND($i_hwnd_Source_State, 16) Then WinSetState($hwnd_Source, "", @SW_SHOWNOACTIVATE) EndIf EndFunc ;==>_check_GUI_Pos Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.ph...showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) ; x64 FIX! http://www.autoitscript.com/trac/autoit/ticket/1362 ; http://www.autoitscript.com/forum/index.php?showtopic=77831&view=findpost&p=768190 Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $pt = DllStructCreate("long;long") Local $pt64 = DllStructCreate("int64", DllStructGetPtr($pt)) DllStructSetData($pt, 1, MouseGetPos(0)) DllStructSetData($pt, 2, MouseGetPos(1)) Local $aRet = DllCall("User32.dll", "hwnd", "WindowFromPoint", _ "int64", DllStructGetData($pt64, 1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint Func _WindowDrag() DllCall("user32.dll", "int", "SendMessage", "hWnd", $hwnd_Thumbnail, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>_WindowDrag Func _DWM_Thumbnail_Register($hwnd, $hWndOw) $aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", 0) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Register thumbnail failed Return $aRet[3] EndFunc ;==>_DWM_Thumbnail_Register Func _DWM_Thumbnail_Unregister($hThumbID) $aRet = DllCall("dwmapi.dll", "int", "DwmUnregisterThumbnail", "hwnd", $hThumbID) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Unregister thumbnail failed Return $aRet[0] EndFunc ;==>_DWM_Thumbnail_Unregister Func _DWM_Thumbnail_Update_Properties($hThumbID, $rcDest_X, $rcDest_Y, $rcDest_Width, $rcDest_Height, $rcOpacity = 255, $rcReadOnly = True, $rcClientAreaOnly = 0) $tDWM_THUMBNAIL_PROPERTIES = DllStructCreate("dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;int fVisible;int fSourceClientAreaOnly") DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "dwFlags", BitOR($DWM_TNP_RECTDESTINATION, $DWM_TNP_OPACITY, $DWM_TNP_VISIBLE, $DWM_TNP_SOURCECLIENTAREAONLY)) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_X, 1) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Y, 2) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Width, 3) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Height, 4) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "opacity", $rcOpacity) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fVisible", $rcReadOnly) DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fSourceClientAreaOnly", $rcClientAreaOnly) $pDWM_THUMBNAIL_PROPERTIES = DllStructGetPtr($tDWM_THUMBNAIL_PROPERTIES) $aRet = DllCall("dwmapi.dll", "int", "DwmUpdateThumbnailProperties", "ptr", $hThumbID, "ptr", $pDWM_THUMBNAIL_PROPERTIES) If Not IsArray($aRet) Then Return SetError(1, 0, 0); Update thumbnail failed EndFunc ;==>_DWM_Thumbnail_Update_Properties Func _Mouse_Proc($nCode, $wParam, $lParam) ;$mouseData = DllStructGetData(DllStructCreate("int X;int Y" & ";dword mouseData", $lParam), 3) ;If $wParam = 0x020A Then $mouseEvent = BitShift($mouseData, 16) ; ConsoleWrite($nCode & @tab & $wParam & @tab & $lParam & @CRLF) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hMO_Hook, $nCode, $wParam, $lParam) EndIf If $wParam = 0x00000201 Then If TimerDiff($tTimer_Doubleclick) < 500 Then WinSetState($hwnd_Source, "", @SW_SHOW) WinSetOnTop($hwnd_Source, "", 1) WinSetOnTop($hwnd_Source, "", 0) EndIf If _WindowFromPoint() = $hwnd_Thumbnail Then $tTimer_Doubleclick = TimerInit() EndIf Return _WinAPI_CallNextHookEx($hMO_Hook, $nCode, $wParam, $lParam) EndFunc ;==>_Mouse_Proc Func _Key_Proc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hKB_Hook, $nCode, $wParam, $lParam) EndIf If $wParam = $WM_KEYDOWN And DllStructGetData($tKEYHOOKS, "vkCode") = 27 And _WindowFromPoint() = $hwnd_Thumbnail Then $bExitPreview = True ; ConsoleWrite("ESC pressed" & @crlf) Return _WinAPI_CallNextHookEx($hKB_Hook, $nCode, $wParam, $lParam) EndFunc ;==>_Key_Proc ; #FUNCTION# ======================================================= ; Name...........: _WinGetPosEx ; Description ...: Retrieves Window size and position similar to WinGetPos() but regards possible Aero effects on Vista and Win7 ; Syntax.........: _WinGetPosEx($hWnd) ; Parameters ....: $hWnd - Handle to Window to measure ; Return values .: Success: Returns a 4-element array containing the following information: ; $array[0] = X position ; $array[1] = Y position ; $array[2] = Width ; $array[3] = Height ; Sets @extended = 0 for Aero effect is OFF for $hWnd ; = 1 for Aero effect is ON for $hWnd ; ; Failure: Returns 0 and sets @error to 1 if windows is not found. ; Author ........: KaFu ; Link ..........; http://msdn.microsoft.com/en-us/library/aa969515%28VS.85%29.aspx ; Example .......; Yes ; ================================================================== Func _WinGetPosEx($hwnd) If Not IsHWnd($hwnd) Then Return SetError(1, 0, 0) Local $aPos[4], $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom") Local Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 DllCall("dwmapi.dll", "hwnd", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hwnd), "dword", $DWMWA_EXTENDED_FRAME_BOUNDS, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error Then Return SetError(0, 0, WinGetPos($hwnd)) Local $iRectLeft = DllStructGetData($tRect, "Left") Local $iRectTop = DllStructGetData($tRect, "Top") Local $iRectRight = DllStructGetData($tRect, "Right") Local $iRectBottom = DllStructGetData($tRect, "Bottom") If Abs($iRectLeft) + Abs($iRectTop) + Abs($iRectRight) + Abs($iRectBottom) > 0 Then $aPos[0] = $iRectLeft $aPos[1] = $iRectTop $aPos[2] = $iRectRight - $iRectLeft $aPos[3] = $iRectBottom - $iRectTop Return SetError(0, 1, $aPos) EndIf Return SetError(0, 0, WinGetPos($hwnd)) EndFunc ;==>_WinGetPosEx Func _DwmQueryThumbnailSourceSize($hThumbID) #cs http://msdn.microsoft.com/en-us/library/aa969520%28VS.85%29.aspx HRESULT DwmQueryThumbnailSourceSize( HTHUMBNAIL hThumbnail, PSIZE pSize ); typedef struct tagSIZE { LONG cx; LONG cy; }SIZE, *PSIZE; #ce $tSize = DllStructCreate("int X;int Y") $aRet = DllCall("dwmapi.dll", "hwnd", "DwmQueryThumbnailSourceSize", "hwnd", $hThumbID, "ptr", DllStructGetPtr($tSize)) If $aRet[0] = $S_OK Then $i_hwnd_Thumbnail_Width = DllStructGetData($tSize, 1) $i_hwnd_Thumbnail_Height = DllStructGetData($tSize, 2) Return True Else Return False EndIf EndFunc ;==>_DwmQueryThumbnailSourceSize OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
nullschritt Posted August 30, 2012 Share Posted August 30, 2012 Is there a way to use this dll to get the displayed content of a minimized window? Link to comment Share on other sites More sharing options...
KaFu Posted August 30, 2012 Share Posted August 30, 2012 No, for performance reasons the thumbnails are not refreshed using this public API for minimized windows. Though there has to be some undocumented way, as e.g. a thumbnail of the Windows Media Player is updated even minimized... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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