Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/22/2014 in all areas

  1. UEZ

    AutoIt Snippets

    Here a snipped how to colorize each character of a label text: GUICtrlCreateLabelColorized: #include <GDIPlus.au3> #include <GUIConstantsEx.au3> _GDIPlus_Startup() Global $hGUI = GUICreate("Test", 570, 100), $i GUISetBkColor(0xFFFFFF) Global $sText1 = "These chars were colorized separately" Global $aColors1[StringLen($sText1)] For $i = 0 To UBound($aColors1) - 1 $aColors1[$i] = Random(0x000000, 0x400000, 1) Next Global $aLabel1 = GUICtrlCreateLabelColorized($sText1, $aColors1, 10, 10, 18, "Comic Sans MS") Global $sText2 = "using " & Chr(203) & "label controls" & Chr(202) & " with " & Chr(201) & "bold" & Chr(200) & " words. ;-)" Global $aColors2[StringLen($sText2)] Global $aLabel2 = GUICtrlCreateLabelColorized($sText2, $aColors2, 18, 50, 26, "Times New Roman") GUISetState() Do ;~ For $i = 0 To UBound($aColors2) - 1 ;~ GUICtrlSetColor($aLabel2[$i][0], Random(0x000000, 0xD00000, 1)) ;~ Next ;~ Sleep(40) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit ; #FUNCTION# ==================================================================================================================== ; Name ..............: GUICtrlCreateLabelColorized ; Description ......: Creates a label with possibility to set different color to each character ; Syntax ............: GUICtrlCreateLabelColorized($sText, $aColors, $iX, $iY, $fFontSize, $sFont[, $iWeight = 400[, $iAttribute = 0[, ; $iFQuality = 0[, $fCorrection = 0.95]]]]) ; Parameters .....: $sText - A string value. Chr(200) = disable bold char, Chr(201) = enable bold char, ; Chr(202) = disable italic char, Chr(203) = enable italic char, ; $aColors - An array of color values in format RGB. ; $iX - An integer value - x position of the label. ; $iY - An integer value - y position of the label. ; $fFontSize - A floating point value - size of the font. ; $sFont - A string value - font name. ; $iWeight - [optional] An integer value. Default is 400. ; $iAttribute - [optional] An integer value. Default is 0. ; $iFQuality - [optional] An integer value. Default is 4 (checkout GUICtrlSetFont for more details about quality settings) ; $fCorrection - [optional] A floating point value. Default is 0.925. ; Return values .: An array with following values: ; [$i][0] = control id of the label ; [$i][1] = color value of the character in RGB format ; [$i][2] = x position of the character ; [$i][3] = y position of the character ; [$i][4] = width of the character ; [$i][5] = height of the character ; Version ..........: 0.95 build 2017-09-11 beta ; Author ...........: UEZ ; Modified ........: ; Remarks .......: AutoIt version 3.3.10.2 or higher is required, __MeasureString is an internal function to measure each character. ; Don't forget to start GDI+ before you call the function! ; Related .........: GUICtrlCreateLabel, _GDIPlus_StringFormatSetMeasurableCharacterRanges ; Link ..............: ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlCreateLabelColorized($sText, $aColors, $iX, $iY, $fFontSize = 9.5, $sFont = "Arial", $iWeight = 400, $iAttribute = 0, $iFQuality = 4, $fCorrection = 0.925) If Not StringLen($sText) Then Return SetError(1, 0, 0) Local $aChars = StringSplit($sText, "", 2), $i, $aLabels[UBound($aChars)][6], $aCoord, $sChar, _ $bBold = 0, $bItalic = 0, $iBold = 700, $iItalic = 2, $iWeightPrev = $iWeight, $iItalicPrev = $iAttribute For $i = 0 To UBound($aChars) - 1 $sChar = $aChars[$i] If $sChar = " " Then $sChar = "." ;if char is space fill it up with . to calculate space between words Switch $sChar Case Chr(200) $bBold = 0 ContinueLoop Case Chr(201) $bBold = 1 ContinueLoop Case Chr(202) $bItalic = 0 ContinueLoop Case Chr(203) $bItalic = 1 ContinueLoop EndSwitch $aCoord = __MeasureString($sChar, $sFont, $fFontSize, $iAttribute + ($iWeight > 699) * 1) $aLabels[$i][1] = $aColors[$i] ;color $aLabels[$i][2] = ($iX - $aCoord[0]) * $fCorrection ;x pos $aLabels[$i][3] = $iY ;y pos $aLabels[$i][4] = $aCoord[2] ;width $aLabels[$i][5] = $aCoord[3] ;height $aLabels[$i][0] = GUICtrlCreateLabel($aChars[$i], $aLabels[$i][2], $aLabels[$i][3], $aLabels[$i][4], $aLabels[$i][5]) ;create label (char) control GUICtrlSetColor($aLabels[$i][0], $aLabels[$i][1]) ;set char color If $bBold Then $iWeight = $iBold Else $iWeight = $iWeightPrev EndIf If $bItalic Then $iAttribute = $iItalic Else $iAttribute = $iItalicPrev EndIf GUICtrlSetFont($aLabels[$i][0], $fFontSize, $iWeight, $iAttribute, $sFont, $iFQuality) ;set font for char $iX += $aCoord[1] ;calculate next x position Next Return $aLabels EndFunc ;==>GUICtrlCreateLabelColorized ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ............: __MeasureString ; Description ....: Measures a string ; Syntax ..........: __MeasureString($sString, $sFont, $fFontSize[, $iAttribute = 0]) ; Parameters ...: $sString - A string value. ; $sFont - A string value. ; $fFontSize - A floating point value. ; $iAttribute - [optional] An integer value. Default is 0. ; Return values.: An array with x, y, width and height values of the string ; Version ..........: 2020-03-08 beta ; Author ...........: UEZ ; Modified ........: ; Remarks .......: AutoIt version 3.3.10.2 or higher is required ; Related .........: GDIPlus ; Link ..............: ; Example .......: Yes ; =============================================================================================================================== Func __MeasureString($sString, $sFont, $fFontSize, $iAttribute = 0) Local Const $hDC = _WinAPI_GetDC(0), $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC), $tLayout = _GDIPlus_RectFCreate() Local Const $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($sFont), $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize, $iAttribute) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) Local $aRanges[2][2] = [[1]] $aRanges[1][1] = StringLen($sString) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) Local Const $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat) Local Const $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics) _GDIPlus_RegionDispose($aRegion[1]) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_ReleaseDC(0, $hDC) Local $aDim[4] $aDim[0] = $aBounds[0] ;X coordinate of the upper-left corner of the rectangle $aDim[1] = $aBounds[2] ;Width of the rectangle for next char $aDim[2] = $aInfo[0].Width ;Width of the rectangle $aDim[3] = $aInfo[0].Height ;Height of the rectangle Return $aDim EndFunc ;==>__MeasureString Requires AutoIt version 3.3.10.2 or higher! Br, UEZ
    1 point
  2. I have changed the creation of the online version of the helpfile, which is now auto-generated from the SciTE4AutoIt3 helpfile and thus should be in sync from now on without any extra effort. http://www.autoitscript.com/autoit3/scite/docs/Help.html Jos
    1 point
  3. Bert

    making a bot

    You really are making a poor choice here. This thread is over 8 years old, and is against forum rules. You honestly think the OP is going to reply? And for that manner do you think a moderator is going to let you post what you did along with your email address too?
    1 point
  4. Geir1983

    ftp question

    Why dont you just connect to ftp after you have written your file? Edit: and why do you loop this script? You never exit the loop?
    1 point
  5. I'll do it for $1000. In advance.
    1 point
  6. JohnOne

    Create a script

    You're wrong, "them" edited thems post.
    1 point
  7. $working = 1 $awayfromcomputer = Random(0, 1, 1) While $working If $awayfromcomputer Then _Put_USB_In_Pocket() EndIf Sleep(1000) WEnd
    1 point
  8. Try something like this : #include <Constants.au3> $iPid = Run('C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\Corflags.exe" "C:\temp\Myapplication.exe"', 'C:\temp' , "", $STDOUT_CHILD ) ProcessWaitClose($iPid) $sOUtput = StdoutRead($iPid) MsgBox(0, "", $sOutput)
    1 point
×
×
  • Create New...