-
Posts
76 -
Joined
-
Last visited
Everything posted by SEKOMD
-
Hello everyone!!! I'll tell you right away - most likely my task is impossible to solve. However, perhaps I will be lucky. Is there any way to move or change the position of an already created region? is this impossible or maybe I don't know something? I mean changing the location of a region (new x y) that has already been created. It seems unrealistic. But it would be cool!! #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> $hGUI = GUICreate('Move region - is it possible.. ?', 600, 600) GUISetBkColor($COLOR_RED, $hGUI) GUISetState(@SW_SHOW, $hGUI) Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80 $hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight) Global $x = 120, $y = 120, $iWidth = 80, $iHeight = 80 $hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight) $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3]) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3) ;help me ;how to move region? ;ex. _WinAPI_MoveRgn ... (set new iX iY) ;ex. _WinAPI_RgnSetPos ... (set new iX iY) ;any ideas? _WinAPI_SetWindowRgn($hGUI, $hCombinedRgn) _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hCombinedRgn) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Sorry for my English!
-
Web driver not starting
SEKOMD replied to CaptainBeardsEyesBeard's topic in AutoIt General Help and Support
Please tell me why I need to specify the port twice? _WD_Option('Port', '9515') _WD_Option('DriverParams', '--port=9515 --log-path="' & @ScriptDir & '\chrome.log"') sorry my English! -
Please tell me why this code doesn't work? #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPICom.au3> #include <WinAPI.au3> #include <WinAPI.au3> Global $hGui ; Project includes #include "Includes\WV2Interfaces.au3" WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate( "WebView2 Sample", 600, 300, -1, -1, $WS_OVERLAPPEDWINDOW ) ; Create Button Local $idButton = GUICtrlCreateButton( "ExecuteScript", 10, 250, 170, 40 ) ; Initialize COM _WinAPI_CoInitialize( $COINIT_APARTMENTTHREADED ) ; Create callback interfaces and functions CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate( True ) ; Forces CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke() below to be executed CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate( True ) CoreWebView2ExecuteScriptCompletedHandlerCreate( True ) ; DllCall CreateCoreWebView2EnvironmentWithOptions Local $hWebView2Loader = DllOpen( @AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll" ) Local $aRet = DllCall( $hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", "", _ "ptr", NULL, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ) If @error Or $aRet[0] Then Return ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF ) ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions OK" & @CRLF & @CRLF ) ; Show WebView2 GUI GUISetState( @SW_SHOW ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED, $GUI_EVENT_RESTORE Local $tRect = _WinAPI_GetClientRect( $hGui ) $oCoreWebView2Controller.put_Bounds( $tRect ) Case $idButton ;$oCoreWebView2.NavigateToString('<h2>testting</h2>') ;$oCoreWebView2.ExecuteScript("document.documentElement.innerHTML", $pCoreWebView2ExecuteScriptCompletedHandler) $oCoreWebView2.get_Source($pCoreWebView2WebMessageReceivedEventHandler) ;??? Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() DllClose( $hWebView2Loader ) EndFunc Func CoreWebView2WebMessageReceivedEventHandler_Invoke( $pSelf, $ptr1, $ptr2 ) ; Ret: long Par: ptr*;ptr* ConsoleWrite( "CoreWebView2WebMessageReceivedEventHandler_Invoke()" & @CRLF & @CRLF ) ; Create CoreWebView2WebMessageReceivedEventArgs object $oCoreWebView2WebMessageReceivedEventArgs = ObjCreateInterface( $ptr2, $sIID_ICoreWebView2WebMessageReceivedEventArgs, $dtag_ICoreWebView2WebMessageReceivedEventArgs ) ConsoleWrite( "IsObj( $oCoreWebView2WebMessageReceivedEventArgs ) = " & IsObj( $oCoreWebView2WebMessageReceivedEventArgs ) & @CRLF ) $oCoreWebView2WebMessageReceivedEventArgs.AddRef() ; Prevent the object from being deleted when the function ends ; Get WebMessage information Local $sWebMessage $oCoreWebView2WebMessageReceivedEventArgs.TryGetWebMessageAsString( $sWebMessage ) ConsoleWrite( "$sWebMessage = " & $sWebMessage & @CRLF & @CRLF ) MsgBox(64,'','Result: ' & $sWebMessage) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $ptr1 EndFunc Func CoreWebView2ExecuteScriptCompletedHandler_Invoke($pSelf, $hresult, $wstr) #forceref $pSelf, $hresult, $wstr If $hresult = 0 Then MsgBox(64,'','source: ' & $wstr) Else ConsoleWrite("error: " & $hresult & @CRLF) EndIf EndFunc ; Copied from WV2Interfaces.au3 ; Executed automatically when the callback interface is created Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke" & @CRLF ) ; Create CoreWebView2Environment object $oCoreWebView2Environment = ObjCreateInterface( $ptr, $sIID_ICoreWebView2Environment, $dtag_ICoreWebView2Environment ) ConsoleWrite( "IsObj( $oCoreWebView2Environment ) = " & IsObj( $oCoreWebView2Environment ) & @CRLF & @CRLF ) ; Set $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler callback pointer for the WebView2 GUI $oCoreWebView2Environment.CreateCoreWebView2Controller( $hGui, $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler ) ; Forces CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke() below to be executed Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2Environment.CreateCoreWebView2Controller() above Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke" & @CRLF ) ; Create CoreWebView2Controller object $oCoreWebView2Controller = ObjCreateInterface( $ptr, $sIID_ICoreWebView2Controller, $dtag_ICoreWebView2Controller ) ConsoleWrite( "IsObj( $oCoreWebView2Controller ) = " & IsObj( $oCoreWebView2Controller ) & @CRLF ) $oCoreWebView2Controller.AddRef() ; Prevent the object from being deleted when the function ends ; Set bounds for the CoreWebView2 object Local $tRect = _WinAPI_GetClientRect( $hGui ) $oCoreWebView2Controller.put_Bounds( $tRect ) ; Create CoreWebView2 object $oCoreWebView2Controller.get_CoreWebView2( $pCoreWebView2 ) $oCoreWebView2 = ObjCreateInterface( $pCoreWebView2, $sIID_ICoreWebView2, $dtag_ICoreWebView2 ) ConsoleWrite( "IsObj( $oCoreWebView2 ) = " & IsObj( $oCoreWebView2 ) & @CRLF & @CRLF ) ; Navigate to web page $oCoreWebView2.NavigateToString( _GetPage() ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc Func _GetPage() Local $sPageSource = "" $sPageSource &= "<h2>testting</h2>" & @CRLF Return $sPageSource EndFunc I read the whole topic and realized that it is impossible, it's a pity, I had hoped...
-
managed to extract the source code (thanks chatgpt), but it's kind of weird, how to convert it to normal? #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPICom.au3> #include <WinAPI.au3> #include <WinAPI.au3> Global $hGui ; Project includes #include "Includes\WV2Interfaces.au3" WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate( "WebView2 Sample", 600, 300, -1, -1, $WS_OVERLAPPEDWINDOW ) ; Create Button Local $idButton = GUICtrlCreateButton( "ExecuteScript", 10, 250, 170, 40 ) ; Initialize COM _WinAPI_CoInitialize( $COINIT_APARTMENTTHREADED ) ; Create callback interfaces and functions CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate( True ) ; Forces CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke() below to be executed CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate( True ) CoreWebView2ExecuteScriptCompletedHandlerCreate( True ) ; DllCall CreateCoreWebView2EnvironmentWithOptions Local $hWebView2Loader = DllOpen( @AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll" ) Local $aRet = DllCall( $hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", "", _ "ptr", NULL, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ) If @error Or $aRet[0] Then Return ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF ) ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions OK" & @CRLF & @CRLF ) ; Show WebView2 GUI GUISetState( @SW_SHOW ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED, $GUI_EVENT_RESTORE Local $tRect = _WinAPI_GetClientRect( $hGui ) $oCoreWebView2Controller.put_Bounds( $tRect ) Case $idButton ;$oCoreWebView2.NavigateToString('<h2>testting</h2>') $oCoreWebView2.ExecuteScript("document.documentElement.innerHTML", $pCoreWebView2ExecuteScriptCompletedHandler) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() DllClose( $hWebView2Loader ) EndFunc Func CoreWebView2ExecuteScriptCompletedHandler_Invoke($pSelf, $hresult, $wstr) #forceref $pSelf, $hresult, $wstr If $hresult = 0 Then MsgBox(64,'','source: ' & $wstr) Else ConsoleWrite("error: " & $hresult & @CRLF) EndIf EndFunc ; Copied from WV2Interfaces.au3 ; Executed automatically when the callback interface is created Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke" & @CRLF ) ; Create CoreWebView2Environment object $oCoreWebView2Environment = ObjCreateInterface( $ptr, $sIID_ICoreWebView2Environment, $dtag_ICoreWebView2Environment ) ConsoleWrite( "IsObj( $oCoreWebView2Environment ) = " & IsObj( $oCoreWebView2Environment ) & @CRLF & @CRLF ) ; Set $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler callback pointer for the WebView2 GUI $oCoreWebView2Environment.CreateCoreWebView2Controller( $hGui, $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler ) ; Forces CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke() below to be executed Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2Environment.CreateCoreWebView2Controller() above Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke" & @CRLF ) ; Create CoreWebView2Controller object $oCoreWebView2Controller = ObjCreateInterface( $ptr, $sIID_ICoreWebView2Controller, $dtag_ICoreWebView2Controller ) ConsoleWrite( "IsObj( $oCoreWebView2Controller ) = " & IsObj( $oCoreWebView2Controller ) & @CRLF ) $oCoreWebView2Controller.AddRef() ; Prevent the object from being deleted when the function ends ; Set bounds for the CoreWebView2 object Local $tRect = _WinAPI_GetClientRect( $hGui ) $oCoreWebView2Controller.put_Bounds( $tRect ) ; Create CoreWebView2 object $oCoreWebView2Controller.get_CoreWebView2( $pCoreWebView2 ) $oCoreWebView2 = ObjCreateInterface( $pCoreWebView2, $sIID_ICoreWebView2, $dtag_ICoreWebView2 ) ConsoleWrite( "IsObj( $oCoreWebView2 ) = " & IsObj( $oCoreWebView2 ) & @CRLF & @CRLF ) ; Navigate to web page $oCoreWebView2.NavigateToString( _GetPage() ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc Func _GetPage() Local $sPageSource = "" $sPageSource &= "<h2>testting</h2>" & @CRLF Return $sPageSource EndFunc sorry my english!
-
how to get the source code of a page? don't work: Local $sSource $sSource = $oCoreWebView2.get_Source() MsgBox(64,'',$sSource)
-
IUIAutomation MS framework automate chrome, FF, IE, ....
SEKOMD replied to junkew's topic in AutoIt Example Scripts
Case "getValue" $obj2ActOn.setfocus() Send("^a") Sleep(50) Send("^c") $retValue = ClipGet() only keyboard keys are used - this is not always convenient/reliable when selecting text - for example, the input focus is lost.. -
IUIAutomation MS framework automate chrome, FF, IE, ....
SEKOMD replied to junkew's topic in AutoIt Example Scripts
I found a great function and I'm surprised that your library doesn't have a similar function. Why not? Sending keyboard presses (CTRL + C) is not convenient/suitable for everyone... Func UIA_GetAeCurrentPropertyValue($oAe, $PropertyID) If Not IsObj($UIA_oUIAutomation) Then Return SetError(1) If Not IsObj($oAe) Then Return SetError(2) Local $tVal $oAe.GetCurrentPropertyValue($PropertyID, $tVal) If Not IsArray($tVal) Then Return $tVal Local $tStr = $tVal[0] For $i = 1 To UBound($tVal) - 1 $tStr &= "; " & $tVal[$i] Next Return $tStr EndFunc ;==>UIA_GetAeCurrentPropertyValue https://www.autoitscript.com/forum/topic/211768-automate-combobox-using-ui-automation/ Sorry for my English!!! -
WinSetOnTop and child window - don't work
SEKOMD replied to SEKOMD's topic in AutoIt General Help and Support
ioa747 Bravo, maestro! Thank you very much!! -
Hello everyone! Please tell me how to make the child window $hGUI_Parent1 always be on top of other child windows? Sorry for my english( #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <Constants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate('MAIN WINDOW', 600, 600, 200, 200, $WS_POPUP+$WS_SIZEBOX) ;$WS_SIZEBOX - don't work $hGUI_Parent1 = GUICreate('PARENT 1', 200, 200, 20, 20, $WS_POPUP) $hGUI_Parent2 = GUICreate('PARENT 2', 200, 200, 80, 80, $WS_POPUP) GUISetBkColor($COLOR_GREEN, $hGUI) GUISetBkColor($COLOR_RED, $hGUI_Parent1) GUISetBkColor($COLOR_GRAY, $hGUI_Parent2) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Parent1) GUISetState(@SW_SHOW, $hGUI_Parent2) _WinAPI_SetParent($hGUI_Parent1,$hGUI) _WinAPI_SetParent($hGUI_Parent2,$hGUI) WinSetOnTop($hGUI_Parent1,'',1) ; << don't work While Sleep(5) ;WinActivate($hGUI_Parent1) ;questionable decision.. Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd
-
Please help improve the function (_GDIPlus, draw text)
SEKOMD replied to SEKOMD's topic in AutoIt General Help and Support
thank you, very useful example! -
Hi all! Please help me improve the function code. I can't figure out _GDIPlus at all(( (Coded by UEZ) - when changing the window size - the text disappears; - how to remove flickering when text is frequently updated (flickering is not very frequent); ;Coded by UEZ #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <WinApi.au3> #include <ColorConstants.au3> #include <Misc.au3> #include <Array.au3> #include <WinAPISysWin.au3> HotKeySet('{ESC}', '_ButtonExit') Func _ButtonExit() Exit EndFunc ;==>_ButtonExit _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hGUI = GUICreate("GDI+ Test", 800, 400,Default,Default,$WS_SIZEBOX) GUISetBkColor(0x505050) Global Const $iPicBtn = GUICtrlCreatePic("", 50, 28, 100, 44) GUISetState() Global $aMouseInfo, $bShow = False, $bHide = False ;======== Flickering and text disappears when resizing ============================= While 1 $aButtons = _GDIPlus_BitmapCreateRoundedButtonAndText("AutoIt MSEC:" & @MSEC, 600,200) _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) ;_WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) ;_WinAPI_RedrawWindow($hGUI, 0, 0, BitOR($RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) _WinAPI_InvalidateRgn($hGUI,Default,0) _WinAPI_RedrawWindow($hGUI) WEnd ;==================================================================== Do If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $iPicBtn _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) $bShow = True $bHide = False Case Else _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) $bHide = True $bShow = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($aButtons[0]) _WinAPI_DeleteObject($aButtons[1]) _GDIPlus_Shutdown() Exit Case $iPicBtn MsgBox(0, "Information", "Button pressed") EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateRoundedButtonAndText ; Description ...: Draw rounded button ; Syntax ........: _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2025-01-12 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 86, $sFont = "Tahoma", $iHoverColor = 0xF0FFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[1], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) ;, $hBrushBGColor = _GDIPlus_BrushCreateSolid($iBgColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, $iFrameSize), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) _GDIPlus_PathStartFigure($hPath) Local $fArcSize = $iWidth * 0.11 _GDIPlus_PathAddArc($hPath, $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, 180, -90) ;BR _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, -270, -90) ;BL _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, 0, -90) ;TR _GDIPlus_PathAddArc($hPath, $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, -90, -90) ;TL _GDIPlus_PathCloseFigure($hPath) Local Const $hPath_Clone = _GDIPlus_PathClone($hPath) Local Const $hBrushBGColor = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetSurroundColor($hBrushBGColor, $iBgColor) _GDIPlus_PathBrushSetCenterColor($hBrushBGColor, 0xFFFFFFFF) _GDIPlus_PathBrushSetCenterPoint($hBrushBGColor, $iWidth / 2, $iHeight / 2) _GDIPlus_PathBrushSetSigmaBlend($hBrushBGColor, 1, 0.02) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushBGColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) _GDIPlus_PathReset($hPath) ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawPath($aGfxCtxt[1], $hPath_Clone, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_PathDispose($hPath_Clone) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_BrushDispose($hBrushBGColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc ;==>_GDIPlus_BitmapCreateRoundedButtonAndText sorry my English..!
-
Hi all! Please tell me how to make sure that the text does not disappear after minimizing/maximizing the window? #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hGraphics,4) _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 200, "Tahoma", 66) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example
-
Hello everyone! I found a working example of a _GDIPlus button on the forum. But how do I make rounded edges on the button? (square) Thanks in advance! sorry for my english please! #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Global $hGraphic, $hBrush, $hBrushFont, $hFont, $hFormat, $hFamily, $hGUI, $tRect_Coords[4] ;would be used in two functions therefore declared as global. Global $iTheme = 0 Example() Func Example() ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) ; Fill a rectangle _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBrush = _GDIPlus_BrushCreateSolid(0xAA43A6DF) $hBrushFont = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Light") $hFont = _GDIPlus_FontCreate($hFamily, 20, 2) $tRect_Coords[0] = 10 $tRect_Coords[1] = 10 $tRect_Coords[2] = 100 $tRect_Coords[3] = 100 ;Register for painting GUIRegisterMsg($WM_PAINT, "WM_PAINT") ;$WM_PAINT GUISetState() ; Loop until the user exits. Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN If CheckPointer($tRect_Coords) Then SetTheme(1) Case $GUI_EVENT_PRIMARYUP SetTheme(0) Case $GUI_EVENT_MOUSEMOVE If GetTheme() = 1 Then ContinueLoop If CheckPointer($tRect_Coords) Then SetTheme(2) Else SetTheme(0) EndIf EndSwitch Until 0 ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrushFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example Func WM_PAINT($hGUI, $iMsg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) ;Your Code must lie below ;Paint the string _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) _GDIPlus_GraphicsFillRect($hGraphic, $tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3], $hBrush) _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, _GDIPlus_RectFCreate($tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3]), $hFormat, $hBrushFont) ;End of your code _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return 0;'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT Func CheckPointer(ByRef $aiCoords_ClientRel) Return _WinAPI_PtInRectEx(_WinAPI_GetMousePosX(True, $hGUI), _WinAPI_GetMousePosY(True, $hGUI), $aiCoords_ClientRel[0], $aiCoords_ClientRel[1], $aiCoords_ClientRel[2] + $aiCoords_ClientRel[0], $aiCoords_ClientRel[3] + $aiCoords_ClientRel[1]) EndFunc ;==>CheckPointer Func GetTheme() Return $iTheme EndFunc ;==>GetTheme Func SetTheme($Theme, $f_Redraw = true) If GetTheme() = $Theme Then Return 1 If $Theme = 0 Then ;Idle _GDIPlus_BrushSetSolidColor($hBrush, 0xAA43A6DF) _GDIPlus_BrushSetSolidColor($hBrushFont, 0xFFFFFFFF) ;Default Dimensions $tRect_Coords[0] = 10 $tRect_Coords[1] = 10 $tRect_Coords[2] = 100 $tRect_Coords[3] = 100 ElseIf $Theme = 1 Then ;MouseDown _GDIPlus_BrushSetSolidColor($hBrush, 0xFF3685B2) _GDIPlus_BrushSetSolidColor($hBrushFont, 0xFFFFFFFF) ;Compress a Bit $tRect_Coords[0] = 12 $tRect_Coords[1] = 12 $tRect_Coords[2] = 96 $tRect_Coords[3] = 96 ElseIf $Theme = 2 Then ;MouseOver _GDIPlus_BrushSetSolidColor($hBrush, 0xBB7BC1E9) _GDIPlus_BrushSetSolidColor($hBrushFont, 0xFFFFFFFF) ;Enlarge a Bit $tRect_Coords[0] = 8 $tRect_Coords[1] = 8 $tRect_Coords[2] = 104 $tRect_Coords[3] = 104 Else Return SetError(1, 0, 0) EndIf $iTheme = $Theme ConsoleWrite("CurTheme: " & $iTheme & @CRLF) If $f_Redraw Then _WinAPI_RedrawWindow($hGUI, 0, 0, BitOR($RDW_INTERNALPAINT, $RDW_ERASE)) endfunc ;==>SetTheme
-
pixelsearch, ioa747 thank you for trying to help!!! It seems to me that it is impossible to remove the rest of the header. That would be great though. (painting in one color is not suitable) For now, the solution is to create a separate shadow (maybe someone find it useful): #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <GDIPlus.au3> #include <WinAPISysWin.au3> ;exit func HotKeySet('{ESC}', 'Terminate') Func Terminate() Exit EndFunc ;==>Terminate $hGUI_Shadow = GUICreate('', 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) $hGUI = GUICreate('', 400, 400, 300, 300, $WS_POPUP, Default, $hGUI_Shadow) GUISetBkColor($COLOR_RED, $hGUI) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Shadow) ;create shadow :) _GDIPlus_Startup() _WinAPI_UpdateLayeredWindowEx($hGUI_Shadow, 300-20, 300-20, _CreateDropShadow(400, 400, 20, 0xFF000000), 60, 1) _GDIPlus_Shutdown() While Sleep(1000) WEnd ;============== code by Yashied (author) ==================== Func _CreateDropShadow($iWidth, $iHeight, $iRadius, $iARGB = 0) Local $hGraphic, $hBrush, $hImage, $hBitmap Local $aPart[4][5] = _ [[$iRadius, 0, $iWidth, $iRadius, -90], _ [$iWidth + $iRadius, $iRadius, $iRadius, $iHeight, 0], _ [$iRadius, $iHeight + $iRadius, $iWidth, $iRadius, 90], _ [0, $iRadius, $iRadius, $iHeight, 180]] $hImage = _GDIPlus_BitmapCreateFromScan0($iWidth + 2 * $iRadius, $iHeight + 2 * $iRadius) If Not $hImage Then Return 0 EndIf $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsClear($hGraphic, 0) $hBrush = _GDIPlus_BrushCreateSolid($iARGB) _GDIPlus_GraphicsFillRect($hGraphic, $iRadius, $iRadius, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDrawRadialGradient($hGraphic, $iRadius, $iRadius, $iRadius, $iARGB, BitAND($iARGB, 0x00FFFFFF), -180, -90) _GDIPlus_GraphicsDrawRadialGradient($hGraphic, $iWidth + $iRadius, $iRadius, $iRadius, $iARGB, BitAND($iARGB, 0x00FFFFFF), -90, 0) _GDIPlus_GraphicsDrawRadialGradient($hGraphic, $iWidth + $iRadius, $iHeight + $iRadius, $iRadius, $iARGB, BitAND($iARGB, 0x00FFFFFF), 0, 90) _GDIPlus_GraphicsDrawRadialGradient($hGraphic, $iRadius, $iHeight + $iRadius, $iRadius, $iARGB, BitAND($iARGB, 0x00FFFFFF), 90, 180) For $i = 0 To 3 $tRect = DllStructCreate($tagGDIPRECTF) For $j = 0 To 4 DllStructSetData($tRect, $j + 1, $aPart[$i][$j]) Next $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRect, $iARGB, BitAND($iARGB, 0x00FFFFFF), $aPart[$i][4], 0, 3) _GDIPlus_GraphicsFillRect($hGraphic, $aPart[$i][0], $aPart[$i][1], $aPart[$i][2], $aPart[$i][3], $hBrush) _GDIPlus_BrushDispose($hBrush) Next $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) Return $hBitmap EndFunc ;==>_CreateDropShadow Func _GDIPlus_GraphicsDrawRadialGradient($hGraphics, $iX, $iY, $iRadius, $iARGB1, $iARGB2, $iStartAngle = 0, $iEndAngle = 360, $iStep = 5) If $iStep < 1 Then $iStep = 1 EndIf Local $Xi = $iX - $iRadius, $Yi = $iY - $iRadius, $Di = 2 * $iRadius Local $hBrush, $hMatrix, $Smooth = _GDIPlus_GraphicsGetSmoothingMode($hGraphics) Local $Start = True _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 0) $hBrush = _GDIPlus_LineBrushCreate(0, 0, $iRadius, 0, $iARGB1, $iARGB2, 3) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $iX, $iY) While $iStartAngle < $iEndAngle If $iStartAngle + $iStep > $iEndAngle Then $iStep = $iEndAngle - $iStartAngle EndIf If $Start Then _GDIPlus_MatrixRotate($hMatrix, $iStartAngle + $iStep / 2) $Start = False Else _GDIPlus_MatrixRotate($hMatrix, $iStep) EndIf _GDIPlus_LineBrushSetTransform($hBrush, $hMatrix) _GDIPlus_GraphicsFillPie($hGraphics, $Xi, $Yi, $Di, $Di, $iStartAngle, $iStep, $hBrush) $iStartAngle += $iStep WEnd _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $Smooth) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_BrushDispose($hBrush) Return 1 EndFunc ;==>_GDIPlus_GraphicsDrawRadialGradient sorry for my english...
-
I managed to delete the title, but a white trace of it remains. Is it possible to delete it? It is important that the window shadow remains... sorry for my english please! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> ;exit func HotKeySet('{ESC}', 'Terminate') Func Terminate() Exit EndFunc ;==>Terminate $hGUI = GUICreate('', 400, 400, 400, 400, BitOR($WS_POPUP, $WS_THICKFRAME)) GUISetBkColor($COLOR_RED,$hGUI) GUISetState(@SW_SHOW,$hGUI) While Sleep(1000) WEnd