Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/21/2024 in all areas

  1. ioa747

    Creates a rectangle frame

    ; https://www.autoitscript.com/forum/topic/211986-creates-a-rectangle-frame/ ;---------------------------------------------------------------------------------------- ; Title...........: _GuiFrame.au3 ; Description.....: Creates a rectangle frame ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WindowsConstants.au3> #include <WinAPIGdi.au3> ;Example: Global $aCoord, $hPoint, $hFrame = _GuiFrame("", 100, 100, 200, 200, 5, 0xFFFFFF, 255) ;********************************** Do $aCoord = PixelSearch(100, 100, 200, 200, 0xFFFFFF, 0, 1, 0) ;0xFFFFFF White If Not @error Then ConsoleWrite("found White at X,Y: " & $aCoord[0] & "," & $aCoord[1] & @CRLF) $hPoint = _GuiFrame("", $aCoord[0], $aCoord[1], $aCoord[0] + 1, $aCoord[1] + 1, 3, 0xFF0000) Sleep(4000) GUIDelete($hPoint) EndIf Sleep(10) Until GUIGetMsg() = -3 ; GUI_EVENT_CLOSE ;********************************** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GuiFrame ; Description....: Creates a rectangle frame ; Syntax.........: _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom [, $iThickness = 2 [, $iColor = 0xFF0000 [, $iTransparency = 150 [, $hWndParent = 0]]]]) ; Parameters.....: $sTitle - The title of frame. ; $iLeft - The left coordinate of frame. ; $iTop - The top coordinate of frame. ; $iRight - The right coordinate of frame. ; $iBottom - The bottom coordinate of frame. ; $iThickness - [optional] The thickness of frame (default = 1). ; $iColor - [optional] The color of frame (default = 0xFF0000). ; $iTransparency - [optional] The transparency of frame, in the range 1 - 255 (default = 150). ; $hWndParent - [optional] The parent window handle (default = 0). ; Return values..: The handle of the created frame. ; Author ........: ioa747 ; Notes .........: Note that coordinate, are the internal frame dimensions. ; Dependencies...: #include <WinAPIGdi.au3>, #include <WindowsConstants.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom, $iThickness = 1, $iColor = 0xFF0000, $iTransparency = 150, $hWndParent = 0) If $iThickness < 1 Or $iThickness = Default Then $iThickness = 1 If $iColor = -1 Or $iColor = Default Then $iColor = 0xFF0000 If $iTransparency < 1 Or $iTransparency = Default Or $iTransparency > 255 Then $iTransparency = 150 Local $iWidth = $iRight - $iLeft + (2 * $iThickness) + 1 Local $iHeight = $iBottom - $iTop + (2 * $iThickness) + 1 Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft - $iThickness, $iTop - $iThickness, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE), $hWndParent) GUISetBkColor($iColor, $hGUI) WinSetTrans($hGUI, "", $iTransparency) ;255 = Solid, 0 = Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hGUI) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $iWidth, $iHeight) $hInner_rgn = _WinAPI_CreateRectRgn($iThickness, $iThickness, $iWidth - $iThickness, $iHeight - $iThickness) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hInner_rgn) _WinAPI_SetWindowRgn($hGUI, $hCombined_rgn) Return $hGUI EndFunc ;==>_GuiFrame ;-------------------------------------------------------------------------------------------------------------------------------- Another example #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> _Example1() Func _Example1() Local $iGuiFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) Local $iThickness = 10 Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi! Move this window around'')"') Local $hWnd = WinWaitActive('Hello World!', '', 3) Local $aPos = WinGetPos($hWnd) Local $iLeft = $aPos[0] + $iGuiFrame Local $iTop = $aPos[1] Local $iRight = $aPos[0] + $aPos[2] - $iGuiFrame Local $iBottom = $aPos[1] + $aPos[3] - $iGuiFrame Local $hFrame = _GuiFrame("", $iLeft, $iTop, $iRight, $iBottom, $iThickness, 0xFF0000, 150, $hWnd) ConsoleWrite("$hFrame=" & $hFrame & @CRLF) Local $sStrPos While WinExists($hWnd) $aPos = WinGetPos($hWnd) If $sStrPos <> $aPos[0] & ";" & $aPos[1] Then WinMove($hFrame, '', $aPos[0] - $iThickness + $iGuiFrame, $aPos[1] - $iThickness) $sStrPos = $aPos[0] & ";" & $aPos[1] EndIf Sleep(10) WEnd EndFunc ;==>_Example1 ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GuiFrame ; Description....: Creates a rectangle frame ; Syntax.........: _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom [, $iThickness = 2 [, $iColor = 0xFF0000 [, $iTransparency = 150 [, $hWndParent = 0]]]]) ; Parameters.....: $sTitle - The title of frame. ; $iLeft - The left coordinate of frame. ; $iTop - The top coordinate of frame. ; $iRight - The right coordinate of frame. ; $iBottom - The bottom coordinate of frame. ; $iThickness - [optional] The thickness of frame (default = 1). ; $iColor - [optional] The color of frame (default = 0xFF0000). ; $iTransparency - [optional] The transparency of frame, in the range 1 - 255 (default = 150). ; $hWndParent - [optional] The parent window handle (default = 0). ; Return values..: The handle of the created frame. ; Author ........: ioa747 ; Notes .........: Note that coordinate, are the internal frame dimensions. ; Dependencies...: #include <WinAPIGdi.au3>, #include <WindowsConstants.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom, $iThickness = 1, $iColor = 0xFF0000, $iTransparency = 150, $hWndParent = 0) If $iThickness < 1 Or $iThickness = Default Then $iThickness = 1 If $iColor = -1 Or $iColor = Default Then $iColor = 0xFF0000 If $iTransparency < 1 Or $iTransparency = Default Or $iTransparency > 255 Then $iTransparency = 150 Local $iWidth = $iRight - $iLeft + (2 * $iThickness) + 1 Local $iHeight = $iBottom - $iTop + (2 * $iThickness) + 1 Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft - $iThickness, $iTop - $iThickness, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_NOACTIVATE), $hWndParent) GUISetBkColor($iColor, $hGUI) WinSetTrans($hGUI, "", $iTransparency) ;255 = Solid, 0 = Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hGUI) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $iWidth, $iHeight) $hInner_rgn = _WinAPI_CreateRectRgn($iThickness, $iThickness, $iWidth - $iThickness, $iHeight - $iThickness) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hInner_rgn) _WinAPI_SetWindowRgn($hGUI, $hCombined_rgn) Return $hGUI EndFunc ;==>_GuiFrame ;-------------------------------------------------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
  2. ioa747

    Creates a rectangle frame

    and one with Hover effect #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> ; get height of window title and width of window frame - may be different when XP theme is ON/OFF Global $iGuiMetricsTitle = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Global $iGuMetricsiFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) Global $bInfo = False ; *** <-- True = more ConsoleWrite info Global $g_idMemo, $MyGui, $a_idBtn[7] Example() ;-------------------------------------------------------------------------------------------------------------------------------- Func Example() $MyGui = GUICreate("Button Get/Set ImageList (v" & @AutoItVersion & ")", 510, 400) $g_idMemo = GUICtrlCreateEdit("", 119, 10, 376, 374, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) $a_idBtn[0] = 6 Local $y = 20, $iWidth = 90, $iHeight = 50 For $x = 1 To $a_idBtn[0] $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x, 10, $y, $iWidth, $iHeight) $y += 60 Next Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $a_idBtn[1] To $a_idBtn[$a_idBtn[0]] MemoWrite("cklick " & GUICtrlRead($a_idBtn[$iMsg - $a_idBtn[1] + 1])) EndSwitch _Hover() Sleep(10) WEnd Exit EndFunc ;==>Example ;-------------------------------------------------------------------------------------------------------------------------------- Func _Hover($iThickness = 5, $FrameColor = 0x00FFFF, $iTransparency = 100) Local Static $iActive, $hFrame If Not WinActive($MyGui) Then Return SetError(1, 0, False) Local $ActiveCtrl Local $aCtrl = GUIGetCursorInfo($MyGui) $ActiveCtrl = IsArray($aCtrl) ? $aCtrl[4] : 0 If $iActive <> $ActiveCtrl Then $iActive = $ActiveCtrl DW("> $iActive=" & $iActive & @CRLF) Local $Msg ;if frame exist => obsolete => FrameDelete If $hFrame Then $Msg = GUIDelete($hFrame) DW("!! ObsoleteFrameDelete(" & $hFrame & ")=" & $Msg & @CRLF) $hFrame = Null EndIf ;Rule1 $ActiveCtrl = 0 => Return If $ActiveCtrl = 0 Then DW("<< $ActiveCtrl = 0" & @CRLF & @CRLF) Return SetError(2, 0, False) EndIf ;Rule2 if not $a_idBtn => Return If $ActiveCtrl < $a_idBtn[1] Or $ActiveCtrl > $a_idBtn[$a_idBtn[0]] Then DW("<< Only from:" & $a_idBtn[1] & " to:" & $a_idBtn[$a_idBtn[0]] & @CRLF & @CRLF) Return SetError(3, 0, False) EndIf ;recheck obsoleteFrameDelete If $hFrame Then $Msg = GUIDelete($hFrame) DW("!!!! recheck ObsoleteFrameDelete(" & $hFrame & ")=" & $Msg & @CRLF) EndIf Local $aPos = WinGetPos($MyGui) Local $sName = GUICtrlRead($ActiveCtrl) Local $aCtrlPos = ControlGetPos($MyGui, '', $ActiveCtrl) Local $iLeft = $iGuMetricsiFrame + $aPos[0] + $aCtrlPos[0] Local $iTop = $iGuMetricsiFrame + $iGuiMetricsTitle + $aPos[1] + $aCtrlPos[1] Local $iRight = $aCtrlPos[2] Local $iBottom = $aCtrlPos[3] DW("- Ctrl:" & $ActiveCtrl & " | Name:" & $sName & " | X,Y,W,H: " & $aCtrlPos[0] & ", " & $aCtrlPos[1] & ", " & $aCtrlPos[2] & ", " & $aCtrlPos[3] & _ " | WinPos: " & $aPos[0] & ", " & $aPos[1] & ", " & $aPos[2] & ", " & $aPos[3] & @CRLF) $hFrame = _GuiFrame("frame_" & $sName, $iLeft, $iTop, $iRight, $iBottom, $iThickness, $FrameColor, $iTransparency, $MyGui, 1) ;normal DW("+ NewFrame: " & $hFrame & " : " & $iLeft & ", " & $iTop & ", " & $iRight & ", " & $iBottom & @CRLF & @CRLF) EndIf Sleep(10) EndFunc ;==>_Hover ;-------------------------------------------------------------------------------------------------------------------------------- Func MemoWrite($sMessage) ; Write a line to the memo control GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ;-------------------------------------------------------------------------------------------------------------------------------- Func DW($sText) If Not $bInfo Then Return ConsoleWrite($sText) EndFunc ;==>DW ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GuiFrame ; Description....: Creates a rectangle frame ; Syntax.........: _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom [, $iThickness = 2 [, $iColor = 0xFF0000 [, $iTransparency = 150 [, $hWndParent = 0 [, $iFlag = 0 ]]]]]) ; Parameters.....: $sTitle - The title of frame. ; $iLeft - The left coordinate of frame. ; $iTop - The top coordinate of frame. ; $iRight - The right coordinate of frame. ; $iBottom - The bottom coordinate of frame. ; $iThickness - [optional] The thickness of frame (default = 1). ; $iColor - [optional] The color of frame (default = 0xFF0000). ; $iTransparency - [optional] The transparency of frame, in the range 1 - 255 (default = 150). ; $hWndParent - [optional] The parent window handle (default = 0). ; $iFlag - [optional] $iFlag=0 $iRight=$iRight and $iBottom=$iBottom (default = 0). ; $iFlag=1 $iRight=$iWidth and $iBottom=$iHeight ; Return values..: The handle of the created frame. ; Author ........: ioa747 ; Notes .........: Note that coordinate, are the internal frame dimensions. ; Dependencies...: #include <WinAPIGdi.au3>, #include <WindowsConstants.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom, $iThickness = 1, $iColor = 0xFF0000, $iTransparency = 150, $hWndParent = 0, $iFlag = 0) If $iThickness < 1 Or $iThickness = Default Then $iThickness = 1 If $iColor = -1 Or $iColor = Default Then $iColor = 0xFF0000 If $iTransparency < 1 Or $iTransparency = Default Or $iTransparency > 255 Then $iTransparency = 150 Local $iWidth, $iHeight If $iFlag = 1 Then ; $iFlag=1 $iRight=$iWidth and $iBottom=$iHeight $iWidth = $iRight + (2 * $iThickness) $iHeight = $iBottom + (2 * $iThickness) Else $iFlag = 0 $iWidth = $iRight - $iLeft + (2 * $iThickness) + 1 $iHeight = $iBottom - $iTop + (2 * $iThickness) + 1 EndIf Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft - $iThickness, $iTop - $iThickness, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_NOACTIVATE), $hWndParent) GUISetBkColor($iColor, $hGUI) WinSetTrans($hGUI, "", $iTransparency) ;255 = Solid, 0 = Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hGUI) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $iWidth, $iHeight) $hInner_rgn = _WinAPI_CreateRectRgn($iThickness, $iThickness, $iWidth - $iThickness, $iHeight - $iThickness) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hInner_rgn) _WinAPI_SetWindowRgn($hGUI, $hCombined_rgn) Return $hGUI EndFunc ;==>_GuiFrame ;-------------------------------------------------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
×
×
  • Create New...