Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/01/2013 in all areas

  1. Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip
    1 point
  2. After UEZ helped me with the Countdown Timer his techniques seemed perfect for displaying individual images with transparency. One thing led to another and here's the resulting script. Download the attached zip file and place the 5 PNG files in the same folder as this script. I did not embed the images in the script, to make the script easier to read and so you can see the actual images used. In my opinion the ultimate next step would be to add the ability to play animated GIFs, still with transparency if that's possible. Enjoy! (with much gratitude to UEZ for his help) ; Functions coded by UEZ 2013-10-29 ; Updated to address issues 2013-10-31 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #NoTrayIcon _GDIPlus_Startup() ;initiate GDI+ #region ; timmy2's simple demonstration of UEZ's code ; ; display blank chalkboard (there will be no fade-in so use default $iAlpha value of 255) $aRes1 = DisplayImage( "Wood-framed-chalkboard.png", -1, -1 ) Sleep (500) ; add first two steps $aRes2 = DisplayImage("step-1.png", -1, -1 ) Sleep(2000) $aRes3 = DisplayImage("step-2.png", -1, -1 ) ; fade in handdrawn circle (therefore start with $iAlpha = 0) $aPos = WinGetPos($aRes1[0]) ;required because the chalkboard is displayed at screen center, which varies based on resolution (doh!) $aRes4 = DisplayImage("circle.png", $aPos[0] + 290, $aPos[1] + 75, 0) sleep (500) _Fader($aRes4) sleep(1000) _Fader($aRes4, False) ReleaseResources($aRes4) sleep(500) ; add third step $aRes5 = DisplayImage("step-3.png", -1, -1 ) Sleep(2000) ; fade the three steps out in reverse order (faster than defaults) _Fader($aRes5, False, 255, 5, 5) ReleaseResources($aRes5) _Fader($aRes3, False, 255, 5, 5) ReleaseResources($aRes3) _Fader($aRes2, False, 255, 5, 5) ReleaseResources($aRes2) Sleep(500) ; fade out chockboard _Fader($aRes1, False, 255, 10, 5) ReleaseResources($aRes1) #endregion _GDIPlus_Shutdown() Exit ; Display the image at center unless otherwise specified. If Fader will not be used then $iAlpha's default of 0xFF is good. ; If Fader will be used then start with $iAlpha equal to zero. Option to make this image "Always on top" is also available. Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True) Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image If @error Then Return SetError(1, 0, 0) ;image cannot be loaded Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image Local Const $hGUI = GUICreate("", $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW)) ;create GUI with appropriate styles and extented style (borderless transparent GUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging GUISetState(@SW_SHOW, $hGUI) ;show GUI Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap ;display GDI+ with transparency on desktop Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height) DllStructSetData($tSize, "X", $iW) ;set data for width DllStructSetData($tSize, "Y", $iH) ;set data for height Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen ;release resources otherwise memory will filled up (memory leak) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Local $aResource[7] = [$hGUI, $hScrDC, $hHBitmap, $hMemDC, $tBlend, $tSize, $tSource] ;return the handle to release it later Return $aResource EndFunc ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource) If Not IsArray($aResource) Then Return SetError(1, 0, 0) If UBound($aResource) <> 7 Then Return SetError(2, 0, 0) _WinAPI_ReleaseDC($aResource[0], $aResource[1]) _WinAPI_DeleteDC($aResource[3]) _WinAPI_DeleteObject($aResource[2]) GUIDelete($aResource[0]) EndFunc ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10 ) If Not IsArray($res1) Then Return SetError(1, 0, 0) If UBound($res1) <> 7 Then Return SetError(2, 0, 0) Switch $bIn Case True For $a = 0 To $iTrans Step $speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next Case Else For $a = $iTrans To 0 Step -$speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next EndSwitch EndFunc ;==>_FadeIn #region GDI and GDI+ functions Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 #endregion GDI and GDI+ functions images.zip
    1 point
  3. Released Beta 3 of the UDF. For download and a history of changes please see post #1.
    1 point
  4. Melba23

    ListView SubItem

    MadaraUchiha, Just use GUICtrlSetColor on the relevant items: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 225, 225, 747, 172) $ListView1 = GUICtrlCreateListView("Person|Number", 8, 8, 200, 165) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 90) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) $ListView1_0 = GUICtrlCreateListViewItem("Peter|5234*", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Bob|1234", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("Sally|5466", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("Julia|7543*", $ListView1) $ListView1_4 = GUICtrlCreateListViewItem("Marc|9999", $ListView1) $ListView1_5 = GUICtrlCreateListViewItem("Joe|4545", $ListView1) $ListView1_6 = GUICtrlCreateListViewItem("Nathan|4404", $ListView1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< For $i = 0 to _GUICtrlListView_GetItemCount($ListView1) - 1 If StringInStr( _GUICtrlListView_GetItemText($ListView1, $i, 1), "*") Then GUICtrlSetColor($ListView1_0 + $i, 0xFF0000) EndIf Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Button1 = GUICtrlCreateButton("Get", 72, 192, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 for $index = 0 to _GUICtrlListView_GetItemCount($ListView1) - 1 ; ListView items start at index 0 <<<<<<<<<<<<<<<<<<<<<<<<< $Name = _GUICtrlListView_GetItemText($ListView1, $index,1) If StringInStr($Name,'*') Then GUICtrlSetColor(_GUICtrlListView_GetItemText($ListView1,$name,1), 0xff0000) ; Red MsgBox(0,'found *',$Name) EndIf Next EndSwitch WEnd Note the change I made to the loop limits - try detecting the first * with the original limits and see what happens. M23
    1 point
  5. Alright, you can't use a string with nulls in it. But you can use 'Binary' and the code below sends a 16 bit number via serial to Arduino. #cs Test program for sending message to Arduino. Message is *A followed by 16 bit binary number, total 4 bytes. This sends a sequence of numbers from 0 to 256 #ce Opt("MustDeclareVars", 1) Local $Msg Local $sAxName Local $obj $sAxName = "MSCOMMLib.MSComm.1" $obj = ObjCreate($sAxName) With $obj .CommPort = 31 .Settings = "9600,N,8,1" .NullDiscard = False .NullDiscard = True .HandShaking = 0 ;.InBufferSize = 50 ;.OutBufferSize = 50 .InputMode = 0 .DTREnable = True .EOFEnable = False .RTSEnable = True .PortOpen = True EndWith Sleep(50) ;For $iCnt = 0x100 To 0 Step - 1 For $iCnt = 0 To 0x100 With $obj .NullDiscard = False $Msg = Binary("*A" & Chr(BitShift($iCnt, 8)) & Chr(BitAND($iCnt, 0xFF))) .Output = $Msg EndWith Sleep(50) Next With $obj .PortOpen = False EndWith
    1 point
  6. UEZ

    GDI+ draw text in circle

    corgano, what about this version? ;coded by UEZ 2011 build 2011-04-06 ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3" #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UPX_Parameters=--brute --crp-ms=999999 --all-methods --all-filters #include <Array.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) _GDIPlus_Startup() Global Const $iW = 600 Global Const $iH = 600 Global Const $iW2 = $iW / 2 Global Const $iH2 = $iH / 2 Global Const $hgui = GUICreate("GDI+ Rotated Letters by UEZ 2011 Beta", $iW, $iH) GUISetBkColor(0x202040, $hgui) WinSetTrans($hgui, "", 0xFF) GUISetState() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hgui) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic) Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) Global $ps = 4 Global $hPen = _GDIPlus_PenCreate(0xFFFFA000, $ps) Global $radius = 250 Global $sText = " Rotated Letters by UEZ 2011 Beta #" Global $hBMP = CreateRotatedLetters($sText, $iW, $iH) Global $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_GraphicsDrawImageRect($hBackbuffer, $hBMP, 0, 0, $iW, $iH) GUISetOnEvent(-3, "_Exit") Global $i = 0 While Sleep(10) $i -= 0.01 _GDIPlus_GraphicsClear($hBackbuffer, 0x80202020) _GDIPlus_GraphicsDrawImageRect($hBackbuffer, $hBMP, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $ps - 2, $ps - 2, $iW - $ps - 2, $iH - $ps - 2, $hPen) _GDIPlus_GraphicsDrawEllipse($hBackbuffer, 95, 95, $iW - 2 * 95, $iH - 2 * 95, $hPen) _GDIPlus_MatrixTranslate($hMatrix, $iW2, $iH2) _GDIPlus_MatrixRotate($hMatrix, Sin($i), False) _GDIPlus_MatrixTranslate($hMatrix, -$iW2, -$iH2) _GDIPlus_GraphicsSetTransform($hBackbuffer, $hMatrix) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) WEnd Func CreateRotatedLetters($sText, $iW, $iH, $fontsize = 60, $radius = 250, $letter_w = 100, $letter_h = 100, $font = "Impact", $rv = 20, $gv = 100, $bv = 240, $start_angle = 0) Local Const $iW2 = $iW / 2 Local Const $iH2 = $iH / 2 Local Const $sLen = StringLen($sText) Local $j = $sLen / 2 Local Const $delta_a = Floor(360 / $sLen) Local Const $letter_w2 = $letter_w / 2 Local Const $letter_h2 = $letter_h / 2 Local Const $center_x = $iW2 - $letter_w2 Local Const $center_y = $iH2 - $letter_h2 Local Const $deg = ACos(-1) / 180 Local $aTable[$sLen][12] Local $i, $r, $g, $b, $a, $lW, $lH, $x, $y Local $hImage = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hImage) For $i = 0 To $sLen - 1 ;generate table $aTable[$i][0] = StringMid($sText, $i + 1, 1) ;get next letter $aTable[$i][1] = _GDIPlus_BitmapCreateFromScan0($letter_w, $letter_h) ;create bitmap $aTable[$i][2] = _GDIPlus_ImageGetGraphicsContext($aTable[$i][1]) ;create context of bitmap to draw to bitmap $r = 0xFF - Sin($j / 10) * $rv $g = 0xFF - Sin($j / 10) * $gv $b = 0xFF - Sin($j / 10) * $bv $j -= 0.5 $aTable[$i][3] = _GDIPlus_BrushCreateSolid("0xE0" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2)) $aTable[$i][4] = _GDIPlus_StringFormatCreate() ;$hFormat $aTable[$i][5] = _GDIPlus_FontFamilyCreate($font) ;$hFamily $aTable[$i][6] = _GDIPlus_FontCreate($aTable[$i][5], $fontsize) ;$hFont $aTable[$i][7] = _GDIPlus_RectFCreate(0, 0, 0, 0) ;$tLayout $aTable[$i][8] = _GDIPlus_GraphicsMeasureString($hGraphic, $aTable[$i][0], $aTable[$i][6], $aTable[$i][7], $aTable[$i][4]) $aTable[$i][9] = _GDIPlus_MatrixCreate() ;create a matrix for each letter $aTable[$i][10] = $i * $delta_a + $start_angle ;calculate angle of letter $aTable[$i][11] = $radius ;radius _GDIPlus_GraphicsSetSmoothingMode($aTable[$i][2], 2) _GDIPlus_GraphicsClear($aTable[$i][2], 0x00000000) ;calculated possition of letter to place it in the middle of the graphic $a = $aTable[$i][8] $lW = DllStructGetData($a[0], "width") $lH = DllStructGetData($a[0], "height") DllStructSetData($a[0], "x", $letter_w2 - $lW / 2) DllStructSetData($a[0], "y", $letter_h2 - $lH / 2) ;rotate letter _GDIPlus_MatrixTranslate($aTable[$i][9], $letter_w2, $letter_h2) _GDIPlus_MatrixRotate($aTable[$i][9], -27 + $aTable[$i][10], False) _GDIPlus_MatrixTranslate($aTable[$i][9], -$letter_w2, -$letter_h2) _GDIPlus_GraphicsSetTransform($aTable[$i][2], $aTable[$i][9]) ;print letter to bitmap _GDIPlus_GraphicsDrawStringEx($aTable[$i][2], $aTable[$i][0], $aTable[$i][6], $a[0], $aTable[$i][4], $aTable[$i][3]) ;copy letter to main screen in a circle $x = $center_x + Cos(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11] $y = $center_y + Sin(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11] _GDIPlus_GraphicsDrawImage($hContext, $aTable[$i][1], $x, $y) Next For $i = 0 To $sLen - 1 _GDIPlus_BitmapDispose($aTable[$i][1]) _GDIPlus_GraphicsDispose($aTable[$i][2]) _GDIPlus_BrushDispose($aTable[$i][3]) _GDIPlus_StringFormatDispose($aTable[$i][4]) _GDIPlus_FontFamilyDispose($aTable[$i][5]) _GDIPlus_FontDispose($aTable[$i][6]) _GDIPlus_MatrixDispose($aTable[$i][9]) Next _GDIPlus_GraphicsDispose($hContext) Return $hImage EndFunc ;==>CreateRotatedLetters Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 Func _Exit() _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBMP) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hgui) Exit EndFunc ;==>_Exit Btw, does anyone know why _GDIPlus_GraphicsSetSmoothingMode() is not working with with _GDIPlus_GraphicsDrawStringEx() on Vista+ os'? Br, UEZ
    1 point
×
×
  • Create New...