Leaderboard
Popular Content
Showing content with the highest reputation since 06/21/2025 in all areas
-
Make active transparent icon on image background
argumentum and 2 others reacted to UEZ for a topic
I have thought again and this is simpler and the better solution. #NoTrayIcon ;#RequireAdmin #include <WinAPISys.au3> #include <GDIPlus.au3> #include <WinAPIShellEx.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Example() Func Example() Local $hGUI, $hGraphic, $hIcon, $hBitmap, $iX = 768, $iY = 525 $hGUI = GUICreate("GDI+", $iX, $iY) _GDIPlus_Startup() ; Create GUI Global $idPic = GUICtrlCreatePic("", 0, 0, $iX, $iY) Global $sFileName = @ScriptDir& "\MAIN.png" $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) $hBGImage = _GDIPlus_BitmapCreateFromScan0($iX, $iY) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBGImage) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) $btnx = 250 $btny = 150 ;_GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 221, 48, 48) $hBitmap = _GDIPlus_BitmapCreateFromHICON32($hIcon) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, $btnx, $btny) $shBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBGImage) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, 0, $shBitmap)) ; STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 GUICtrlSetState($idPic, $gui_disable) GUICtrlSetState(-1, $GUI_ONTOP) GUICtrlSetCursor(-1, 0) $hIcon = GUICtrlCreateIcon(@SystemDir & '\shell32.dll', -1, $btnx, $btny, 48, 48, BitOR($SS_NOTIFY, $SS_BLACKRECT)) GUISetState() ; Loop until user exits Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hIcon ConsoleWrite("Icon clicked" & @CRLF) EndSwitch Until False ; Clean up resources _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject($shBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hBGImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example3 points -
WebP v0.3.5 build 2025-06-27 beta
argumentum and one other reacted to UEZ for a topic
Updated to: WebP v0.3.5 build 2025-06-27 beta You can now create WebP animated files. Examples8 encodes GDI+ supported image files to an animation. Example9 captures the desktop screen to an WebP anim file.2 points -
You can simply try this code: It uses GDI+ to draw a red circle with centered text, creates a 32-bit ARGB icon, and sets it as a taskbar overlay using ITaskbarList3::SetOverlayIcon. It updates the icon every second. You can easily adjust it to fit your own needs. Let me know if it works for you! #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIIcons.au3> Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " Line: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) EndFunc ; Define ITaskbarList3 COM interface Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" Global Const $tagITaskbarList3 = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" & _ "MarkFullscreenWindow hresult(hwnd;boolean);" & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" ; Global variables Global $hGraphic, $hTextBrush, $hFormat, $hFamily, $hFont, $hBackgroundBrush, $hPen Global $oList, $hWnd Global $iWidth = 32, $iHeight = 32, $iFontSize = 12 Global $iCounter = 0 Main() Func Main() _GDIPlus_Startup() $hWnd = GUICreate("Taskbar Overlay Icon Test", 400, 300) Local $label = GUICtrlCreateLabel("Starting...", 10, 10, 380, 100) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hTextBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize) $hBackgroundBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000) $hPen = _GDIPlus_PenCreate(0xFF000000, 2) $oList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3) If Not IsObj($oList) Then MsgBox(16, "Error", "Failed to initialize ITaskbarList3.") Exit EndIf $oList.HrInit() If @error Then MsgBox(16, "Error", "HrInit failed: " & @error) Exit EndIf GUICtrlSetData($label, "$oList.AddTab") $oList.AddTab($hWnd) If @error Then MsgBox(16, "Error", "Failed to add taskbar tab: " & @error) Exit EndIf _UpdateOverlayIcon($iCounter) GUICtrlSetData($label, "Overlay icon initialized with counter: " & $iCounter) Local $hTimer = TimerInit() While 1 If TimerDiff($hTimer) > 1000 Then $iCounter += 1 If $iCounter > 99 Then $iCounter = 99 _UpdateOverlayIcon($iCounter) GUICtrlSetData($label, "Counter: " & $iCounter) $hTimer = TimerInit() EndIf If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop Sleep(10) WEnd GUICtrlSetData($label, "Removing overlay icon and tab") _Taskbar_SetOverlayIcon($oList, $hWnd, Null, "") $oList.DeleteTab($hWnd) $oList = 0 _GDIPlus_FontDispose($hFont) _GDIPlus_PenDispose($hPen) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hTextBrush) _GDIPlus_BrushDispose($hBackgroundBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc Func _UpdateOverlayIcon($iCount) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB) Local $hGraphicBitmap = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphicBitmap, 2) _GDIPlus_GraphicsClear($hGraphicBitmap, 0x00000000) _GDIPlus_GraphicsFillEllipse($hGraphicBitmap, 0, 0, $iWidth - 2, $iHeight - 2, $hBackgroundBrush) _GDIPlus_GraphicsDrawEllipse($hGraphicBitmap, 0, 0, $iWidth - 2, $iHeight - 2, $hPen) Local $tLayout = _GDIPlus_RectFCreate(2, 2, $iWidth - 4, $iHeight - 8) DrawStringCentered($hGraphicBitmap, $iCount, $hFont, $tLayout, $hFormat, $hTextBrush) Local $hIcon = _GDIPlus_HICONCreateFromBitmap($hBitmap) If @error Then MsgBox(16, "Error", "Failed to create HICON: " & @error) Exit EndIf _Taskbar_SetOverlayIcon($oList, $hWnd, $hIcon, "Counter: " & $iCount) _WinAPI_DestroyIcon($hIcon) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphicBitmap) EndFunc Func DrawStringCentered($hGraphic, $iIndex, $hFont, $tLayout, $hFormat, $hTextBrush) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $iIndex, $hFont, $tLayout, $hFormat) Local $tIndex = $aInfo[0] $tIndex.X = $tLayout.X + (($tLayout.Width - $tIndex.Width) / 2) $tIndex.Y = $tLayout.Y + (($tLayout.Height - _GDIPlus_FontGetHeight($hFont, $hGraphic)) / 2) _GDIPlus_GraphicsDrawStringEx($hGraphic, $iIndex, $hFont, $tIndex, $hFormat, $hTextBrush) EndFunc Func _Taskbar_SetOverlayIcon(ByRef $oTB, $hWnd, $hIcon, $sAltText = "") Local $vRet = $oTB.SetOverlayIcon($hWnd, $hIcon, $sAltText) If @error Then Return SetError(@error, @extended, False) If $vRet = 0 Then Return True Return SetError($vRet, 0, False) EndFunc2 points
-
I dont see $btny used anywhere, $btnx appears to be used for both X and Y positions.2 points
-
Need help converting percentage to hex
WildByDesign and one other reacted to UEZ for a topic
I misunderstood the value but it's easy, too: Local $iIntensity = '80' ;% of the alpha channel Local $iTintColor = '0x0078D4' $iIntensity = Int($iIntensity) * 255 / 100 Local $iColor = BitOR(BitShift($iIntensity > 255 ? 255 : $iIntensity < 0 ? 0: $iIntensity, -24), Int($iTintColor)) ConsoleWrite(Hex($iColor, 8) & @CRLF) _WinAPI_DwmEnableBlurBehindWindow10($hGUI, True, $iColor)2 points -
Need help converting percentage to hex
ioa747 and one other reacted to argumentum for a topic
If all this is for coloring, there is code for all that in https://www.autoitscript.com/forum/files/file/489-my-fine-tuned-high-contrast-theme/ If is for Hex, do give the user 255% because, why not. It'd simplify your code, enlighten the user, and gives fine control ( other wise you'd have to calculate "value * 2.55" each step ) for those that are very picky with colors. I look at it as from zero to Maximum Effort !2 points -
AutoIt Script for TLS Security Context Initialization (Schannel, Customizable)
argumentum reacted to Numeric1 for a topic
In the context of a complex project with stringent TLS requirements and various technical constraints, I decided to dive into the core of security mechanisms. While many off-the-shelf solutions exist for handling security contexts, I wanted to explore the fundamentals directly. Here, I’m sharing a raw and isolated excerpt of an AutoIt script that initializes a TLS security context using the Schannel API. This code is functional but deliberately minimal, providing a solid foundation for optimization and enhanced robustness. #include-once #include <WinAPI.au3> #include <WinAPIError.au3> #include <AutoItConstants.au3> #include <Date.au3> ; Constantes Schannel Global Const $SEC_E_OK = 0x00000000 Global Const $SEC_I_CONTINUE_NEEDED = 0x00090312 Global Const $SEC_E_INCOMPLETE_MESSAGE = 0x80090318 Global Const $SEC_E_INVALID_TOKEN = 0x80090308 Global Const $SECPKG_CRED_OUTBOUND = 2 Global Const $UNISP_NAME = "Microsoft Unified Security Protocol Provider" Global Const $SCHANNEL_CRED_VERSION = 4 Global Const $SCH_CRED_NO_DEFAULT_CREDS = 0x00000010 Global Const $SCH_CRED_AUTO_CRED_VALIDATION = 0x00000020 ; Flags pour InitializeSecurityContext Global Const $ISC_REQ_SEQUENCE_DETECT = 0x00000008 Global Const $ISC_REQ_REPLAY_DETECT = 0x00000004 Global Const $ISC_REQ_CONFIDENTIALITY = 0x00000010 Global Const $ISC_REQ_ALLOCATE_MEMORY = 0x00000100 Global Const $ISC_REQ_STREAM = 0x00008000 ; Types buffers Global Const $SECBUFFER_TOKEN = 2 Global Const $SECBUFFER_EMPTY = 0 ; Attributes QueryContextAttributes Global Const $SECPKG_ATTR_REMOTE_CERT_CONTEXT = 0x53 Global Const $SECPKG_ATTR_CONNECTION_INFO = 0x5A ; Structures Global Const $tagCRED_HANDLE = "struct;ULONG_PTR dwLower;ULONG_PTR dwUpper;endstruct;" Global Const $tagSCHANNEL_CRED = "struct;" & _ "dword dwVersion;" & _ "dword dwCredFormat;" & _ "dword cCreds;" & _ "ptr paCred;" & _ "ptr hRootStore;" & _ "dword cMappers;" & _ "ptr aphMappers;" & _ "byte reserved[4];" & _ "dword dwSessionLifespan;" & _ "dword dwFlags;" & _ "dword cTlsParameters;" & _ "ptr pTlsParameters;" & _ "endstruct;" Global Const $tagSEC_BUFFER = "struct;dword cbBuffer;dword BufferType;ptr pvBuffer;endstruct;" Global Const $tagSEC_BUFFER_DESC = "struct;dword ulVersion;dword cBuffers;ptr pBuffers;endstruct;" Global Const $tagCERT_CONTEXT = "struct;" & _ "dword dwCertEncodingType;" & _ "ptr pbCertEncoded;" & _ "dword cbCertEncoded;" & _ "ptr pCertInfo;" & _ "ptr hCertStore;" & _ "endstruct;" Global Const $tagCERT_INFO = "struct;" & _ "dword dwVersion;" & _ "dword cbSerialNumber;ptr pbSerialNumber;" & _ "ptr pszObjId;dword cbData;ptr pbData;" & _ "dword cbIssuer;ptr pbIssuer;" & _ "dword NotBeforeLow;dword NotBeforeHigh;" & _ "dword NotAfterLow;dword NotAfterHigh;" & _ "dword cbSubject;ptr pbSubject;" & _ "ptr pSubjectPublicKeyInfo;" & _ "dword cbIssuerUniqueId;ptr pbIssuerUniqueId;" & _ "dword cbSubjectUniqueId;ptr pbSubjectUniqueId;" & _ "dword cExtension;" & _ "ptr rgExtension;" & _ "endstruct;" ; Variables globales Global $iSocket = -1 Global $tCredHandle, $tCtxtHandle Global $sHost = "www.google.com" Global $g_iDetectedTLSVersion = 0 Func InitializeTLS() TCPStartup() Sleep(100) ; Initial delay to stabilize the network Local $sIP = TCPNameToIP($sHost) If @error Then ConsoleWrite("Error: Failed to establish TCP connection to " & $sHost & @CRLF) Cleanup() Return False EndIf $iSocket = TCPConnect($sIP, 443) If $iSocket = -1 Then ConsoleWrite("Error: Failed to establish TCP connection to " & $sHost & @CRLF) Cleanup() Return False EndIf $tCredHandle = _AcquireCredentialsHandle() If @error Then Cleanup() Return False EndIf Local $bResult = EstablishSecurityContext() If Not $bResult Then Cleanup() EndIf Return $bResult EndFunc ;==>InitializeTLS Func _AcquireCredentialsHandle() Local $tCred = DllStructCreate($tagSCHANNEL_CRED) Local $tTimeStamp = DllStructCreate("dword;dword") Local $tHandle = DllStructCreate($tagCRED_HANDLE) DllStructSetData($tCred, "dwVersion", $SCHANNEL_CRED_VERSION) DllStructSetData($tCred, "dwCredFormat", 0) DllStructSetData($tCred, "cCreds", 0) DllStructSetData($tCred, "paCred", 0) DllStructSetData($tCred, "hRootStore", 0) DllStructSetData($tCred, "cMappers", 0) DllStructSetData($tCred, "aphMappers", 0) DllStructSetData($tCred, "dwSessionLifespan", 0) DllStructSetData($tCred, "dwFlags", BitOR($SCH_CRED_NO_DEFAULT_CREDS, $SCH_CRED_AUTO_CRED_VALIDATION)) DllStructSetData($tCred, "cTlsParameters", 0) DllStructSetData($tCred, "pTlsParameters", 0) DllStructSetData($tCred, "grbitEnabledProtocols", BitOR(0x00000800, 0x00002000)) ; TLS 1.2 et 1.3 Local $aRet = DllCall("secur32.dll", "long", "AcquireCredentialsHandleW", _ "wstr", "", _ "wstr", $UNISP_NAME, _ "dword", $SECPKG_CRED_OUTBOUND, _ "ptr", 0, _ "ptr", DllStructGetPtr($tCred), _ "ptr", 0, _ "ptr", 0, _ "ptr", DllStructGetPtr($tHandle), _ "ptr", DllStructGetPtr($tTimeStamp)) If @error Or $aRet[0] <> $SEC_E_OK Then ConsoleWrite("Error AcquireCredentialsHandle: " & Hex($aRet[0]) & @CRLF) Return SetError(1, 0, 0) EndIf ConsoleWrite("Credentials acquired successfully" & @CRLF) Return $tHandle EndFunc ;==>_AcquireCredentialsHandle Func EstablishSecurityContext() Local $tInBufferDesc = DllStructCreate($tagSEC_BUFFER_DESC) Local $tOutBufferDesc = DllStructCreate($tagSEC_BUFFER_DESC) Local $tInBuffer = DllStructCreate($tagSEC_BUFFER) Local $tOutBuffer = DllStructCreate($tagSEC_BUFFER) Local $tCtxtNew = DllStructCreate($tagCRED_HANDLE) Local $tAttributes = DllStructCreate("dword") Local $tTimeStamp = DllStructCreate("dword;dword") DllStructSetData($tInBufferDesc, "ulVersion", 0) DllStructSetData($tInBufferDesc, "cBuffers", 1) DllStructSetData($tInBufferDesc, "pBuffers", DllStructGetPtr($tInBuffer)) DllStructSetData($tInBuffer, "BufferType", $SECBUFFER_EMPTY) DllStructSetData($tInBuffer, "cbBuffer", 0) DllStructSetData($tInBuffer, "pvBuffer", 0) DllStructSetData($tOutBufferDesc, "ulVersion", 0) DllStructSetData($tOutBufferDesc, "cBuffers", 1) DllStructSetData($tOutBufferDesc, "pBuffers", DllStructGetPtr($tOutBuffer)) DllStructSetData($tOutBuffer, "BufferType", $SECBUFFER_TOKEN) DllStructSetData($tOutBuffer, "cbBuffer", 0) DllStructSetData($tOutBuffer, "pvBuffer", 0) Local $dwFlags = BitOR($ISC_REQ_SEQUENCE_DETECT, $ISC_REQ_REPLAY_DETECT, _ $ISC_REQ_CONFIDENTIALITY, $ISC_REQ_ALLOCATE_MEMORY, $ISC_REQ_STREAM) Local $scRet = $SEC_I_CONTINUE_NEEDED Local $bFirstCall = True While $scRet = $SEC_I_CONTINUE_NEEDED Or $scRet = $SEC_E_INCOMPLETE_MESSAGE ConsoleWrite("Calling InitializeSecurityContext (" & ($bFirstCall ? "first" : "subsequent") & ")" & @CRLF) Local $aRet = DllCall("secur32.dll", "long", "InitializeSecurityContextW", _ "ptr", DllStructGetPtr($tCredHandle), _ "ptr", ($bFirstCall ? 0 : DllStructGetPtr($tCtxtNew)), _ "wstr", $sHost, _ "dword", $dwFlags, _ "dword", 0, _ "dword", 0, _ "ptr", ($bFirstCall ? 0 : DllStructGetPtr($tInBufferDesc)), _ "dword", 0, _ "ptr", DllStructGetPtr($tCtxtNew), _ "ptr", DllStructGetPtr($tOutBufferDesc), _ "ptr", DllStructGetPtr($tAttributes), _ "ptr", DllStructGetPtr($tTimeStamp)) If @error Then ConsoleWrite("DLL Call ERROR: " & @CRLF) Return False EndIf $scRet = $aRet[0] ConsoleWrite("hResult: " & Hex($scRet) & @CRLF) If $scRet = $SEC_E_OK Then ConsoleWrite("TLS connection successfully established!" & @CRLF) $tCtxtHandle = $tCtxtNew Return True ElseIf $scRet = $SEC_I_CONTINUE_NEEDED Or $scRet = $SEC_E_INCOMPLETE_MESSAGE Then If Not SendOutBuffer($tOutBuffer) Then Return False EndIf If Not ReceiveInputBuffer($tInBufferDesc, $tInBuffer) Then Return False EndIf If $bFirstCall Then $bFirstCall = False Else ConsoleWrite("Error InitializeSecurityContext: " & Hex($scRet) & @CRLF) Return False EndIf WEnd Return False EndFunc ;==>EstablishSecurityContext Func SendOutBuffer(ByRef $tBuffer) Local $cbBuffer = DllStructGetData($tBuffer, "cbBuffer") If $cbBuffer <= 0 Then Return True Local $pvBuffer = DllStructGetData($tBuffer, "pvBuffer") Local $tData = DllStructCreate("byte[" & $cbBuffer & "]", $pvBuffer) Local $bData = DllStructGetData($tData, 1) ConsoleWrite("Send " & $cbBuffer & " octets (hex): " & StringLeft($bData, 100) & "..." & @CRLF) ConsoleWrite("Send (text) : " & StringLeft(BinaryToString($bData), 50) & "..." & @CRLF) TCPSend($iSocket, $bData) If @error Then ConsoleWrite("Errorr TCPSend: " & @error & @CRLF) Return False EndIf DllCall("secur32.dll", "long", "FreeContextBuffer", "ptr", $pvBuffer) DllStructSetData($tBuffer, "pvBuffer", 0) DllStructSetData($tBuffer, "cbBuffer", 0) Return True EndFunc ;==>SendOutBuffer Func ReceiveInputBuffer(ByRef $tBufferDesc, ByRef $tBuffer) Local $bData = "" Local $iTimeout = TimerInit() While BinaryLen($bData) < 5 And TimerDiff($iTimeout) < 5000 $bData = TCPRecv($iSocket, 8192, 1) If @error Then ConsoleWrite("Error TCPRecv: " & @error & @CRLF) Return False EndIf If BinaryLen($bData) > 0 Then ExitLoop Sleep(10) WEnd Local $iLen = BinaryLen($bData) If $iLen = 0 Then ConsoleWrite("Error: No data received after timeout" & @CRLF) Return False EndIf ConsoleWrite("Received " & $iLen & " bytes (hex): " & StringLeft($bData, 50) & "..." & @CRLF) ConsoleWrite("Received (text): " & StringLeft(BinaryToString($bData), 50) & "..." & @CRLF) If BinaryMid($bData, 1, 1) = 0x15 And $iLen >= 7 Then Local $iVersion = Number(BinaryMid($bData, 2, 2)) Local $iLengthHi = Number(BinaryMid($bData, 4, 1)) Local $iLengthLo = Number(BinaryMid($bData, 5, 1)) Local $iLength = $iLengthHi * 256 + $iLengthLo Local $iLevel = Number(BinaryMid($bData, 6, 1)) Local $iDesc = Number(BinaryMid($bData, 7, 1)) ConsoleWrite("Alerte TLS détected: " & _ "Version=0x" & Hex($iVersion, 4) & ", " & _ "Length=" & $iLength & ", " & _ "Level=" & ($iLevel = 2 ? "Fatal" : "Warning") & ", " & _ "Description=" & $iDesc & " (" & GetAlertDescription($iDesc) & ")" & @CRLF) EndIf Local $tData = DllStructCreate("byte[" & $iLen & "]") DllStructSetData($tData, 1, $bData) DllStructSetData($tBuffer, "BufferType", $SECBUFFER_TOKEN) DllStructSetData($tBuffer, "cbBuffer", $iLen) DllStructSetData($tBuffer, "pvBuffer", DllStructGetPtr($tData)) Return True EndFunc ;==>ReceiveInputBuffer Func GetAlertDescription($iDesc) Switch $iDesc Case 0 Return "Close Notify" Case 10 Return "Unexpected Message" Case 40 Return "Handshake Failure" Case 70 Return "Protocol Version" Case 112 Return "Unrecognized Name" Case Else Return "Unknown Alert" EndSwitch EndFunc ;==>GetAlertDescription Func DisplayCertInfo() Local $tCertContextPtr = DllStructCreate("ptr") Local $aRet = DllCall("secur32.dll", "long", "QueryContextAttributesW", _ "ptr", DllStructGetPtr($tCtxtHandle), _ "dword", $SECPKG_ATTR_REMOTE_CERT_CONTEXT, _ "ptr", DllStructGetPtr($tCertContextPtr)) If @error Or $aRet[0] <> $SEC_E_OK Then ConsoleWrite("Error QueryContextAttributesW (cert): " & Hex($aRet[0]) & @CRLF) Return EndIf Local $pCertContext = DllStructGetData($tCertContextPtr, 1) If $pCertContext = 0 Then ConsoleWrite("Error: No certificate retrieved" & @CRLF) Return EndIf Local $tCertContext = DllStructCreate($tagCERT_CONTEXT, $pCertContext) Local $pCertInfo = DllStructGetData($tCertContext, "pCertInfo") Local $tCertInfo = DllStructCreate($tagCERT_INFO, $pCertInfo) Local $tConnInfo = DllStructCreate("struct;dword dwProtocol;dword aiCipher;dword dwCipherStrength;dword aiHash;dword dwHashStrength;dword aiExch;dword dwExchStrength;endstruct;") $aRet = DllCall("secur32.dll", "long", "QueryContextAttributesW", _ "ptr", DllStructGetPtr($tCtxtHandle), _ "dword", $SECPKG_ATTR_CONNECTION_INFO, _ "ptr", DllStructGetPtr($tConnInfo)) If @error Or $aRet[0] <> $SEC_E_OK Then ConsoleWrite("Error QueryContextAttributesW (conn): " & Hex($aRet[0]) & @CRLF) EndIf ConsoleWrite("🔒 SSL CERTIFICATE INFO" & @CRLF) ConsoleWrite("======================================" & @CRLF) ConsoleWrite("🏷️ Subject: " & GetCertNameString($pCertContext, False) & @CRLF) ConsoleWrite("🏛️ Issued by: " & GetCertNameString($pCertContext, True) & @CRLF) Local $tNotAfter = DllStructCreate($tagFILETIME) DllStructSetData($tNotAfter, "Lo", DllStructGetData($tCertInfo, "NotAfterLow")) DllStructSetData($tNotAfter, "Hi", DllStructGetData($tCertInfo, "NotAfterHigh")) Local $sExpiration = FileTimeToString($tNotAfter) ConsoleWrite("📅 Expiration: " & $sExpiration & @CRLF) Local $tNotBefore = DllStructCreate($tagFILETIME) DllStructSetData($tNotBefore, "Lo", DllStructGetData($tCertInfo, "NotBeforeLow")) DllStructSetData($tNotBefore, "Hi", DllStructGetData($tCertInfo, "NotBeforeHigh")) Local $sValidFrom = FileTimeToString($tNotBefore) ConsoleWrite("📅 Valid from: " & $sValidFrom & @CRLF) ConsoleWrite("ConnInfo: " & _ "Protocol=0x" & Hex(DllStructGetData($tConnInfo, "dwProtocol"), 4) & ", " & _ "Cipher=0x" & Hex(DllStructGetData($tConnInfo, "aiCipher"), 4) & ", " & _ "Strength=" & DllStructGetData($tConnInfo, "dwCipherStrength") & ", " & _ "Hash=0x" & Hex(DllStructGetData($tConnInfo, "aiHash"), 4) & ", " & _ "HashStrength=" & DllStructGetData($tConnInfo, "dwHashStrength") & ", " & _ "Exch=0x" & Hex(DllStructGetData($tConnInfo, "aiExch"), 4) & ", " & _ "ExchStrength=" & DllStructGetData($tConnInfo, "dwExchStrength") & @CRLF) Local $dwProtocol = DllStructGetData($tConnInfo, "dwProtocol") Local $sProtocol = GetProtocolName($dwProtocol) ConsoleWrite("🔒 SSL Protocol: " & $sProtocol & " (raw value: 0x" & Hex($dwProtocol, 4) & ")" & @CRLF) ConsoleWrite("CERT_INFO Data: Version=" & DllStructGetData($tCertInfo, "dwVersion") & ", pszObjId=" & DllStructGetData($tCertInfo, "pszObjId") & @CRLF) ConsoleWrite("🖊️ Signature Algorithm: " & GetSignatureAlgorithm($pCertInfo) & @CRLF) Local $sCipher = GetCipherName(DllStructGetData($tConnInfo, "aiCipher")) ConsoleWrite("🔑 Encryption Algorithm: " & $sCipher & @CRLF) Local $iCipherStrength = DllStructGetData($tConnInfo, "dwCipherStrength") ConsoleWrite("🛠️ Key Size: " & $iCipherStrength & " bits" & @CRLF) DllCall("crypt32.dll", "bool", "CertFreeCertificateContext", "ptr", $pCertContext) EndFunc ;==>DisplayCertInfo Func GetCertNameString($pCertContext, $bIssuer = False) Local Const $CERT_NAME_SIMPLE_DISPLAY_TYPE = 4 Local Const $CERT_NAME_ISSUER_FLAG = 0x1 Local $dwFlags = ($bIssuer ? $CERT_NAME_ISSUER_FLAG : 0) Local $aRet = DllCall("crypt32.dll", "dword", "CertGetNameStringW", _ "ptr", $pCertContext, _ "dword", $CERT_NAME_SIMPLE_DISPLAY_TYPE, _ "dword", $dwFlags, _ "ptr", 0, _ "wstr", 0, _ "dword", 0) If @error Then Return "Error DLL: " & @error EndIf Local $iLength = $aRet[0] If $iLength <= 1 Then Return "" EndIf Local $tBuffer = DllStructCreate("wchar[" & $iLength & "]") $aRet = DllCall("crypt32.dll", "dword", "CertGetNameStringW", _ "ptr", $pCertContext, _ "dword", $CERT_NAME_SIMPLE_DISPLAY_TYPE, _ "dword", $dwFlags, _ "ptr", 0, _ "ptr", DllStructGetPtr($tBuffer), _ "dword", $iLength) If @error Or $aRet[0] <= 1 Then Return "" EndIf Return DllStructGetData($tBuffer, 1) EndFunc ;==>GetCertNameString Func GetProtocolName($dwProtocol) Switch $dwProtocol Case 0x0080 Return "SSL 2.0" Case 0x0300 Return "SSL 3.0" Case 0x0301 Return "TLS 1.0" Case 0x0302 Return "TLS 1.1" Case 0x0800 Return "TLS 1.2" Case 0x1000 Return "TLS 1.3" Case Else Return "Inconnu (0x" & Hex($dwProtocol, 4) & ")" EndSwitch EndFunc ;==>GetProtocolName Func GetSignatureAlgorithm($pCertInfo) Local $tCertInfo = DllStructCreate($tagCERT_INFO, $pCertInfo) Local $pszObjId = DllStructGetData($tCertInfo, "pszObjId") ConsoleWrite("OID brut : " & $pszObjId & @CRLF) Switch $pszObjId Case "1.2.840.113549.1.1.11" Return "SHA256withRSA" Case "1.2.840.113549.1.1.12" Return "SHA384withRSA" Case "1.2.840.10045.4.3.2" Return "ECDSAwithSHA256" Case "1.2.840.10045.4.3.3" Return "ECDSAwithSHA384" Case Else Return "Inconnu (OID: " & $pszObjId & ")" EndSwitch EndFunc ;==>GetSignatureAlgorithm Func GetCipherName($aiCipher) Switch $aiCipher Case 0x0000660E Return "AES-128" Case 0x0000660F Return "AES-256" Case 0x00000002 Return "RC4" Case 0x00000005 Return "3DES" Case Else Return "Inconnu (0x" & Hex($aiCipher, 4) & ")" EndSwitch EndFunc ;==>GetCipherName Func Cleanup() If IsDllStruct($tCtxtHandle) Then DllCall("secur32.dll", "long", "DeleteSecurityContext", "ptr", DllStructGetPtr($tCtxtHandle)) $tCtxtHandle = 0 EndIf If IsDllStruct($tCredHandle) Then DllCall("secur32.dll", "long", "FreeCredentialsHandle", "ptr", DllStructGetPtr($tCredHandle)) $tCredHandle = 0 EndIf If $iSocket <> -1 Then TCPCloseSocket($iSocket) $iSocket = -1 EndIf TCPShutdown() EndFunc ;==>Cleanup Func FileTimeToString($tFileTime) Local $tSystemTime = DllStructCreate("word wYear;word wMonth;word wDayOfWeek;word wDay;word wHour;word wMinute;word wSecond;word wMilliseconds") Local $aRet = DllCall("kernel32.dll", "none", "FileTimeToSystemTime", _ "ptr", DllStructGetPtr($tFileTime), _ "ptr", DllStructGetPtr($tSystemTime)) If @error Or $aRet[0] <> 0 Then ConsoleWrite("Erreur FileTimeToSystemTime: " & @error & @CRLF) Return "Erreur" EndIf Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d UTC", _ DllStructGetData($tSystemTime, "wYear"), _ DllStructGetData($tSystemTime, "wMonth"), _ DllStructGetData($tSystemTime, "wDay"), _ DllStructGetData($tSystemTime, "wHour"), _ DllStructGetData($tSystemTime, "wMinute"), _ DllStructGetData($tSystemTime, "wSecond")) EndFunc ;==>FileTimeToString ; Execution If InitializeTLS() Then ConsoleWrite("TLS connection successful!" & @CRLF) Sleep(300) DisplayCertInfo() Else ConsoleWrite("TLS connection failed" & @CRLF) EndIf Cleanup()1 point -
AutoIt Script for TLS Security Context Initialization (Schannel, Customizable)
Numeric1 reacted to argumentum for a topic
Oh, am just running this once. And doubt that it needs constant reties. But I'd like to replicate the from your post1 point -
DwmColorBlurMica
argumentum reacted to WildByDesign for a topic
I just updated the first post with version 1.0.2. I made some changes to the hooking logic so that it hooks earlier during process initialization. This made the overall hooking significantly faster and the occasional flicker with some apps is gone or at least greatly reduced. That may also depend on CPU speed, system load, etc. but overall a really nice improvement. I also made some changes to the border coloring function to make it more efficient and therefore benefit the performance of other areas of the program.1 point -
Make active transparent icon on image background
Davidyese reacted to argumentum for a topic
..this is quite something. For GUIs without combo or listviews, the whole GUI could be used like this 💯1 point -
1 point
-
_WinAPI_DwmEnableBlurBehindWindow in Windows 10
Parsix reacted to scintilla4evr for a topic
Hello! As some of you probably know, _WinAPI_DwmEnableBlurBehindWindow does not work as you'd like it to work in Windows 10. It doesn't add Aero-like blur, as seen in the new Start menu or Notification Center. I looked for a solution and found "the most elegant" one: The blur only affects the inside of the window and it is not colored. It can be enabled via an undocumented SetWindowCompositionAttribute function in user32.dll. _WinAPI_DwmEnableBlurBehindWindow for Windows 10 - this archive contains both the UDF and the example.1 point -
DwmColorBlurMica
argumentum reacted to WildByDesign for a topic
I've updated the first post with version 1.0.1. It might be the smallest update with the least amount of changes. However, it is by far the most significant to me. I was finally able to get the compiled x64 binary to avoid the False Positive from Windows Defender. I actually tried about a dozen different changes and none of them got rid of the false positive. The one single change that did get rid of the false positive: #AutoIt3Wrapper_Compression=0 That's it. That is all. I was so disappointed with the false positive on every single prior version, but now I am ecstatic. Now I have to get rid of the false positives on my 5 or 6 other AutoIt programs. I'm wondering if they should change the default compression level because of this.1 point -
You have to exclude the area of the icon off the bitmap (graphic). One example:1 point
-
1 point
-
DwmColorBlurMica
argumentum reacted to WildByDesign for a topic
Version 1.0.0 has been updated on the first post. After failing to figure out color tinted blur for weeks now, I have finally figured it out. Now you can have blur tinted with any color. There are global options for this and per-app / per-class options. So you can have as many apps as you want all with varying colors of tinted blur with varying intensities. And some with all of the other stuff too. I've been so busy building this thing that I haven't actually had much time to play with it. But I am imagining the crazy amount of possibilities right now.1 point -
Need help converting percentage to hex
argumentum reacted to WildByDesign for a topic
Thank you very much. That works beautifully.1 point -
Need help converting percentage to hex
WildByDesign reacted to UEZ for a topic
Try: Local $iIntensity = '80' ;hex Local $iTintColor = '0x0078D4' Local $iColor = BitOR(BitShift(Dec($iIntensity), -24), Int($iTintColor)) ConsoleWrite(Hex($iColor, 8) & @CRLF) _WinAPI_DwmEnableBlurBehindWindow10($hGUI, True, $iColor)1 point -
Need help converting percentage to hex
argumentum reacted to WildByDesign for a topic
Exquisite is the perfect and only word to describe your math, I agree. Thank you very much.1 point -
Need help converting percentage to hex
WildByDesign reacted to argumentum for a topic
ConsoleWrite(percentageOfAlpha(80, 0xFF1234FF) & @CRLF) ConsoleWrite(percentageOfAlpha(80, '0xFF0000FF') & @CRLF) ConsoleWrite(percentageOfAlpha(80, 0x0000FF) & @CRLF) ConsoleWrite(percentageOfAlpha(80, '0x0000FF') & @CRLF) Func percentageOfAlpha($iVal, $iColor) Return "0x" & percentageOfHex($iVal) & Hex($iColor, 6) ;~ Local $a = StringSplit(Hex($iColor, 6), "", 0) ;~ Return "0x" & percentageOfHex($iVal) & $a[$a[0] - 5] & $a[$a[0] - 4] & $a[$a[0] - 3] & $a[$a[0] - 2] & $a[$a[0] - 1] & $a[$a[0] - 0] EndFunc ;==>percentageOfAlpha Func percentageOfHex($iVal) $iVal = Int($iVal > 99 ? 100 : ($iVal < 1 ? 0 : $iVal)) ; no more than 100% or less than 0% Return Hex(Ceiling(($iVal * 100) * (2.55 * 100) / (100 * 100)), 2) ; calculate in integers, as floating point numbers suck in a CPU EndFunc ;==>percentageOfHex gotta say, my math is exquisite1 point -
Need help converting percentage to hex
WildByDesign reacted to argumentum for a topic
ConsoleWrite( percentageOfHex(110) & @CRLF) ConsoleWrite( percentageOfHex(80) & @CRLF) ConsoleWrite( percentageOfHex(-2) & @CRLF) Func percentageOfHex($iVal) $iVal = Int($iVal > 99 ? 100 : ($iVal < 1 ? 0 : $iVal)) ; no more than 100% or less than 0% Return Hex(Ceiling(($iVal * 100) * (2.55 * 100) / (100 * 100)), 2) ; calculate in integers, as floating point numbers suck in a CPU EndFunc1 point -
It's on my list to look at when I next have a dev spurt.1 point
-
Need help converting percentage to hex
SOLVE-SMART reacted to WildByDesign for a topic
Well that is actually really interesting. And thank you for your reply as well, by the way. I am still at that stage where I haven't really looked at AI at all yet. So looking at your AI response link there is my first actual look into something from AI. And to be honest, the response is really quite helpful. Particularly the way that it breaks down how it works. One reason why I have stayed away from AI is because I am still very new to AutoIt and I really would like to learn and fully understand things as best as possible. And then maybe dip into AI if needed. But this is very helped, I must admit. Thank you.1 point -
Need help converting percentage to hex
WildByDesign reacted to SOLVE-SMART for a topic
Hi @WildByDesign 👋 , this is one of rar good examples on when to use AI (in my opinion). Please have a look: https://chatgpt.com/share/68593c0e-abac-800f-b469-a29209d5d520 I really just copy and paste your question and already got an idea of how an approach could look like. I don't suggest to use AI to generate AutoIt code, becauce AutoIt code examples are not listed/progressed enough in the most LLMs, but I suggest to get the idea (which is close to your thoughts above) and then come up with the code/solution in AutoIt for yourself or by us as community 😀 . Hopefully this is a good starting point. Best regards Sven1 point -
Need help converting percentage to hex
WildByDesign reacted to ahmet for a topic
What is FF when converted to decimal? You have minimum of zero in hexadecimal that matches 0 in dec. You also have FF in hexadecimal that matches to what in decimal? Then map (0,100) in decimal to (0,FF) afte you have converted it to decimal.1 point -
WinRT Object Libraries
WildByDesign reacted to MattyD for a topic
Apologies for the late reply, I have been awol for a bit. Generally speaking, if the object name starts with windows.* then it'll be built into the OS. So we should have a decent chance of making these ones work. The Microsoft.* objects however are usually external. For these we'll probably need dependencies or a runtime in order to use them. So "Microsoft.UI.Content.DesktopChildSiteBridge" looks to be part of the Windows App SDK (And maybe WinUI3??). There will be associated *.winmd files in the SDK somewhere that contain object definitions. From these we should be able to wrap any object that we'll need in order to change colours etc.. But the tricky bit is how to implement the external objects/controls in the first place. Hope that makes sense. I will eventually get around to attacking this WinUI stuff - It'll just be whenever I have the time and energy to throw at it1 point -
_Msg
WildByDesign reacted to ioa747 for a topic
_Msg($iUI, $sText, $sTitle = @ScriptName, $iTimeout = 3, $iOption = 0) Displays a message using different UI elements based on the specified $iUI parameter. ; https://www.autoitscript.com/forum/topic/212945-_msg/ #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <AutoItConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name...........: _Msg ; Description....: Displays a message using different UI elements based on the specified $iUI parameter. ; Syntax.........: _Msg($iUI, $sText, $sTitle = @ScriptName, $iTimeout = 3, $iOption = 0) ; Parameters.....: $iUI - Specifies the UI element to use: ; 0 - Return - nothing ; 1 - ConsoleWrite ; 2 - MsgBox ; 3 - ToolTip ; 4 - TrayTip ; $sText - The message text to be displayed. ; $sTitle - [optional] The title of the UI element. (Default is @ScriptName) ; $iTimeout - [optional] Timeout in seconds for displaying the message. (Default is 3) ; $iOption - [optional] Options for MsgBox, ToolTip, and TrayTip. (Default is 0) ; Return values .: Success: No specific return value, function exits after display. ; Failure: None ; Example .......: _Msg(1, "Hello, this is a test message.", @ScriptName, 5) ; =============================================================================================================================== Func _Msg($iUI, $sText, $sTitle = Default, $iTimeout = 3, $iOption = 0) If $sTitle = Default Then $sTitle = @ScriptName Switch $iUI Case 0 ; ### 0 Return - Does nothing, just exits the function. Return Case 1 ; ### 1 ConsoleWrite ConsoleWrite($sTitle & ": " & $sText & @CRLF) Case 2 ; ### 2 MsgBox MsgBox($iOption, $sTitle, $sText, $iTimeout) Case 3 ; ### 3 ToolTip ToolTip($sText, Default, Default, $sTitle, $iOption) Sleep($iTimeout * 1000) ; ToolTip doesn't have built-in timeout, so we use Sleep ToolTip("") ; Clear the tooltip after the timeout Case 4 ; ### 4 TrayTip TrayTip($sTitle, $sText, $iTimeout, $iOption) Sleep($iTimeout * 1000) ; give time to display it Case Else ; ### Else case - Does nothing, just exits the function. Return EndSwitch EndFunc ;==>_Msg ; Example Usage of _Msg Function ; ### ConsoleWrite ############################################### ; ConsoleWrite Example _Msg(1, "This message appears in the AutoIt console.", "Console Output") ; ConsoleWrite Example - Information-sign icon consisting of an 'i' in a circle _Msg(1, "This is an informational message.", "> Info") ; ConsoleWrite Example - Stop-sign icon _Msg(1, "This is a error message.", "! Error") ; ConsoleWrite Example - Question-mark icon _Msg(1, "This is a question message.", "+ Question") ; ConsoleWrite Example - Exclamation-point icon _Msg(1, "This is a warning message.", "- Warning") ; ### MsgBox ############################################### ; MsgBox Example - Information-sign icon consisting of an 'i' in a circle _Msg(2, "This is an informational message box.", "Info", 3, $MB_ICONINFORMATION) ; MsgBox Example - Stop-sign icon _Msg(2, "This is a error message box.", "Error", 3, $MB_ICONERROR) ; MsgBox Example - Question-mark icon _Msg(2, "This is a question message box.", "Question", 3, $MB_ICONQUESTION) ; MsgBox Example - Exclamation-point icon _Msg(2, "This is a warning message box.", "Warning", 3, $MB_ICONWARNING) ; ### ToolTip ############################################### ; ToolTip Example - no icon _Msg(3, "This is a question ToolTip.", "noicon", 3, $TIP_NOICON) ; ToolTip Example - Information-sign icon consisting of an 'i' in a circle _Msg(3, "This is an informational ToolTip.", "Info", 3, $TIP_INFOICON) ; ToolTip Example - error icon _Msg(3, "This is a error ToolTip.", "Error", 3, $TIP_ERRORICON) ; ToolTip Example - Warning icon _Msg(3, "This is a warning ToolTip.", "Warning", 3, $TIP_WARNINGICON) ; ### TrayTip ############################################### ; TrayTip Example - no icon _Msg(4, "This is a question TrayTip.", "noicon", 3, $TIP_ICONNONE) ; TrayTip Example - Information-sign icon consisting of an 'i' in a circle _Msg(4, "This is an informational TrayTip.", "Info", 3, $TIP_ICONASTERISK) ; TrayTip Example - error icon _Msg(4, "This is a error TrayTip.", "Error", 3, $TIP_ICONHAND) ; TrayTip Example - Warning icon _Msg(4, "This is a warning TrayTip.", "Warning", 3, $TIP_ICONEXCLAMATION) ; ################################################## ; Return Example (does nothing visible) _Msg(0, "This message will not be displayed.", "No Output") ; MsgBox Example $iTimeout = 0 _Msg(2, "All message examples have been executed.", "Examples Finished", 0)1 point -
DwmColorBlurMica
WildByDesign reacted to argumentum for a topic
Can not be outdated. These are timeless, as life itself. I would recommend putting everything in a zip file and add a simple password. That has shown to me to be better A/V wise for downloads.1 point -
As promised I post the updated UDF when I had the time to finish it. Please don't hesitate to report issues, i have made a few last minute changes that should not interfere but shit usually happens when you don't expect it. I was doubting for a long while; Would I create a new topic or would I add it to the existing topic? Two reasons I have chosen to create a new topic for it: -The programming has been changed so drastically that you cannot incorporate this UDF into your existing projects that are based on the old WINHTTP UDF. -Not just the fact that this UDF is curl based, but the given examples are demonstrating on many levels how you can apply the Curl UDF (including the mime adoption for media/file posting) and something simple but not obvious: how to get the HTTP response code, also when authentication errors like 401/407 occur. Because of the file-size of the libcurl DLL's, I cannot incorporate them into the zip archive so you have to download the libcurl library yourself from the libcurl.se site. As said above, the script also has some optimized (script breaking!) changes regarding the update array that Telegram returned. I know the earlier editions of the older UDF also used the curl executable, this edition uses libcurl instead: I had to test this on hardware and configuration certified environments, some of them are running specific windows environment that do not allow patching or updating/upgrading and won't be for quite a long time. It is there where WINHTTP was really shortcoming without patching. With libcurl, at least you can guarantee your production works out-of-the-box on X86 and X64 editions of windows without letting people to go through all kinds of pain by having to install KB updates or fixes and perhaps not getting any further afterall. New This version is now communicating with the security standards libcurl supports out of the box (no more unsecured plain text https queries) Proxy connections are supported (with or without authentication), i have tested with Synology proxy server, mitm proxy software and a service provider proxy. _getChatmember() has been added _getChatAdministrators() has been added _deleteMessage() has been added/altered to work $TELEGRAM_DEBUG allows enabling two levels of verbosity and logging to an output file to allow you to get debug data _UserPoll() routine support added -> You can build GUI components to process. Don't expect to build 60fps games, but at least you can interact with the GUI decently. (See adapted test.au3 how this works). Changed The _MsgDecode() function now returns a 2D array, rather than a 1D array (script breaking!) -> you need to process $msgData[$Record][$Field] instead of $msgData[$Field] $msgData[$Record][$MESSAGE_ID] is prefixed with a two or three character type indicator: p_, g_, c_, ep_, eg_, ec_ (private, group, channel) (see relaybot.au3 how filtering works) Fixes Binarycall has been altered: OnAutoit3ExitRegister has been removed. (Caused crash if you added your own onAutoitExitRegister callback function) __BinaryCall_DoRelease() is called more often to prevent memory hogging and is added to _Telegram_Close() function The full JSON array is now processed and resulting in this former mentioned 2D array. It saves multiple http queries for the same JSON array buffer if it is large. -> When bot is offline and multiple users were firing all kinds of commands and texts into the chat, group or channel during the bot's absence, Telegram is shoving down the whole history into the bot's throat for processing as soon as it gets online again. The larger the buffered data is, the longer it took to process and redownload before the buffer got released on the telegram server. In some cases I experienced a never-ending loop with the original UDF. I have added the LGPL license text, however: i did *not* have had any answer from Luca regarding the proposed change so it is not effective currently even though I changed a lot of code. telegram-udf-curl-autoit-master.zip1 point
-
@argumentum I hope you don't mind me doing something similar in parallel. I would like to test the code on different OS, need your support. It would make sense to have 2+ monitors, if possible with > 96 DPI. I don't know from which os it is possible to set different DPIs per monitor (WIn10+?). I tested it on Win11 22H2 and worked properly on 3 monitors with 3 different DPIs (left 100%, middle 125 % (main), right 150%). Just run the code and move the GUI over all your monitors. Theoretically the GUI should be adjusted accordingly. _WinAPI_DPI.au3: ;Coded by UEZ build 2023-08-15 beta #include-once #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPISysWin.au3> #include <WinAPIsysinfoConstants.au3> #Region DPI Constants ;https://learn.microsoft.com/en-us/windows/win32/api/windef/ne-windef-dpi_awareness Global Enum $DPI_AWARENESS_INVALID = -1, $DPI_AWARENESS_UNAWARE = 0, $DPI_AWARENESS_SYSTEM_AWARE = 1, $DPI_AWARENESS_PER_MONITOR_AWARE = 2 ;https://learn.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context Global Const $DPI_AWARENESS_CONTEXT_UNAWARE = $DPI_AWARENESS_UNAWARE - 1 Global Const $DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = $DPI_AWARENESS_UNAWARE - 2 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = $DPI_AWARENESS_UNAWARE - 3 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = $DPI_AWARENESS_UNAWARE - 4 Global Const $DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = $DPI_AWARENESS_UNAWARE - 5 ; enum _MONITOR_DPI_TYPE Global Enum $MDT_EFFECTIVE_DPI = 0, $MDT_ANGULAR_DPI, $MDT_RAW_DPI Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI ;Windows Message Codes Global Const $WM_DPICHANGED = 0x02E0, $WM_DPICHANGED_BEFOREPARENT = 0x02E2, $WM_DPICHANGED_AFTERPARENT = 0x02E3, $WM_GETDPISCALEDSIZE = 0x02E4 #EndRegion DPI Constants #Region WinAPI DPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi Func _WinAPI_AdjustWindowRectExForDpi($dpi, $dwStyle, $dwExStyle, $bMenu = False) Local $tRECT = DllStructCreate($tagRECT) Local $aResult = DllCall("user32.dll", "bool", "AdjustWindowRectExForDpi", "struct*", $tRECT, "dword", $dwStyle, "bool", $bMenu, "dword", $dwExStyle, "int", $dpi) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If $aResult[0] Then Return SetError(2, @extended, 0) Return $tRECT EndFunc ;==>_WinAPI_AdjustWindowRectExForDpi ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfofordpi Func _WinAPI_SystemParametersInfoForDpi($uiAction, $uiParam, $pvParam, $fWinIni, $dpi) Local $aResult = DllCall("user32.dll", "bool", "SystemParametersInfoForDpi", "uint", $uiAction, "uint", $uiParam, "struct*", $pvParam, "uint", $fWinIni, "uint", $dpi) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SystemParametersInfoForDpi ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-inheritwindowmonitor Func _WinAPI_InheritWindowMonitor($hWnd, $hWndInherit) Local $aResult = DllCall("user32.dll", "bool", "InheritWindowMonitor", "hwnd", $hWnd, "hwnd", $hWndInherit) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_InheritWindowMonitor ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-isvaliddpiawarenesscontext Func _WinAPI_IsValidDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "bool", "IsValidDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_IsValidDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-logicaltophysicalpointforpermonitordpi Func _WinAPI_LogicalToPhysicalPointForPerMonitorDPI($hWnd) Local $tPOINT = DllStructCreate($tagPOINT) Local $aResult = DllCall("user32.dll", "bool", "LogicalToPhysicalPointForPerMonitorDPI", "hwnd", $hWnd, "struct*", $tPOINT) ;requires Win 8.1+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $tPOINT EndFunc ;==>_WinAPI_LogicalToPhysicalPointForPerMonitorDPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-physicaltologicalpointforpermonitordpi Func _WinAPI_PhysicalToLogicalPointForPerMonitorDPI($hWnd) Local $tPOINT = DllStructCreate($tagPOINT) Local $aResult = DllCall("user32.dll", "bool", "PhysicalToLogicalPointForPerMonitorDPI", "hwnd", $hWnd, "struct*", $tPOINT) ;requires Win 8.1+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $tPOINT EndFunc ;==>_WinAPI_PhysicalToLogicalPointForPerMonitorDPI Func _GDIPlus_GetDPI($hGUI = 0) _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) If @error Then Return SetError(1, @extended, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Return $aResult[2] EndFunc ;==>_GDIPlus_GetDPI Func _WinAPI_GetDPI($hWnd = 0) $hWnd = Not $hWnd ? _WinAPI_GetDesktopWindow() : $hWnd Local Const $hDC = _WinAPI_GetDC($hWnd) If @error Then Return SetError(1, 0, 0) Local Const $iDPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSX) If @error Or Not $iDPI Then _WinAPI_ReleaseDC($hWnd, $hDC) Return SetError(2, 0, 0) EndIf _WinAPI_ReleaseDC($hWnd, $hDC) Return $iDPI EndFunc ;==>_WinAPI_GetDPI ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getdpiformonitor Func _WinAPI_GetDpiForPrimaryMonitor($hMOnitor = 0, $dpiType = $MDT_DEFAULT) If $hMOnitor = 0 Then Local $aMonitors = _WinAPI_EnumDisplayMonitors() If @error Or Not IsArray($aMonitors) Then Return SetError(1, 0, 0) Local $i For $i = 1 To $aMonitors[0][0] If _WinAPI_GetMonitorInfo($aMonitors[$i][0])[2] = 1 Then $hMOnitor = $aMonitors[$i][0] ExitLoop EndIf Next EndIf Local $tx = DllStructCreate("int dpiX"), $tY = DllStructCreate("int dpiY") Local $aResult = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "handle", $hMOnitor, "long", $dpiType, "struct*", $tx, "struct*", $tY) If @error Or Not IsArray($aResult) Then Return SetError(2, 0, 0) Return $tx.dpiX EndFunc ;==>_WinAPI_GetDpiForPrimaryMonitor ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow Func _WinAPI_GetDpiForWindow($hWnd) Local $aResult = DllCall("user32.dll", "uint", "GetDpiForWindow", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForWindow ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforsystem Func _WinAPI_GetDpiForSystem() Local $aResult = DllCall("user32.dll", "uint", "GetDpiForSystem") ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForSystem ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getthreaddpiawarenesscontext Func _WinAPI_GetThreadDpiAwarenessContext() Local $aResult = DllCall("user32.dll", "uint", "GetThreadDpiAwarenessContext") ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpifromdpiawarenesscontext Func _WinAPI_GetDpiFromDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "uint", "GetDpiFromDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiFromDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getawarenessfromdpiawarenesscontext Func _WinAPI_GetAwarenessFromDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "uint", "GetAwarenessFromDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetAwarenessFromDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiawarenesscontextforprocess Func _WinAPI_GetDpiAwarenessContextForProcess($hProcess) Local $aResult = DllCall("user32.dll", "uint", "GetDpiAwarenessContextForProcess", "handle", $hProcess) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiAwarenessContextForProcess ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemdpiforprocess Func _WinAPI_GetSystemDpiForProcess($hProcess) Local $aResult = DllCall("user32.dll", "uint", "GetSystemDpiForProcess", "handle", $hProcess) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetSystemDpiForProcess ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowdpiawarenesscontext Func _WinAPI_GetWindowDpiAwarenessContext($hWnd) Local $aResult = DllCall("user32.dll", "uint", "GetWindowDpiAwarenessContext", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetWindowDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext Func _WinAPI_SetThreadDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "uint", "SetThreadDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness Func _WinAPI_SetProcessDpiAwareness($PROCESS_DPI_AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE) Local $aResult = DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $PROCESS_DPI_AWARENESS) ;requires Win 8.1+ / Server 2012 R2+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If $aResult[0] Then Return SetError(2, $aResult[0], 0) Return $aResult[0] ;0 is S_OK EndFunc ;==>_WinAPI_SetProcessDpiAwareness Func _WinAPI_SetDPIAwareness($DPIAwareContext = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, $iMode = 1) Switch @OSBuild Case 6000 To 9199 Local $aResult = DllCall("user32.dll", "bool", "SetProcessDPIAware") ;requires Vista+ / Server 2008+ If Not $aResult[0] Then Return SetError(1, 0, 0) Case 9200 To 13999 $DPIAwareContext = ($DPIAwareContext < 0) ? 0 : ($DPIAwareContext > 2) ? 2 : $DPIAwareContext _WinAPI_SetProcessDpiAwareness($DPIAwareContext) If @error Then Return SetError(2, @error, 0) Case @OSBuild > 13999 $DPIAwareContext = ($DPIAwareContext < -5) ? -5 : ($DPIAwareContext > -1) ? -1 : $DPIAwareContext $iMode = ($iMode < 1) ? 1 : ($iMode > 2) ? 2 : $iMode Local $iResult Switch $iMode Case 1 $iResult = _WinAPI_SetProcessDpiAwarenessContext($DPIAwareContext) If Not $iResult Or @error Then Return SetError(3, 0, 0) Case 2 #cs Return DPI_AWARENESS_CONTEXT values $DPI_AWARENESS_CONTEXT_UNAWARE = 0x6010 / 24592 $DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 0x9011 / 36881 $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 0x12 / 18 $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 0x22 / 34 $DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = 0x40006010 / 1073766416 #ce $iResult = _WinAPI_SetThreadDpiAwarenessContext($DPIAwareContext) If Not $iResult Or @error Then Return SetError(4, 0, 0) EndSwitch EndSwitch Local $iDPI If @OSBuild < 9200 Then $iDPI = _WinAPI_GetDPI() If @error Or Not $iDPI Then Return SetError(5, 0, 0) Else $iDPI = _WinAPI_GetDpiForPrimaryMonitor() If @error Or Not $iDPI Then Return SetError(6, 0, 0) EndIf Return $iDPI EndFunc ;==>_WinAPI_SetDPIAwareness #EndRegion WinAPI DPI Example.au3: ; AutoIt GUI Example ; Created: 17/01/2005 - CyberSlug ; Modifed: 05/12/2011 - guinness ; Modifed: 09/06/2014 - mLipok ; Modifed: 15/10/2018 - mLipok ; Modifed: 14/08/2023 - UEZ #AutoIt3Wrapper_Change2CUI=n #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so #AutoIt3Wrapper_Res_HiDpi=n ;must be n otherwise _WinAPI_SetDPIAwareness() function will fail! #AutoIt3Wrapper_UseX64=n #Region INCLUDE #include <AVIConstants.au3> #include <GuiConstantsEx.au3> #include <TreeViewConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdiDC.au3> #include <WindowsConstants.au3> #include "_WinAPI_DPI.au3" #EndRegion INCLUDE #Region INITIALIZATION and EXIT Global $aCtrl[43][6], $ahWnd[2][10], $g_iDPI_ratio1, $g_iDPI_ratio2, $iw = 400, $ih = 200 _Example() ; Finished! #EndRegion INITIALIZATION and EXIT Func _Example() Local $AWARENESS Switch @OSBuild Case 9200 To 13999 $AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE Case @OSBuild > 13999 $AWARENESS = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 EndSwitch Local $iDPI = _WinAPI_SetDPIAwareness($AWARENESS, 2), $iDPI_def = 96 If $iDPI = 0 Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to set DPI awareness!!!", 10) $g_iDPI_ratio1 = $iDPI / $iDPI_def $g_iDPI_ratio2 = $iDPI_def / $iDPI #Region GUI Local $sPath = RegRead("HKLM\SOFTWARE\" & (@AutoItX64 ? "WOW6432Node\" : "") & "AutoIt v3\AutoIt", "InstallDir") $sPath = ($sPath = "" ? @ProgramFilesDir & "\AutoIt3\" : $sPath & "\") ;assume default path $ahWnd[0][1] = 8.5 * $g_iDPI_ratio1 $ahWnd[0][0] = GUICreate("DPI Sample GUI", 400 * $g_iDPI_ratio1, 400 * $g_iDPI_ratio1) GUISetIcon(@SystemDir & "\mspaint.exe", 0) GUISetFont($ahWnd[0][1], 400, 0, "Arial", $ahWnd[0][0], $CLEARTYPE_QUALITY) #EndRegion GUI #Region MENU $aCtrl[1][0] = GUICtrlCreateMenu("Menu &One") $aCtrl[2][0] = GUICtrlCreateMenu("Menu &Two") $aCtrl[3][0] = GUICtrlCreateMenu("Menu Th&ree") $aCtrl[4][0] = GUICtrlCreateMenu("Menu &Four") GUICtrlCreateMenuItem('SubMenu One &A', $aCtrl[1][0]) GUICtrlCreateMenuItem('SubMenu One &B', $aCtrl[1][0]) #EndRegion MENU #Region CONTEXT MENU $aCtrl[5][0] = GUICtrlCreateContextMenu() GUICtrlCreateMenuItem("Context Menu", $aCtrl[5][0]) GUICtrlCreateMenuItem("", $aCtrl[5][0]) ; Separator GUICtrlCreateMenuItem("&Properties", $aCtrl[5][0]) #EndRegion CONTEXT MENU #Region PIC $aCtrl[6][2] = 0 ;x $aCtrl[6][3] = 0 ;y $aCtrl[6][4] = 169 ;w $aCtrl[6][5] = 68 ;h $aCtrl[6][0] = GUICtrlCreatePic($sPath & "Examples\GUI\logo4.gif", $aCtrl[6][2] * $g_iDPI_ratio1, $aCtrl[6][3] * $g_iDPI_ratio1, $aCtrl[6][4] * $g_iDPI_ratio1, $aCtrl[6][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region PIC') $aCtrl[7][2] = 75 $aCtrl[7][3] = 1 $aCtrl[7][4] = 80 $aCtrl[7][5] = 16 $aCtrl[7][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[7][0] = GUICtrlCreateLabel("Sample Pic", $aCtrl[7][2] * $g_iDPI_ratio1, $aCtrl[7][3] * $g_iDPI_ratio1, $aCtrl[7][4] * $g_iDPI_ratio1, $aCtrl[7][5] * $g_iDPI_ratio1) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, $aCtrl[7][1] * $g_iDPI_ratio1) #EndRegion PIC #Region AVI $aCtrl[8][2] = 180 $aCtrl[8][3] = 10 $aCtrl[8][4] = 32 $aCtrl[8][5] = 32 $aCtrl[8][0] = GUICtrlCreateAvi($sPath & "Examples\GUI\SampleAVI.avi", 0, $aCtrl[8][2] * $g_iDPI_ratio1, $aCtrl[8][3] * $g_iDPI_ratio1, $aCtrl[8][4] * $g_iDPI_ratio1, $aCtrl[8][5] * $g_iDPI_ratio1, $ACS_AUTOPLAY) GUICtrlSetTip(-1, '#Region AVI') ; TODO $aCtrl[9][2] = 175 $aCtrl[9][3] = 50 $aCtrl[9][4] = 50 $aCtrl[9][5] = 12 $aCtrl[9][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[9][0] = GUICtrlCreateLabel("Sample avi", $aCtrl[9][2] * $g_iDPI_ratio1, $aCtrl[9][3] * $g_iDPI_ratio1, $aCtrl[9][4] * $g_iDPI_ratio1, $aCtrl[9][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region AVI - Label') GUICtrlSetFont(-1, $aCtrl[9][1] * $g_iDPI_ratio1) #EndRegion AVI #Region TAB $aCtrl[10][2] = 240 $aCtrl[10][3] = 0 $aCtrl[10][4] = 150 $aCtrl[10][5] = 70 $aCtrl[10][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[10][0] = GUICtrlCreateTab($aCtrl[10][2] * $g_iDPI_ratio1, $aCtrl[10][3] * $g_iDPI_ratio1, $aCtrl[10][4] * $g_iDPI_ratio1, $aCtrl[10][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[10][1] * $g_iDPI_ratio1) $aCtrl[11][0] = GUICtrlCreateTabItem("One") GUICtrlSetTip(-1, '#Region TAB1') $aCtrl[12][2] = 244 $aCtrl[12][3] = 35 $aCtrl[12][4] = 140 $aCtrl[12][5] = 24 $aCtrl[12][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[12][0] = GUICtrlCreateLabel("Sample Tab with TabItems", $aCtrl[12][2] * $g_iDPI_ratio1, $aCtrl[12][3] * $g_iDPI_ratio1, $aCtrl[12][4] * $g_iDPI_ratio1, $aCtrl[12][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[12][1] * $g_iDPI_ratio1) $aCtrl[13][0] = GUICtrlCreateTabItem("Two") GUICtrlSetTip(-1, '#Region TAB2') $aCtrl[14][0] = GUICtrlCreateTabItem("Three") GUICtrlSetTip(-1, '#Region TAB3') GUICtrlCreateTabItem("") #EndRegion TAB #Region COMBO $aCtrl[15][2] = 250 $aCtrl[15][3] = 80 $aCtrl[15][4] = 120 $aCtrl[15][5] = 100 $aCtrl[15][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[15][0] = GUICtrlCreateCombo("Sample Combo", $aCtrl[15][2] * $g_iDPI_ratio1, $aCtrl[15][3] * $g_iDPI_ratio1, $aCtrl[15][4] * $g_iDPI_ratio1, $aCtrl[15][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region COMBO') GUICtrlSetFont(-1, $aCtrl[15][1] * $g_iDPI_ratio1) #EndRegion COMBO #Region PROGRESS $aCtrl[16][2] = 60 $aCtrl[16][3] = 80 $aCtrl[16][4] = 150 $aCtrl[16][5] = 20 $aCtrl[16][0] = GUICtrlCreateProgress($aCtrl[16][2] * $g_iDPI_ratio1, $aCtrl[16][3] * $g_iDPI_ratio1, $aCtrl[16][4] * $g_iDPI_ratio1, $aCtrl[16][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region PROGRES') GUICtrlSetData(-1, 60) $aCtrl[17][2] = 5 $aCtrl[17][3] = 82 $aCtrl[17][4] = 50 $aCtrl[17][5] = 18 $aCtrl[17][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[17][0] = GUICtrlCreateLabel("Progress:", $aCtrl[17][2] * $g_iDPI_ratio1, $aCtrl[17][3] * $g_iDPI_ratio1, $aCtrl[17][4] * $g_iDPI_ratio1, $aCtrl[17][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region PROGRES - Label') GUICtrlSetFont(-1, $aCtrl[17][1] * $g_iDPI_ratio1) #EndRegion PROGRESS #Region EDIT $aCtrl[18][2] = 10 $aCtrl[18][3] = 110 $aCtrl[18][4] = 150 $aCtrl[18][5] = 70 $aCtrl[18][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[18][0] = GUICtrlCreateEdit(@CRLF & " Sample Edit Control", $aCtrl[18][2] * $g_iDPI_ratio1, $aCtrl[18][3] * $g_iDPI_ratio1, $aCtrl[18][4] * $g_iDPI_ratio1, $aCtrl[18][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region EDIT') GUICtrlSetFont(-1, $aCtrl[18][1] * $g_iDPI_ratio1) #EndRegion EDIT #Region LIST $aCtrl[19][2] = 5 $aCtrl[19][3] = 190 $aCtrl[19][4] = 100 $aCtrl[19][5] = 90 $aCtrl[19][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[19][0] = GUICtrlCreateList("", $aCtrl[19][2] * $g_iDPI_ratio1, $aCtrl[19][3] * $g_iDPI_ratio1, $aCtrl[19][4] * $g_iDPI_ratio1, $aCtrl[19][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[19][1] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region LIST') GUICtrlSetData(-1, "A.Sample|B.List|C.Control|D.Here", "B.List") #EndRegion LIST #Region ICON $aCtrl[20][2] = 175 $aCtrl[20][3] = 120 $aCtrl[20][4] = 32 $aCtrl[20][5] = 32 $aCtrl[20][0] = GUICtrlCreateIcon("explorer.exe", 0, $aCtrl[20][2] * $g_iDPI_ratio1, $aCtrl[20][3] * $g_iDPI_ratio1, $aCtrl[20][4] * $g_iDPI_ratio1, $aCtrl[20][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region ICON') $aCtrl[21][2] = 180 $aCtrl[21][3] = 160 $aCtrl[21][4] = 50 $aCtrl[21][5] = 20 $aCtrl[21][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[21][0] = GUICtrlCreateLabel("Icon", $aCtrl[21][2] * $g_iDPI_ratio1, $aCtrl[21][3] * $g_iDPI_ratio1, $aCtrl[21][4] * $g_iDPI_ratio1, $aCtrl[21][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region ICON - Label') GUICtrlSetFont(-1, $aCtrl[21][1] * $g_iDPI_ratio1) #EndRegion ICON #Region LIST VIEW $aCtrl[22][2] = 110 $aCtrl[22][3] = 190 $aCtrl[22][4] = 110 $aCtrl[22][5] = 80 $aCtrl[22][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[22][0] = GUICtrlCreateListView("Sample|ListView|", $aCtrl[22][2] * $g_iDPI_ratio1, $aCtrl[22][3] * $g_iDPI_ratio1, $aCtrl[22][4] * $g_iDPI_ratio1, $aCtrl[22][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region LIST VIEW') GUICtrlSetFont(-1, $aCtrl[22][1] * $g_iDPI_ratio1) GUICtrlCreateListViewItem("A|One", $aCtrl[22][0]) GUICtrlCreateListViewItem("B|Two", $aCtrl[22][0]) GUICtrlCreateListViewItem("C|Three", $aCtrl[22][0]) #EndRegion LIST VIEW #Region GROUP WITH RADIO BUTTONS $aCtrl[23][2] = 230 $aCtrl[23][3] = 120 $aCtrl[23][4] = 110 $aCtrl[23][5] = 80 $aCtrl[23][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[23][0] = GUICtrlCreateGroup("Sample Group", $aCtrl[23][2] * $g_iDPI_ratio1, $aCtrl[23][3] * $g_iDPI_ratio1, $aCtrl[23][4] * $g_iDPI_ratio1, $aCtrl[23][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[22][1] * $g_iDPI_ratio1) $aCtrl[24][2] = 250 $aCtrl[24][3] = 140 $aCtrl[24][4] = 80 $aCtrl[24][5] = 32 $aCtrl[24][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[24][0] = GUICtrlCreateRadio("Radio One", $aCtrl[24][2] * $g_iDPI_ratio1, $aCtrl[24][3] * $g_iDPI_ratio1, $aCtrl[24][4] * $g_iDPI_ratio1, $aCtrl[24][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO1') GUICtrlSetFont(-1, $aCtrl[24][1] * $g_iDPI_ratio1) GUICtrlSetState(-1, $GUI_CHECKED) $aCtrl[25][2] = 250 $aCtrl[25][3] = 165 $aCtrl[25][4] = 80 $aCtrl[25][5] = 32 $aCtrl[25][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[25][0] = GUICtrlCreateRadio("Radio Two", $aCtrl[25][2] * $g_iDPI_ratio1, $aCtrl[25][3] * $g_iDPI_ratio1, $aCtrl[25][4] * $g_iDPI_ratio1, $aCtrl[25][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO2') GUICtrlSetFont(-1, $aCtrl[25][1] * $g_iDPI_ratio1) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group #EndRegion GROUP WITH RADIO BUTTONS #Region UPDOWN $aCtrl[26][2] = 350 $aCtrl[26][3] = 113 $aCtrl[26][4] = 40 $aCtrl[26][5] = 12 $aCtrl[26][1] = 8 * $g_iDPI_ratio2 $aCtrl[26][0] = GUICtrlCreateLabel("UpDown", $aCtrl[26][2] * $g_iDPI_ratio1, $aCtrl[26][3] * $g_iDPI_ratio1, $aCtrl[26][4] * $g_iDPI_ratio1, $aCtrl[26][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region UPDOWN - Label') GUICtrlSetFont(-1, $aCtrl[26][1] * $g_iDPI_ratio1) $aCtrl[27][2] = 350 $aCtrl[27][3] = 130 $aCtrl[27][4] = 40 $aCtrl[27][5] = 20 $aCtrl[27][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[27][0] = GUICtrlCreateInput("42", $aCtrl[27][2] * $g_iDPI_ratio1, $aCtrl[27][3] * $g_iDPI_ratio1, $aCtrl[27][4] * $g_iDPI_ratio1, $aCtrl[27][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region UPDOWN - Input') GUICtrlSetFont(-1, $aCtrl[27][1] * $g_iDPI_ratio1) $aCtrl[28][0] = GUICtrlCreateUpdown(-1) GUICtrlSetTip(-1, '#Region UPDOWN - Updown') #EndRegion UPDOWN #Region LABEL $aCtrl[29][2] = 350 $aCtrl[29][3] = 165 $aCtrl[29][4] = 40 $aCtrl[29][5] = 40 $aCtrl[29][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[29][0] = GUICtrlCreateLabel("Green" & @CRLF & "Label", $aCtrl[29][2] * $g_iDPI_ratio1, $aCtrl[29][3] * $g_iDPI_ratio1, $aCtrl[29][4] * $g_iDPI_ratio1, $aCtrl[29][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region LABEL') GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetFont(-1, $aCtrl[29][1] * $g_iDPI_ratio1) #EndRegion LABEL #Region SLIDER $aCtrl[30][2] = 235 $aCtrl[30][3] = 215 $aCtrl[30][4] = 40 $aCtrl[30][5] = 16 $aCtrl[30][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[30][0] = GUICtrlCreateLabel("Slider:", $aCtrl[30][2] * $g_iDPI_ratio1, $aCtrl[30][3] * $g_iDPI_ratio1, $aCtrl[30][4] * $g_iDPI_ratio1, $aCtrl[30][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region SLIDER - Label') GUICtrlSetFont(-1, $aCtrl[30][1] * $g_iDPI_ratio1) $aCtrl[31][2] = 270 $aCtrl[31][3] = 210 $aCtrl[31][4] = 120 $aCtrl[31][5] = 30 $aCtrl[31][0] = GUICtrlCreateSlider($aCtrl[31][2] * $g_iDPI_ratio1, $aCtrl[31][3] * $g_iDPI_ratio1, $aCtrl[31][4] * $g_iDPI_ratio1, $aCtrl[31][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region SLIDER') GUICtrlSetData(-1, 30) #EndRegion SLIDER #Region INPUT $aCtrl[32][2] = 235 $aCtrl[32][3] = 255 $aCtrl[32][4] = 130 $aCtrl[32][5] = 20 $aCtrl[32][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[32][0] = GUICtrlCreateInput("Sample Input Box", $aCtrl[32][2] * $g_iDPI_ratio1, $aCtrl[32][3] * $g_iDPI_ratio1, $aCtrl[32][4] * $g_iDPI_ratio1, $aCtrl[32][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region INPUT') GUICtrlSetFont(-1, $aCtrl[32][1] * $g_iDPI_ratio1) #EndRegion INPUT #Region DATE $aCtrl[33][2] = 5 $aCtrl[33][3] = 280 $aCtrl[33][4] = 200 $aCtrl[33][5] = 20 $aCtrl[33][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[33][0] = GUICtrlCreateDate("", $aCtrl[33][2] * $g_iDPI_ratio1, $aCtrl[33][3] * $g_iDPI_ratio1, $aCtrl[33][4] * $g_iDPI_ratio1, $aCtrl[33][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region DATE') GUICtrlSetFont(-1, $aCtrl[33][1] * $g_iDPI_ratio1) $aCtrl[34][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[34][2] = 10 $aCtrl[34][3] = 305 $aCtrl[34][4] = 200 $aCtrl[34][5] = 20 $aCtrl[34][0] = GUICtrlCreateLabel("(Date control expands into a calendar)", $aCtrl[34][2] * $g_iDPI_ratio1, $aCtrl[34][3] * $g_iDPI_ratio1, $aCtrl[34][4] * $g_iDPI_ratio1, $aCtrl[34][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region DATE - Label') GUICtrlSetFont(-1, $aCtrl[34][1] * $g_iDPI_ratio1) #EndRegion DATE #Region BUTTON $aCtrl[35][2] = 10 $aCtrl[35][3] = 330 $aCtrl[35][4] = 100 $aCtrl[35][5] = 30 $aCtrl[35][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[35][0] = GUICtrlCreateButton("Click me :-)", $aCtrl[35][2] * $g_iDPI_ratio1, $aCtrl[35][3] * $g_iDPI_ratio1, $aCtrl[35][4] * $g_iDPI_ratio1, $aCtrl[35][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region BUTTON') GUICtrlSetFont(-1, $aCtrl[35][1] * $g_iDPI_ratio1) #EndRegion BUTTON #Region CHECKBOX $aCtrl[36][2] = 130 $aCtrl[36][3] = 335 $aCtrl[36][4] = 80 $aCtrl[36][5] = 20 $aCtrl[36][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[36][0] = GUICtrlCreateCheckbox("Checkbox", $aCtrl[36][2] * $g_iDPI_ratio1, $aCtrl[36][3] * $g_iDPI_ratio1, $aCtrl[36][4] * $g_iDPI_ratio1, $aCtrl[36][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region CHECKBOX') GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetFont(-1, $aCtrl[36][1] * $g_iDPI_ratio1) #EndRegion CHECKBOX #Region TREEVIEW ONE $aCtrl[37][2] = 210 $aCtrl[37][3] = 290 $aCtrl[37][4] = 80 $aCtrl[37][5] = 80 $aCtrl[37][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[37][0] = GUICtrlCreateTreeView($aCtrl[37][2] * $g_iDPI_ratio1, $aCtrl[37][3] * $g_iDPI_ratio1, $aCtrl[37][4] * $g_iDPI_ratio1, $aCtrl[37][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region TREEVIEW ONE') GUICtrlSetFont(-1, $aCtrl[37][1] * $g_iDPI_ratio1) $aCtrl[38][0] = GUICtrlCreateTreeViewItem("TreeView", $aCtrl[37][0]) GUICtrlCreateTreeViewItem("Item1", $aCtrl[38][0]) GUICtrlCreateTreeViewItem("Item2", $aCtrl[38][0]) GUICtrlCreateTreeViewItem("Foo", -1) GUICtrlSetState($aCtrl[38][0], $GUI_EXPAND) #EndRegion TREEVIEW ONE #Region TREEVIEW TWO $aCtrl[39][2] = 295 $aCtrl[39][3] = 290 $aCtrl[39][4] = 103 $aCtrl[39][5] = 80 $aCtrl[39][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[39][0] = GUICtrlCreateTreeView($aCtrl[39][2] * $g_iDPI_ratio1, $aCtrl[39][3] * $g_iDPI_ratio1, $aCtrl[39][4] * $g_iDPI_ratio1, $aCtrl[39][5] * $g_iDPI_ratio1, $TVS_CHECKBOXES) GUICtrlSetTip(-1, '#Region TREEVIEW TWO') GUICtrlSetFont(-1, $aCtrl[39][1] * $g_iDPI_ratio1) GUICtrlCreateTreeViewItem("TreeView", $aCtrl[39][0]) GUICtrlCreateTreeViewItem("With", $aCtrl[39][0]) GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $aCtrl[39][0]) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateTreeViewItem("Style", $aCtrl[39][0]) #EndRegion TREEVIEW TWO #Region GUI MESSAGE LOOP GUISetState(@SW_SHOW) If @OSBuild > 9599 Then GUIRegisterMsg($WM_DPICHANGED, "WM_DPICHANGED") ;requires Win 8.1+ / Server 2012 R2+ GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "WM_SIZE") Local $hGUI_child, $hImage, $hGDIBitmap, $hGfx, $hPath, $hFamily, $hFormat, $tLayout, $hPen, $hBrush, $hB, $aGUIGetMsg _GDIPlus_Startup() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_ImageDispose ($hImage) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() GUIRegisterMsg($WM_DPICHANGED, "") GUIRegisterMsg(WM_GETMINMAXINFO, "") GUIRegisterMsg(WM_SIZE, "") GUIDelete() Exit Case $aCtrl[35][0] If $hImage Then $hImage = _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_BitmapCreateFromScan0($iw * $g_iDPI_ratio1, $ih * $g_iDPI_ratio1) If $hGfx Then _GDIPlus_GraphicsDispose($hGfx) $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, $GDIP_TEXTRENDERINGHINTANTIALIAS) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hGfx, 0xFFF0F0F0) If $hPath Then _GDIPlus_PathDispose($hPath) $hPath = _GDIPlus_PathCreate() If $hFamily Then _GDIPlus_FontFamilyDispose($hFamily) $hFamily = _GDIPlus_FontFamilyCreate("Arial") If $hFormat Then _GDIPlus_StringFormatDispose($hFormat) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) $tLayout = _GDIPlus_RectFCreate(0, 0, $iw * $g_iDPI_ratio1, $ih * $g_iDPI_ratio1) _GDIPlus_PathAddString($hPath, "Hello World!", $tLayout, $hFamily, 0, 50 * $g_iDPI_ratio1, $hFormat) If $hPen Then _GDIPlus_PenDispose($hPen) $hPen = _GDIPlus_PenCreate(0xFF000000, 8) _GDIPlus_PenSetLineJoin($hPen, 2) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) If $hBrush Then _GDIPlus_BrushDispose($hBrush) $hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush) If $hGDIBitmap Then _WinAPI_DeleteObject($hGDIBitmap) $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) Local $aGUI_Pos = WinGetPos($ahWnd[0][0]) $ahWnd[1][0] = GUICreate("GDI+ Child Window", $iw * $g_iDPI_ratio1, $ih * $g_iDPI_ratio1, $aGUI_Pos[0] - ($aGUI_Pos[2] - $iw * $g_iDPI_ratio1) / 2, $aGUI_Pos[1] + $ih * $g_iDPI_ratio1 / 2, $WS_SIZEBOX, -1, $ahWnd[0][0]) $aCtrl[40][2] = 0 $aCtrl[40][3] = 0 $aCtrl[40][4] = $iw $aCtrl[40][5] = $ih $aCtrl[40][0] = GUICtrlCreatePic("", $aCtrl[40][2], $aCtrl[40][3], $aCtrl[40][4] * $g_iDPI_ratio1, $aCtrl[40][5] * $g_iDPI_ratio1) _WinAPI_DeleteObject(GUICtrlSendMsg($aCtrl[40][0], $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) GUISetState(@SW_SHOW, $ahWnd[1][0]) While 1 $aGUIGetMsg = GUIGetMsg(1) Switch $aGUIGetMsg[1] Case $ahWnd[1][0] Switch $aGUIGetMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($ahWnd[1][0]) ExitLoop EndSwitch EndSwitch WEnd EndSwitch WEnd #EndRegion GUI MESSAGE LOOP EndFunc ;==>_Example Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Switch $hWnd Case $ahWnd[1][0] Local $aSize = ControlGetPos($ahWnd[1][0], "", $aCtrl[40][0]) $aCtrl[40][2] = $aSize[0] $aCtrl[40][3] = $aSize[1] $aCtrl[40][4] = _WinAPI_LoWord($lParam) $aCtrl[40][5] = _WinAPI_HiWord($lParam) GUICtrlSetPos($aCtrl[40][0], $aCtrl[40][2], $aCtrl[40][3], $aCtrl[40][4], $aCtrl[40][5]) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) If $hWnd = $ahWnd[1][0] Then Local $minmaxinfo = DllStructCreate("long ptReservedX;long ptReservedY;long ptMaxSizeX; long ptMaxSizeY;long ptMaxPositionX;long ptMaxPositionY;long ptMinTrackSizeX;long ptMinTrackSizeY;long ptMaxTrackSizeX;long ptMaxTrackSizeY ", $lParam) $minmaxinfo.ptMinTrackSizeX = $iw / 2 $minmaxinfo.ptMinTrackSizeY = $ih / 2 $minmaxinfo.ptMaxTrackSizeX = $iw * 3 $minmaxinfo.ptMaxTrackSizeY = $ih * 3 EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_GETMINMAXINFO Func WM_DPICHANGED($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg Local $iDPI = _WinAPI_LoWord($wParam) ConsoleWrite("DPI change triggered! DPI: " & $iDPI & @CRLF) $g_iDPI_ratio1 = $iDPI / 96 $g_iDPI_ratio2 = $g_iDPI_ratio1 ^ -1 Local $tRECT = DllStructCreate($tagRECT, $lParam) Local $iX = $tRECT.left, $iY = $tRECT.top, $iW = $tRECT.right - $iX, $iH = $tRECT.bottom - $iY, $i Switch $hWnd Case $ahWnd[0][0] _WinAPI_SetWindowPos($ahWnd[0][0], 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) For $i = 0 To 39 If $aCtrl[$i][1] Then GUICtrlSetFont($aCtrl[$i][0], $aCtrl[$i][1] * $g_iDPI_ratio1) If $aCtrl[$i][4] Then GUICtrlSetPos($aCtrl[$i][0], $aCtrl[$i][2] * $g_iDPI_ratio1, $aCtrl[$i][3] * $g_iDPI_ratio1, $aCtrl[$i][4] * $g_iDPI_ratio1, $aCtrl[$i][5] * $g_iDPI_ratio1) Next _WinAPI_UpdateWindow($ahWnd[0][0]) Case $ahWnd[1][0] $i = 40 _WinAPI_SetWindowPos($ahWnd[1][0], 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) GUICtrlSetPos($aCtrl[$i][0], $aCtrl[$i][2], $aCtrl[$i][3], $aCtrl[$i][4], $aCtrl[$i][5]) _WinAPI_UpdateWindow($ahWnd[1][0]) EndSwitch Return 1 EndFunc ;==>WM_DPICHANGED THX.1 point
-
I very offen wonders which values gives particular macro. For example: do I should use @AppDataDir or @LocalAppDataDir or @UserProfileDir Here is my Show_Macro_Values.au3script: ConsoleWrite('@AppDataCommonDir : ' & @AppDataCommonDir & @CRLF) ConsoleWrite('@AppDataDir : ' & @AppDataDir & @CRLF) ConsoleWrite('@AutoItExe : ' & @AutoItExe & @CRLF) ConsoleWrite('@AutoItPID : ' & @AutoItPID & @CRLF) ConsoleWrite('@AutoItVersion : ' & @AutoItVersion & @CRLF) ConsoleWrite('@AutoItX64 : ' & @AutoItX64 & @CRLF) ConsoleWrite('@CommonFilesDir : ' & @CommonFilesDir & @CRLF) ConsoleWrite('@Compiled : ' & @Compiled & @CRLF) ConsoleWrite('@ComputerName : ' & @ComputerName & @CRLF) ConsoleWrite('@ComSpec : ' & @ComSpec & @CRLF) ConsoleWrite('@CPUArch : ' & @CPUArch & @CRLF) ConsoleWrite('@DesktopCommonDir : ' & @DesktopCommonDir & @CRLF) ConsoleWrite('@DesktopDepth : ' & @DesktopDepth & @CRLF) ConsoleWrite('@DesktopDir : ' & @DesktopDir & @CRLF) ConsoleWrite('@DesktopHeight : ' & @DesktopHeight & @CRLF) ConsoleWrite('@DesktopRefresh : ' & @DesktopRefresh & @CRLF) ConsoleWrite('@DesktopWidth : ' & @DesktopWidth & @CRLF) ConsoleWrite('@DocumentsCommonDir : ' & @DocumentsCommonDir & @CRLF) ConsoleWrite('@FavoritesCommonDir : ' & @FavoritesCommonDir & @CRLF) ConsoleWrite('@FavoritesDir : ' & @FavoritesDir & @CRLF) ConsoleWrite('@HomeDrive : ' & @HomeDrive & @CRLF) ConsoleWrite('@HomePath : ' & @HomePath & @CRLF) ConsoleWrite('@HomeDrive : ' & @HomeDrive & @CRLF) ConsoleWrite('@HomeShare : ' & @HomeShare & @CRLF) ConsoleWrite('@LocalAppDataDir : ' & @LocalAppDataDir & @CRLF) ConsoleWrite('@LogonDNSDomain : ' & @LogonDNSDomain & @CRLF) ConsoleWrite('@LogonDomain : ' & @LogonDomain & @CRLF) ConsoleWrite('@LogonServer : ' & @LogonServer & @CRLF) ConsoleWrite('@MyDocumentsDir : ' & @MyDocumentsDir & @CRLF) ConsoleWrite('@OSArch : ' & @OSArch & @CRLF) ConsoleWrite('@OSBuild : ' & @OSBuild & @CRLF) ConsoleWrite('@OSLang : ' & @OSLang & @CRLF) ConsoleWrite('@OSServicePack : ' & @OSServicePack & @CRLF) ConsoleWrite('@OSType : ' & @OSType & @CRLF) ConsoleWrite('@OSVersion : ' & @OSVersion & @CRLF) ConsoleWrite('@ProgramFilesDir : ' & @ProgramFilesDir & @CRLF) ConsoleWrite('@ProgramsCommonDir : ' & @ProgramsCommonDir & @CRLF) ConsoleWrite('@ProgramsDir : ' & @ProgramsDir & @CRLF) ConsoleWrite('@ScriptFullPath : ' & @ScriptFullPath & @CRLF) ConsoleWrite('@ScriptDir : ' & @ScriptDir & @CRLF) ConsoleWrite('@ScriptName : ' & @ScriptName & @CRLF) ConsoleWrite('@ScriptLineNumber : ' & @ScriptLineNumber & @CRLF) ConsoleWrite('@StartMenuCommonDir : ' & @StartMenuCommonDir & @CRLF) ConsoleWrite('@StartMenuDir : ' & @StartMenuDir & @CRLF) ConsoleWrite('@StartupCommonDir : ' & @StartupCommonDir & @CRLF) ConsoleWrite('@StartupDir : ' & @StartupDir & @CRLF) ConsoleWrite('@SystemDir : ' & @SystemDir & @CRLF) ConsoleWrite('@TempDir : ' & @TempDir & @CRLF) ConsoleWrite('@UserName : ' & @UserName & @CRLF) ConsoleWrite('@UserProfileDir : ' & @UserProfileDir & @CRLF) ConsoleWrite('@WindowsDir : ' & @WindowsDir & @CRLF)1 point
-
Version 1.6.1.0
2,814 downloads
Extensive library to control and manipulate Microsoft Task Scheduler Service. Please check this site for the implementation status! Please check the History.txt file in the archive for the changelog. Please check the WIKI for details about how to use the UDF. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2021-02-03) None Things to come (last changed: 2021-02-03) None1 point -
Sers, while working on another project I was in need of desktop notifications. I wanted an own implementation and from time to time the code grew and I thought about sharing it with the world. I know that there is a similar UDF out there but when my project got bigger an UDF was the best choice for me. As you can see the UDF's differ in usage and style of notifications. So, what do we have? The UDF offers the usage of permanent desktop notifications for your own script in a very easy way. Notifications are starting in the bottom right corner of your main screen and will be shown on top until there is no more space. Further notifications will be shown if previous ones are closed. The notifications have a nice minimalistic design in two colors. By default they match the look of the dark taskbar in Windows 10, but colors and other things can be set differently if wished (see example scripts). The UDF works for GUIOnEventMode activated and deactivated and detects it automatically. Show me! Each notification has its GUI, a title, the message, a seperating line, date label, time label and a closing button (and if activated, a border around the notification). The color of the title, message, seperating line, date, time and closing button (+ border if activated) have all the text color. Right now notifications have a fixed size. I thought about variable sizes but did not add it because I didn't need it so far. Some people may notice the shorter seperating line when border is activated, thats just because of better looks Notifications will be colored as the following: Windows 10: they match the design of the taskbar Windows 8/8.1: On most designs: they match the border color of active windows, else they are black with transparency (see screenshot) Windows 7 and earlier: black with transparency (sry aero) How do I use notifications in my script? include UDF call _Notifications_Startup() (after you determined if you want to use GUIOnEventMode or not) If GUIOneventMode deactivated: call _Notifications_CheckGUIMsg($__GUIMsg) in your main loop create a notification using _Notifications_Create($__title, $__message) Between step 2 and 3 you can set various options: _Notifications_SetAnimationTime _Notifications_SetBorder _Notifications_SetButtonText _Notifications_SetBkColor _Notifications_SetColor _Notifications_SetDateFormat _Notifications_SetSound _Notifications_SetTextAlign _Notifications_SetTimeFormat _Notifications_SetTransparency You can also set own functions to be called when notifications are clicked (see advanced example). And now? You can find more information in the UDF. There also are two example scripts to show the usage for GUIOnEventMode activated and deactivated. Another advanced example shows the usage of the Set-Functions. Thats it? Yup, have fun. Changelog Notifications.au3 ( v1.2) Notifications GUIMsg Example.au3 Notifications OnEvent Example.au3 Notifications Advanced Example.au31 point
-
3D Pie Chart
pat4005 reacted to WideBoyDixon for a topic
I've revamped this so that it doesn't "cheat" any more but instead creates a fills paths properly. This should be a bit quicker to draw and the result looks a bit nicer I think. In addition, I've added the capability to display the pie as a 2D donut with a configurable hole size in the middle. The sliders at the bottom can be used to rotate the pie chart and also to change the aspect (but not for a donut). The third slider changes the hole size. #include <GDIPlus.au3> #include <WinAPI.au3> #include <GUISlider.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> ; Let's be strict here Opt("MustDeclareVars", 1) ; Controls the size of the pie and also the depth Global Const $PIE_DIAMETER = 400 Global Const $PIE_MARGIN = $PIE_DIAMETER * 0.025 Global Const $PIE_DEPTH = $PIE_DIAMETER * 0.2 Global Const $PIE_AREA = $PIE_DIAMETER + 2 * $PIE_MARGIN ; Random data for values and colours Global Const $NUM_VALUES = 8 Global $aChartValue[$NUM_VALUES] Global $aChartColour[$NUM_VALUES] For $i = 0 To $NUM_VALUES - 1 $aChartValue[$i] = Random(5, 25, 1) $aChartColour[$i] = (Random(0, 255, 1) * 0x10000) + (Random(0, 255, 1) * 0x100) + Random(0, 255, 1) Next ; The value of PI Global Const $PI = ATan(1) * 4 ; Start GDI+ _GDIPlus_Startup() ; Create the brushes and pens Global $ahBrush[$NUM_VALUES][2], $ahPen[$NUM_VALUES] For $i = 0 To $NUM_VALUES - 1 $ahBrush[$i][0] = _GDIPlus_BrushCreateSolid(BitOR(0xff000000, $aChartColour[$i])) $ahBrush[$i][1] = _GDIPlus_BrushCreateSolid(BitOR(0xff000000, _GetDarkerColour($aChartColour[$i]))) $ahPen[$i] = _GDIPlus_PenCreate(BitOR(0xff000000, _GetDarkerColour(_GetDarkerColour($aChartColour[$i])))) Next ; Create the GUI with sliders to control the aspect, rotation, style and hole size (for donuts) Global $hWnd = GUICreate("Pie Chart", $PIE_AREA, $PIE_AREA + 100, Default, Default) Global $hSlideAspect = _GUICtrlSlider_Create($hWnd, $PIE_MARGIN, $PIE_AREA + 10, $PIE_DIAMETER, 20) _GUICtrlSlider_SetRange($hSlideAspect, 10, 100) _GUICtrlSlider_SetPos($hSlideAspect, 50) Global $hSlideRotation = _GUICtrlSlider_Create($hWnd, $PIE_MARGIN, $PIE_AREA + 40, $PIE_DIAMETER, 20) _GUICtrlSlider_SetRange($hSlideRotation, 0, 360) Global $cStyle = GUICtrlCreateCheckbox("Donut", $PIE_MARGIN, $PIE_AREA + 70, $PIE_DIAMETER / 2 - $PIE_MARGIN, 20) Global $hStyle = GUICtrlGetHandle($cStyle) Global $hHoleSize = _GUICtrlSlider_Create($hWnd, $PIE_MARGIN + $PIE_DIAMETER / 2, $PIE_AREA + 70, $PIE_DIAMETER / 2, 20) _GUICtrlSlider_SetRange($hHoleSize, 2, $PIE_DIAMETER - 4 * $PIE_MARGIN) _GUICtrlSlider_SetPos($hHoleSize, $PIE_DIAMETER / 2) GUISetState() ; Set up GDI+ Global $hDC = _WinAPI_GetDC($hWnd) Global $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($PIE_AREA, $PIE_AREA, $hGraphics) Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2) ; Draw the initial pie chart _DrawPie($aChartValue, _GUICtrlSlider_GetPos($hSlideAspect) / 100, _ _GUICtrlSlider_GetPos($hSlideRotation), _ (GUICtrlRead($cStyle) = $GUI_CHECKED), _ _GUICtrlSlider_GetPos($hHoleSize)) ; The sliders will send WM_NOTIFY messages GUIRegisterMsg($WM_NOTIFY, "_OnNotify") ; Wait until the user quits While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd ; Release the resources For $i = 0 To UBound($aChartColour) - 1 _GDIPlus_PenDispose($ahPen[$i]) _GDIPlus_BrushDispose($ahBrush[$i][0]) _GDIPlus_BrushDispose($ahBrush[$i][1]) Next _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_ReleaseDC($hWnd, $hDC) ; Shut down GDI+ _GDIPlus_Shutdown() ; Done Exit ; Get a darker version of a colour by extracting the RGB components Func _GetDarkerColour($Colour) Local $Red, $Green, $Blue $Red = (BitAND($Colour, 0xff0000) / 0x10000) - 40 $Green = (BitAND($Colour, 0x00ff00) / 0x100) - 40 $Blue = (BitAND($Colour, 0x0000ff)) - 40 If $Red < 0 Then $Red = 0 If $Green < 0 Then $Green = 0 If $Blue < 0 Then $Blue = 0 Return ($Red * 0x10000) + ($Green * 0x100) + $Blue EndFunc ;==>_GetDarkerColour ; Draw the pie chart Func _DrawPie($Percentage, $Aspect, $rotation, $style = 0, $holesize = 100) If $style <> 0 Then $Aspect = 1 Local $nCount, $nTotal = 0, $angleStart, $angleSweep, $X, $Y Local $pieLeft = $PIE_MARGIN, $pieTop = $PIE_AREA / 2 - ($PIE_DIAMETER / 2) * $Aspect Local $pieWidth = $PIE_DIAMETER, $pieHeight = $PIE_DIAMETER * $Aspect, $hPath ; Total up the values For $nCount = 0 To UBound($Percentage) - 1 $nTotal += $Percentage[$nCount] Next ; Set the fractional values For $nCount = 0 To UBound($Percentage) - 1 $Percentage[$nCount] /= $nTotal Next ; Make sure we don't over-rotate $rotation = Mod($rotation, 360) ; Clear the graphics buffer _GDIPlus_GraphicsClear($hBuffer, 0xffc0c0c0) ; Set the initial angles based on the fractional values Local $Angles[UBound($Percentage) + 1] For $nCount = 0 To UBound($Percentage) If $nCount = 0 Then $Angles[$nCount] = $rotation Else $Angles[$nCount] = $Angles[$nCount - 1] + ($Percentage[$nCount - 1] * 360) EndIf Next Switch $style Case 0 ; Adjust the angles based on the aspect For $nCount = 0 To UBound($Percentage) $X = $PIE_DIAMETER * Cos($Angles[$nCount] * $PI / 180) $Y = $PIE_DIAMETER * Sin($Angles[$nCount] * $PI / 180) $Y -= ($PIE_DIAMETER - $pieHeight) * Sin($Angles[$nCount] * $PI / 180) If $X = 0 Then $Angles[$nCount] = 90 + ($Y < 0) * 180 Else $Angles[$nCount] = ATan($Y / $X) * 180 / $PI EndIf If $X < 0 Then $Angles[$nCount] += 180 If $X >= 0 And $Y < 0 Then $Angles[$nCount] += 360 $X = $PIE_DIAMETER * Cos($Angles[$nCount] * $PI / 180) $Y = $pieHeight * Sin($Angles[$nCount] * $PI / 180) Next ; Decide which pieces to draw first and last Local $nStart = -1, $nEnd = -1 For $nCount = 0 To UBound($Percentage) - 1 $angleStart = Mod($Angles[$nCount], 360) $angleSweep = Mod($Angles[$nCount + 1] - $Angles[$nCount] + 360, 360) If $angleStart <= 270 And ($angleStart + $angleSweep) >= 270 Then $nStart = $nCount EndIf If ($angleStart <= 90 And ($angleStart + $angleSweep) >= 90) _ Or ($angleStart <= 450 And ($angleStart + $angleSweep) >= 450) Then $nEnd = $nCount EndIf If $nEnd >= 0 And $nStart >= 0 Then ExitLoop Next ; Draw the first piece _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nStart, $Angles) ; Draw pieces "to the right" $nCount = Mod($nStart + 1, UBound($Percentage)) While $nCount <> $nEnd _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nCount, $Angles) $nCount = Mod($nCount + 1, UBound($Percentage)) WEnd ; Draw pieces "to the left" $nCount = Mod($nStart + UBound($Percentage) - 1, UBound($Percentage)) While $nCount <> $nEnd _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nCount, $Angles) $nCount = Mod($nCount + UBound($Percentage) - 1, UBound($Percentage)) WEnd ; Draw the last piece _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nEnd, $Angles) Case 1 ; Draw the donut pieces For $nCount = 0 To UBound($Percentage) - 1 $angleStart = Mod($Angles[$nCount], 360) $angleSweep = Mod($Angles[$nCount + 1] - $Angles[$nCount] + 360, 360) ; Draw the outer arc in a darker colour $hPath = _GDIPlus_GraphicsPathCreate() _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft, $pieTop, $pieWidth, $pieHeight, $angleStart, $angleSweep) _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft + $PIE_MARGIN, $pieTop + $PIE_MARGIN, $pieWidth - $PIE_MARGIN * 2, _ $pieHeight - $PIE_MARGIN * 2, $angleStart + $angleSweep, -$angleSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hBuffer, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hBuffer, $ahPen[$nCount], $hPath) _GDIPlus_GraphicsPathDispose($hPath) ; Draw the inner piece in a lighter colour - leave room for the hole $hPath = _GDIPlus_GraphicsPathCreate() _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft + $PIE_MARGIN, $pieTop + $PIE_MARGIN, $pieWidth - $PIE_MARGIN * 2, _ $pieHeight - $PIE_MARGIN * 2, $angleStart, $angleSweep) _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft + ($PIE_DIAMETER - $holesize) / 2, $pieTop + ($PIE_DIAMETER - $holesize) / 2, _ $holesize, $holesize, $angleStart + $angleSweep, -$angleSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hBuffer, $ahBrush[$nCount][0], $hPath) _GDIPlus_GraphicsDrawPath($hBuffer, $ahPen[$nCount], $hPath) _GDIPlus_GraphicsPathDispose($hPath) Next EndSwitch ; Now draw the bitmap on to the device context of the window _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) EndFunc ;==>_DrawPie Func _OnNotify($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Switch $hWndFrom Case $hSlideAspect, $hSlideRotation, $hStyle, $hHoleSize ; Update the pie chart _DrawPie($aChartValue, _GUICtrlSlider_GetPos($hSlideAspect) / 100, _ _GUICtrlSlider_GetPos($hSlideRotation), _ (GUICtrlRead($cStyle) = $GUI_CHECKED), _ _GUICtrlSlider_GetPos($hHoleSize)) EndSwitch EndFunc ;==>_OnNotify Func _DrawPiePiece($hGraphics, $iX, $iY, $iWidth, $iHeight, $iDepth, $nCount, $Angles) Local $hPath, $cX = $iX + ($iWidth / 2), $cY = $iY + ($iHeight / 2), $fDrawn = False Local $iStart = Mod($Angles[$nCount], 360), $iSweep = Mod($Angles[$nCount + 1] - $Angles[$nCount] + 360, 360) ; Draw side ConsoleWrite(_Now() & @CRLF) $hPath = _GDIPlus_GraphicsPathCreate() If $iStart < 180 And ($iStart + $iSweep > 180) Then _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, $iStart, 180 - $iStart) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, 180, $iStart - 180) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $ahPen[$nCount], $hPath) $fDrawn = True EndIf If $iStart + $iSweep > 360 Then _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, 0, $iStart + $iSweep - 360) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, $iStart + $iSweep - 360, 360 - $iStart - $iSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $ahPen[$nCount], $hPath) $fDrawn = True EndIf If $iStart < 180 And (Not $fDrawn) Then _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, $iStart + $iSweep, -$iSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $ahPen[$nCount], $hPath) EndIf _GDIPlus_GraphicsPathDispose($hPath) ; Draw top _GDIPlus_GraphicsFillPie($hGraphics, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep, $ahBrush[$nCount][0]) _GDIPlus_GraphicsDrawPie($hGraphics, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep, $ahPen[$nCount]) EndFunc ;==>_DrawPiePiece Func _GDIPlus_GraphicsPathCreate($iFillMode = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $iFillMode, "int*", 0); If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>_GDIPlus_GraphicsPathCreate Func _GDIPlus_GraphicsPathAddLine($hGraphicsPath, $iX1, $iY1, $iX2, $iY2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine", "hwnd", $hGraphicsPath, "float", $iX1, "float", $iY1, _ "float", $iX2, "float", $iY2) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddLine Func _GDIPlus_GraphicsPathAddArc($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _ "float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddArc Func _GDIPlus_GraphicsPathAddPie($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathPie", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _ "float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddPie Func _GDIPlus_GraphicsPathCloseFigure($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathCloseFigure Func _GDIPlus_GraphicsPathDispose($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathDispose Func _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphics, "hwnd", $hPen, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsDrawPath Func _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphics, "hwnd", $hBrush, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsFillPath1 point -
Creates a shortcut file to a URL $oShell = ObjCreate("WScript.Shell") $oShort = $oShell.CreateShortcut(@ScriptDir & "\AutoIt Forums.url") $oShort.TargetPath = "http://www.autoitscript.com/forum/" $oShort.Save1 point