Malkey Posted March 7, 2008 Share Posted March 7, 2008 Still looking at GDI+ functions. This one rotates text on the desktop. Press Ctrl key - alternates between the two examples. Press Esc key to exit.The graphics can be dragged.expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstantsEx.au3> Global Const $iOpacity = 200 Global Const $ULW_ALPHA = 2 Global Const $nPI = 3.1415926535897932384626433832795 Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3 addin Global $hGui, $hGraphic Global $dll = DllOpen ("user32.dll") Global $GuiSize = 580, $w2 = 144, $h2 = 20 Global $randcol,$fCol,$fontSize = 12,$fRot = -144,$w = 100,$h = 20,$nAngle = 0, $flg = 1 Opt("MustDeclareVars", 1) Opt ("GUIOnEventMode", 1) TextRotate() Func TextRotate() Local $hWnd, $hDC, $hBitmap, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hGui = GUICreate("Rotate Text", $GuiSize, $GuiSize, -1,-1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GuiRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3 addin GUISetState() Do _GDIPlus_Startup() $hWnd = _WinAPI_GetDC(0) $hDC = _WinAPI_CreateCompatibleDC ($hWnd) $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd,$GuiSize,$GuiSize) ; $iWidth, $iHeight) _WinAPI_SelectObject ($hDC, $hBitmap) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) If _IsPressed("11") Then $flg += 1 ; CTRL key If $flg = 1 Then RotateText2 () If $flg = 2 Then RotateText () If $flg >= 3 Then $flg = 1 $tSize = DllStructCreate ($tagSIZE) $pSize = DllStructGetPtr ($tSize ) DllStructSetData ($tSize, "X", $GuiSize) ;$iWidth ) DllStructSetData ( $tSize, "Y", $GuiSize) ;$iHeight) $tSource = DllStructCreate ($tagPOINT) $pSource = DllStructGetPtr ($tSource) $tBlend = DllStructCreate ($tagBLENDFUNCTION) $pBlend = DllStructGetPtr ($tBlend ) DllStructSetData ($tBlend, "Alpha" , $iOpacity ) DllStructSetData ($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) Sleep(200) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_ReleaseDC (0, $hWnd) _WinAPI_DeleteObject ($hBitmap) _WinAPI_DeleteDC ($hDC ) _GDIPlus_Shutdown () Until _IsPressed("1B") ; ESC key DllClose($dll) EndFunc Func RotateText() Local $txt,$txtlen,$fontSize = 12 $txt = "Autoit Sang" ; Type text to be displayed here - text box display autosizing below $txtlen = StringLen($txt) $fRot = $fRot + 1 if $fRot = 144 Then $fRot = -144 ; 72*5deg=360deg - 2/360's before zero & 2/360's after zero if $fRot < 0 Then $nAngle = mod($nAngle -5, 360) ; 5deg increments (minus anticlockwise) Else $nAngle = mod($nAngle +5, 360) ; 5deg increments (plus clockwise) EndIf ;Text box display autosizing. $w - Width of text rectangle; $h - Heigth of text rectangle $w = int($fontSize*$txtlen*3/4 ) $h = int( ($fontSize*4/3)*(1280/1024)) if $fCol = 0 Then ;Randomize ARGB color $randcol = "0xff" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) EndIf $fCol = mod($fCol + 1,18) ; Changes color every 18 * 5deg = 90Deg ;DrawText( $nX, $nY, $nAngle, $iWidth, $iHeight, $txt, $iARGB , $fontSize ) DrawText($GuiSize/4, $GuiSize/4, $nAngle, $w, $h, $txt, $randcol ) return 1 EndFunc Func RotateText2() Local $txt2,$txtlen2,$winpos $txt2 = "Autoit Sang" ; Type text to be displayed here - text box display autosizing below $txtlen2 = StringLen($txt2) $fRot = $fRot + 1 if $fRot = 144 Then $fRot = -144 ; 72*5deg=360deg - 2/360's before zero & 2/360's after zero if $fRot < 0 Then $nAngle = mod($nAngle -5, 360) ; 5deg increments (minus anticlockwise) $fontSize = 12 + int(($fRot+144)*20/144 ); increase fontsize 12 to size 32 over 144 increments Else $nAngle = mod($nAngle +5, 360) ; 5deg increments (plus clockwise) $fontSize = 32 - int(($fRot)*20/144 ); decrease fontsize 32 to size 12 over 144 increments EndIf ;$w2 - Width of text rectangle; $h2 - Heigth of text rectangle $w2 = int($fontSize*$txtlen2*3/4 ) $h2 = int( ($fontSize*4/3)*(1280/1024)) $winpos = WinGetPos($hGui) WinMove ( "Rotate Text", "", mod($winpos[0]+1,@DesktopWidth/2) ,$winpos[1] ) if $fCol = 0 Then ;Randomize ARGB color $randcol = "0xff" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) EndIf $fCol = mod($fCol + 1,18) ; Changes color 18 * 5deg = 90Deg ;DrawText( $nX, $nY, $nAngle, $iWidth, $iHeight, $txt, $iARGB , $fontSize ) DrawText($GuiSize/2, $GuiSize/2, $nAngle, $w2, $h2, $txt2, $randcol, $fontSize ) sleep(40) return 1 EndFunc Func DrawText( $nX, $nY, $nAngle, $nWidth, $nHeight, $txt, $iARGB = 0xFF000000, $fontSize = 12) Local $hMatrix, $nXt, $nYt, $hBrush, $hFormat, $hFamily, $hFont, $tLayout,$x,$y ; $nXt - The X coordinate of the upper left corner of the Graphics object before rotation ; $nYt - The Y coordinate of the upper left corner of the Graphics object before rotation ;Rotation Matrix $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, $nAngle, 1) _GDIPlus_GraphicsSetTransform($hGraphic , $hMatrix) ;x, y display coordinates of center of height of the rectanglular text box ($height/2). ;x, y increment in a circular path with radius (width of text box)/2. $x = ($nWidth/2)*cos($nAngle*$nPI/180) - ($nHeight/2)*sin($nAngle*$nPI/180);Parametric equations for a circle $y = ($nWidth/2)*sin($nAngle*$nPI/180) + ($nHeight/2)*cos($nAngle*$nPI/180); and adjusts for center of text box ;Rotation of Coordinate Axes formulae ;Use $nXt, $nYt in _GDIPlus_RectFCreate. These x, y values is the handle of the rectangular text box point ; before rotation (translation of the matrix) $nXt = ($nX-$x)*cos($nAngle*$nPI/180) + ($nY-$y)*sin($nAngle*$nPI/180) ; $nXt - X coordinate before translation $nYt = -($nX-$x)*sin($nAngle*$nPI/180) + ($nY-$y)*cos($nAngle*$nPI/180) ; $nYt - Y coordinate before translation ; Parameters for lus_GraphicsDrawStringEx() $hBrush = _GDIPlus_BrushCreateSolid ($iARGB) $hFormat = _GDIPlus_StringFormatCreate () $hFamily = _GDIPlus_FontFamilyCreate ("Arial") ;$hFont = _GDIPlus_FontCreate ($hFamily, 32, 1) $hFont = _GDIPlus_FontCreate ($hFamily, $fontSize, 1) $tLayout = _GDIPlus_RectFCreate ( $nXt, $nYt, $nWidth, $nHeight ) _GDIPlus_GraphicsDrawStringEx ($hGraphic, $txt, $hFont, $tLayout, $hFormat, $hBrush) sleep(20) ; Clean up resources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) Return 1 EndFunc ; ================================================================= ; Drag Window 3 of 3 addin ; ================================================================= Func _WinMove($HWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) dllcall("user32.dll","int","SendMessage","hWnd", $HWnd, "int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFuncThis is continuing along the same lines as my previous two posts http://www.autoitscript.com/forum/index.ph...st&p=486995and http://www.autoitscript.com/forum/index.ph...st&p=481273 Link to comment Share on other sites More sharing options...
Achilles Posted March 7, 2008 Share Posted March 7, 2008 Once again, nice work! This is a very good example for people to learn from. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
FeReNGi Posted October 8, 2009 Share Posted October 8, 2009 Any updates on this function ? Won't compile on current autoit version ServicesPE|LoadVMDK Link to comment Share on other sites More sharing options...
UEZ Posted October 8, 2009 Share Posted October 8, 2009 Try this: expandcollapse popup#include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstantsEx.au3> #Include <Misc.au3> Global Const $iOpacity = 200 ;~ Global Const $ULW_ALPHA = 2 Global Const $nPI = 3.1415926535897932384626433832795 Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3 addin Global $hGui, $hGraphic Global $dll = DllOpen ("user32.dll") Global $GuiSize = 580, $w2 = 144, $h2 = 20 Global $randcol,$fCol,$fontSize = 12,$fRot = -144,$w = 100,$h = 20,$nAngle = 0, $flg = 1 Opt("MustDeclareVars", 1) Opt ("GUIOnEventMode", 1) TextRotate() Func TextRotate() Local $hWnd, $hDC, $hBitmap, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hGui = GUICreate("Rotate Text", $GuiSize, $GuiSize, -1,-1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GuiRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3 addin GUISetState() Do _GDIPlus_Startup() $hWnd = _WinAPI_GetDC(0) $hDC = _WinAPI_CreateCompatibleDC ($hWnd) $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd,$GuiSize,$GuiSize) ; $iWidth, $iHeight) _WinAPI_SelectObject ($hDC, $hBitmap) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) If _IsPressed("11") Then $flg += 1 ; CTRL key If $flg = 1 Then RotateText2 () If $flg = 2 Then RotateText () If $flg >= 3 Then $flg = 1 $tSize = DllStructCreate ($tagSIZE) $pSize = DllStructGetPtr ($tSize ) DllStructSetData ($tSize, "X", $GuiSize) ;$iWidth ) DllStructSetData ( $tSize, "Y", $GuiSize) ;$iHeight) $tSource = DllStructCreate ($tagPOINT) $pSource = DllStructGetPtr ($tSource) $tBlend = DllStructCreate ($tagBLENDFUNCTION) $pBlend = DllStructGetPtr ($tBlend ) DllStructSetData ($tBlend, "Alpha" , $iOpacity ) DllStructSetData ($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) Sleep(200) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_ReleaseDC (0, $hWnd) _WinAPI_DeleteObject ($hBitmap) _WinAPI_DeleteDC ($hDC ) _GDIPlus_Shutdown () Until _IsPressed("1B") ; ESC key DllClose($dll) EndFunc Func RotateText() Local $txt,$txtlen,$fontSize = 12 $txt = "Autoit Sang" ; Type text to be displayed here - text box display autosizing below $txtlen = StringLen($txt) $fRot = $fRot + 1 if $fRot = 144 Then $fRot = -144 ; 72*5deg=360deg - 2/360's before zero & 2/360's after zero if $fRot < 0 Then $nAngle = mod($nAngle -5, 360) ; 5deg increments (minus anticlockwise) Else $nAngle = mod($nAngle +5, 360) ; 5deg increments (plus clockwise) EndIf ;Text box display autosizing. $w - Width of text rectangle; $h - Heigth of text rectangle $w = int($fontSize*$txtlen*3/4 ) $h = int( ($fontSize*4/3)*(1280/1024)) if $fCol = 0 Then ;Randomize ARGB color $randcol = "0xff" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) EndIf $fCol = mod($fCol + 1,18) ; Changes color every 18 * 5deg = 90Deg ;DrawText( $nX, $nY, $nAngle, $iWidth, $iHeight, $txt, $iARGB , $fontSize ) DrawText($GuiSize/4, $GuiSize/4, $nAngle, $w, $h, $txt, $randcol ) return 1 EndFunc Func RotateText2() Local $txt2,$txtlen2,$winpos $txt2 = "Autoit Sang" ; Type text to be displayed here - text box display autosizing below $txtlen2 = StringLen($txt2) $fRot = $fRot + 1 if $fRot = 144 Then $fRot = -144 ; 72*5deg=360deg - 2/360's before zero & 2/360's after zero if $fRot < 0 Then $nAngle = mod($nAngle -5, 360) ; 5deg increments (minus anticlockwise) $fontSize = 12 + int(($fRot+144)*20/144 ); increase fontsize 12 to size 32 over 144 increments Else $nAngle = mod($nAngle +5, 360) ; 5deg increments (plus clockwise) $fontSize = 32 - int(($fRot)*20/144 ); decrease fontsize 32 to size 12 over 144 increments EndIf ;$w2 - Width of text rectangle; $h2 - Heigth of text rectangle $w2 = int($fontSize*$txtlen2*3/4 ) $h2 = int( ($fontSize*4/3)*(1280/1024)) $winpos = WinGetPos($hGui) WinMove ( "Rotate Text", "", mod($winpos[0]+1,@DesktopWidth/2) ,$winpos[1] ) if $fCol = 0 Then ;Randomize ARGB color $randcol = "0xff" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) EndIf $fCol = mod($fCol + 1,18) ; Changes color 18 * 5deg = 90Deg ;DrawText( $nX, $nY, $nAngle, $iWidth, $iHeight, $txt, $iARGB , $fontSize ) DrawText($GuiSize/2, $GuiSize/2, $nAngle, $w2, $h2, $txt2, $randcol, $fontSize ) sleep(40) return 1 EndFunc Func DrawText( $nX, $nY, $nAngle, $nWidth, $nHeight, $txt, $iARGB = 0xFF000000, $fontSize = 12) Local $hMatrix, $nXt, $nYt, $hBrush, $hFormat, $hFamily, $hFont, $tLayout,$x,$y ; $nXt - The X coordinate of the upper left corner of the Graphics object before rotation ; $nYt - The Y coordinate of the upper left corner of the Graphics object before rotation ;Rotation Matrix $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, $nAngle, 1) _GDIPlus_GraphicsSetTransform($hGraphic , $hMatrix) ;x, y display coordinates of center of height of the rectanglular text box ($height/2). ;x, y increment in a circular path with radius (width of text box)/2. $x = ($nWidth/2)*cos($nAngle*$nPI/180) - ($nHeight/2)*sin($nAngle*$nPI/180);Parametric equations for a circle $y = ($nWidth/2)*sin($nAngle*$nPI/180) + ($nHeight/2)*cos($nAngle*$nPI/180); and adjusts for center of text box ;Rotation of Coordinate Axes formulae ;Use $nXt, $nYt in _GDIPlus_RectFCreate. These x, y values is the handle of the rectangular text box point ; before rotation (translation of the matrix) $nXt = ($nX-$x)*cos($nAngle*$nPI/180) + ($nY-$y)*sin($nAngle*$nPI/180) ; $nXt - X coordinate before translation $nYt = -($nX-$x)*sin($nAngle*$nPI/180) + ($nY-$y)*cos($nAngle*$nPI/180) ; $nYt - Y coordinate before translation ; Parameters for lus_GraphicsDrawStringEx() $hBrush = _GDIPlus_BrushCreateSolid ($iARGB) $hFormat = _GDIPlus_StringFormatCreate () $hFamily = _GDIPlus_FontFamilyCreate ("Arial") ;$hFont = _GDIPlus_FontCreate ($hFamily, 32, 1) $hFont = _GDIPlus_FontCreate ($hFamily, $fontSize, 1) $tLayout = _GDIPlus_RectFCreate ( $nXt, $nYt, $nWidth, $nHeight ) _GDIPlus_GraphicsDrawStringEx ($hGraphic, $txt, $hFont, $tLayout, $hFormat, $hBrush) sleep(20) ; Clean up resources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) Return 1 EndFunc ; ================================================================= ; Drag Window 3 of 3 addin ; ================================================================= Func _WinMove($HWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) dllcall("user32.dll","int","SendMessage","hWnd", $HWnd, "int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc Should work with version 3.3.0.0! UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
junkew Posted May 3, 2018 Share Posted May 3, 2018 Works like a charm with a small fix. (sorry for bubbling up this post but these GDI examples are still very nice) expandcollapse popup#include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstantsEx.au3> #Include <Misc.au3> Global Const $iOpacity = 200 ;~ Global Const $ULW_ALPHA = 2 Global Const $nPI = 3.1415926535897932384626433832795 ;~ Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3 addin Global $hGui, $hGraphic Global $dll = DllOpen ("user32.dll") Global $GuiSize = 580, $w2 = 144, $h2 = 20 Global $randcol,$fCol,$fontSize = 12,$fRot = -144,$w = 100,$h = 20,$nAngle = 0, $flg = 1 Opt("MustDeclareVars", 1) Opt ("GUIOnEventMode", 1) TextRotate() Func TextRotate() Local $hWnd, $hDC, $hBitmap, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hGui = GUICreate("Rotate Text", $GuiSize, $GuiSize, -1,-1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GuiRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3 addin GUISetState() Do _GDIPlus_Startup() $hWnd = _WinAPI_GetDC(0) $hDC = _WinAPI_CreateCompatibleDC ($hWnd) $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd,$GuiSize,$GuiSize) ; $iWidth, $iHeight) _WinAPI_SelectObject ($hDC, $hBitmap) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) If _IsPressed("11") Then $flg += 1 ; CTRL key If $flg = 1 Then RotateText2 () If $flg = 2 Then RotateText () If $flg >= 3 Then $flg = 1 $tSize = DllStructCreate ($tagSIZE) $pSize = DllStructGetPtr ($tSize ) DllStructSetData ($tSize, "X", $GuiSize) ;$iWidth ) DllStructSetData ( $tSize, "Y", $GuiSize) ;$iHeight) $tSource = DllStructCreate ($tagPOINT) $pSource = DllStructGetPtr ($tSource) $tBlend = DllStructCreate ($tagBLENDFUNCTION) $pBlend = DllStructGetPtr ($tBlend ) DllStructSetData ($tBlend, "Alpha" , $iOpacity ) DllStructSetData ($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) Sleep(200) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_ReleaseDC (0, $hWnd) _WinAPI_DeleteObject ($hBitmap) _WinAPI_DeleteDC ($hDC ) _GDIPlus_Shutdown () Until _IsPressed("1B") ; ESC key DllClose($dll) EndFunc Func RotateText() Local $txt,$txtlen,$fontSize = 12 $txt = "Autoit Sang" ; Type text to be displayed here - text box display autosizing below $txtlen = StringLen($txt) $fRot = $fRot + 1 if $fRot = 144 Then $fRot = -144 ; 72*5deg=360deg - 2/360's before zero & 2/360's after zero if $fRot < 0 Then $nAngle = mod($nAngle -5, 360) ; 5deg increments (minus anticlockwise) Else $nAngle = mod($nAngle +5, 360) ; 5deg increments (plus clockwise) EndIf ;Text box display autosizing. $w - Width of text rectangle; $h - Heigth of text rectangle $w = int($fontSize*$txtlen*3/4 ) $h = int( ($fontSize*4/3)*(1280/1024)) if $fCol = 0 Then ;Randomize ARGB color $randcol = "0xff" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) EndIf $fCol = mod($fCol + 1,18) ; Changes color every 18 * 5deg = 90Deg ;DrawText( $nX, $nY, $nAngle, $iWidth, $iHeight, $txt, $iARGB , $fontSize ) DrawText($GuiSize/4, $GuiSize/4, $nAngle, $w, $h, $txt, $randcol ) return 1 EndFunc Func RotateText2() Local $txt2,$txtlen2,$winpos $txt2 = "Autoit Sang" ; Type text to be displayed here - text box display autosizing below $txtlen2 = StringLen($txt2) $fRot = $fRot + 1 if $fRot = 144 Then $fRot = -144 ; 72*5deg=360deg - 2/360's before zero & 2/360's after zero if $fRot < 0 Then $nAngle = mod($nAngle -5, 360) ; 5deg increments (minus anticlockwise) $fontSize = 12 + int(($fRot+144)*20/144 ); increase fontsize 12 to size 32 over 144 increments Else $nAngle = mod($nAngle +5, 360) ; 5deg increments (plus clockwise) $fontSize = 32 - int(($fRot)*20/144 ); decrease fontsize 32 to size 12 over 144 increments EndIf ;$w2 - Width of text rectangle; $h2 - Heigth of text rectangle $w2 = int($fontSize*$txtlen2*3/4 ) $h2 = int( ($fontSize*4/3)*(1280/1024)) $winpos = WinGetPos($hGui) WinMove ( "Rotate Text", "", mod($winpos[0]+1,@DesktopWidth/2) ,$winpos[1] ) if $fCol = 0 Then ;Randomize ARGB color $randcol = "0xff" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) EndIf $fCol = mod($fCol + 1,18) ; Changes color 18 * 5deg = 90Deg ;DrawText( $nX, $nY, $nAngle, $iWidth, $iHeight, $txt, $iARGB , $fontSize ) DrawText($GuiSize/2, $GuiSize/2, $nAngle, $w2, $h2, $txt2, $randcol, $fontSize ) sleep(40) return 1 EndFunc Func DrawText( $nX, $nY, $nAngle, $nWidth, $nHeight, $txt, $iARGB = 0xFF000000, $fontSize = 12) Local $hMatrix, $nXt, $nYt, $hBrush, $hFormat, $hFamily, $hFont, $tLayout,$x,$y ; $nXt - The X coordinate of the upper left corner of the Graphics object before rotation ; $nYt - The Y coordinate of the upper left corner of the Graphics object before rotation ;Rotation Matrix $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, $nAngle, 1) _GDIPlus_GraphicsSetTransform($hGraphic , $hMatrix) ;x, y display coordinates of center of height of the rectanglular text box ($height/2). ;x, y increment in a circular path with radius (width of text box)/2. $x = ($nWidth/2)*cos($nAngle*$nPI/180) - ($nHeight/2)*sin($nAngle*$nPI/180);Parametric equations for a circle $y = ($nWidth/2)*sin($nAngle*$nPI/180) + ($nHeight/2)*cos($nAngle*$nPI/180); and adjusts for center of text box ;Rotation of Coordinate Axes formulae ;Use $nXt, $nYt in _GDIPlus_RectFCreate. These x, y values is the handle of the rectangular text box point ; before rotation (translation of the matrix) $nXt = ($nX-$x)*cos($nAngle*$nPI/180) + ($nY-$y)*sin($nAngle*$nPI/180) ; $nXt - X coordinate before translation $nYt = -($nX-$x)*sin($nAngle*$nPI/180) + ($nY-$y)*cos($nAngle*$nPI/180) ; $nYt - Y coordinate before translation ; Parameters for lus_GraphicsDrawStringEx() $hBrush = _GDIPlus_BrushCreateSolid ($iARGB) $hFormat = _GDIPlus_StringFormatCreate () $hFamily = _GDIPlus_FontFamilyCreate ("Arial") ;$hFont = _GDIPlus_FontCreate ($hFamily, 32, 1) $hFont = _GDIPlus_FontCreate ($hFamily, $fontSize, 1) $tLayout = _GDIPlus_RectFCreate ( $nXt, $nYt, $nWidth, $nHeight ) _GDIPlus_GraphicsDrawStringEx ($hGraphic, $txt, $hFont, $tLayout, $hFormat, $hBrush) sleep(20) ; Clean up resources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) Return 1 EndFunc ; ================================================================= ; Drag Window 3 of 3 addin ; ================================================================= Func _WinMove($HWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) dllcall("user32.dll","int","SendMessage","hWnd", $HWnd, "int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc argumentum 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now