Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/18/2023 in all areas

  1. ioa747

    Get size of GUI

    there is something more . look and at https://www.autoitscript.com/forum/topic/209363-_systemmetricsparameterstoarray/ ; https://www.autoitscript.com/forum/topic/209707-get-size-of-gui/?do=findComment&comment=1513637 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Example", 200, 200, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) Global $DummyMenuEntry = GUICtrlCreateMenu("DummyMenuEntry", -1, $hGUI) GUIRegisterMsg($WM_SIZE, 'WM_SIZE') GUISetState(@SW_SHOW, $hGUI) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) Func WM_SIZE($hWnd, $iMsg, $iWParam, $iLParam) #forceref $hWnd, $iMsg, $iWParam Local $iGUIWidth1 = BitAND($iLParam, 0xFFFF) Local $iGUIHeight1 = BitShift($iLParam, 16) local $iGUIWidth2 = _WinGetPosAccuracy($hGUI)[2] local $iGUIHeight2 = _WinGetPosAccuracy($hGUI)[3] ConsoleWrite("GUIWidth : " & $iGUIWidth1 & " " & $iGUIWidth2 & " " & $iGUIWidth1 - $iGUIWidth2 & @CRLF ) ConsoleWrite("GUIHeight: " & $iGUIHeight1 & " " & $iGUIHeight2 & " " & $iGUIHeight1 - $iGUIHeight2 & @CRLF & @CRLF ) Return ($GUI_RUNDEFMSG) EndFunc ;==>WM_SIZE ;~ WinGetPos ;~ GUIWidth : 200 216 -16 ;~ GUIHeight: 180 239 -59 ;~ _WinGetPosAccuracy ;~ GUIWidth : 200 202 -2 ;~ GUIHeight: 180 232 -52 Func _WinGetPosAccuracy($hWnd) Local $HWPos[4] ; [0]=X [1]=Y [2]=Width [3]=Height If WinExists($hWnd) Then $HWPos[0] = _WindowDWMX($hWnd) $HWPos[1] = _WindowDWMY($hWnd) $HWPos[2] = _WindowDWMWidth($hWnd) $HWPos[3] = _WindowDWMHeight($hWnd) Else Return SetError(1, 0, "") EndIf Return $HWPos EndFunc ;==>_WinGetPosAccuracy #Region === a short extract from Pal, Peter's AutoIt Library, version 1.25 UDF === ; https://www.autoitscript.com/forum/topic/201518-pal-peters-autoit-functions-library/ ; #FUNCTION# ==================================================================================================================== ; Name...........: _WindowDWMWidth ; Description....: Returns window width as registered by the Desktop Window Manager (DWM) ; Syntax.........: _WindowDWMWidth($hGUI) ; Parameters.....: $hGUI - Window GUI handle ; Return values..: Desktop Window Manager window width ; Author.........: Peter Verbeek ; Modified.......: ; =============================================================================================================================== Func _WindowDWMWidth($hGUI) ; Try finding width by the Desktop Window Manager, Windows Vista and higher Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect) DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) ; Alternatively return window width by AutoIt Local $aWindow = WinGetPos($hGUI) If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window Return $aWindow[2] EndFunc ;==>_WindowDWMWidth ; #FUNCTION# ==================================================================================================================== ; Name...........: _WindowDWMHeight ; Description....: Returns window height as registered by the Desktop Window Manager (DWM) ; Syntax.........: _WindowDWMHeight($hGUI) ; Parameters.....: $hGUI - Window GUI handle ; Return values..: Desktop Window Manager window height ; Author.........: Peter Verbeek ; Modified.......: ; =============================================================================================================================== Func _WindowDWMHeight($hGUI) ; Try finding width by the Desktop Window Manager, Windows Vista and higher Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect) DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) ; Alternatively return window height by AutoIt Local $aWindow = WinGetPos($hGUI) If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window Return $aWindow[3] EndFunc ;==>_WindowDWMHeight ; #FUNCTION# ==================================================================================================================== ; Name...........: _WindowDWMX ; Description....: Returns window x coordinate as registered by the Desktop Window Manager (DWM) ; Syntax.........: _WindowDWMWidth($hGUI) ; Parameters.....: $hGUI - Window GUI handle ; Return values..: Desktop Window Manager window x coordinate ; Author.........: Peter Verbeek ; Modified.......: ; =============================================================================================================================== Func _WindowDWMX($hGUI) ; Try finding x coordinate by the Desktop Window Manager, Windows Vista and higher Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect) DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 1) ; Alternatively return window width by AutoIt Local $aWindow = WinGetPos($hGUI) If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window Return $aWindow[0] EndFunc ;==>_WindowDWMX ; #FUNCTION# ==================================================================================================================== ; Name...........: _WindowDWMY ; Description....: Returns window y coordinate as registered by the Desktop Window Manager (DWM) ; Syntax.........: _WindowDWMWidth($hGUI) ; Parameters.....: $hGUI - Window GUI handle ; Return values..: Desktop Window Manager window y coordinate ; Author.........: Peter Verbeek ; Modified.......: ; =============================================================================================================================== Func _WindowDWMY($hGUI) ; Try finding y coordinate by the Desktop Window Manager, Windows Vista and higher Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect) DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect)) If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 2) ; Alternatively return window width by AutoIt Local $aWindow = WinGetPos($hGUI) If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window Return $aWindow[1] EndFunc ;==>_WindowDWMY #EndRegion === a short extract from Pal, Peter's AutoIt Library, version 1.25 UDF ===
    1 point
  2. put variable infront msgbox an do If $var = 1 then.. from help file
    1 point
  3. sandin

    Msgbox and cancel button

    $return_value = MsgBox(4,"Shutting Down", "This computer will do something in a 10 seconds. Press NO to cancel",10) Switch $return_value case 1 ;OK ---> Flags: 0, 1 MsgBox(0, "Return Value", "OK") case 2 ;cancel ---> Flags: 1, 3, 5, 6 MsgBox(0, "Return Value", "Cancel") case 3 ;abort ---> Flags: 2 MsgBox(0, "Return Value", "Abort") case 4 ;retry ---> Flags: 2, 5 MsgBox(0, "Return Value", "Retry") case 5 ;Ignore ---> Flags: 2 MsgBox(0, "Return Value", "Ignore") case 6 ;Yes ---> Flags: 3, 4 MsgBox(0, "Return Value", "Yes") case 7 ;No ---> Flags: 3, 4 MsgBox(0, "Return Value", "No") case 10 ;Try Again ---> Flags: 6 MsgBox(0, "Return Value", "Try again") case 11 ;Continue ---> Flags: 6 MsgBox(0, "Return Value", "Continue") EndSwitch
    1 point
×
×
  • Create New...