Jump to content

Leaderboard

Popular Content

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

  1. Andreik

    Pie chart

    This is an example how to draw a simple pie chart in a picture control. Available properties: Width - width of chart (including legend)Height - height of chart (including title)Title - chart titleTitleHeight - title height in pixels (default 30px)TitleAlign - title alignment: Left,Center,Right (default: Left)TitleSize - title text size (default: 12)TitleStyle - title style: Bold, Italic, Underline, Strikethrough (default: Bold)LegendWidth - width reserved for legend - calculated from total chart width, (default: 150 px)LegendTextSize - text size in legend area (default: 10px)LegendStyle - legend style: Bold, Italic, Underline, Strikethrough (default: Italic)LegendDetails - specify what details are displayed in legend area: Percent, Value, Nothing (default: Percent)Palette - palette of colors - delimited by | - must contain same number of colors (AARRGGBB format) as items in data arrayBackground - background color - AARRGGBB format (default: 0xFFFFFFFF - white)TextColor - text color - AARRGGBB format (default: 0xFF000000 - black)Font - title and legend font (default: Arial)OthersColor - color used for the slice that contain all slices with value less than MinSlice - AARRGGBB format (default: 0xFFC0C0C0 - grey)StartAngle - start angle of first slice (default: 0)Padding - chart padding (default: 5px)MinSlice - minimum value for a slice to be displayed (default: 1)Bullet - bullet used in legend: Square, Circle (default: Square)BorderColor - border color of chart - AARRGGBB format (default: 0xFF000000 - black)BorderSize - border size of chart (default: 0 - without border)Method Draw requires the ID of pic control where the chart will be draw and the array of data. Example: #include <Charts.au3> #cs $aData[0][0] - contains the number of items in data array $aData[0][1] - is not important (this will be used internaly to store the sum of values) ... $aData[n][0] - value $aData[n][1] - label #ce Local $aData[11][2] = _ [ [10,0], _ [72040000,"China"], _ [36784200,"Russia"], _ [26280000,"India"], _ [20373267,"United states"], _ [19102300,"Ukraine"], _ [11791072,"Poland"], _ [11643769,"Germany"], _ [8743976,"Belarus"], _ [7200000,"Netherlands"], _ [6271000,"France"]] _AutoItObject_Startup() $hMain = GUICreate('Pie chart',500,300) $hPic = GUICtrlCreatePic('',0,0,500,300) $Pie = PieChart() With $Pie .Width = 500 .Height = 300 .Title = 'Potatoes production in 2007 (tonnes)' .TitleHeight = 30 .TitleAlign = "Left" .TitleSize = 11 .TitleStyle = "Bold" .LegendWidth = 200 .LegendTextSize = 10 .LegendStyle = "Italic" .Palette = '0xFF00BEEF|0xFFDC143C|0xFF228B22|0xFF003399|0xFFFF8000|0xFF80FFA0|0xFFFFD700|0xFF800080|0xFFDB7093|0xFF7F00FF' .OthersColor = 0xFFEEE8AA .Background = 0xFFFFFFFF .TextColor = 0xFF002060 .Font = 'Tahoma' .StartAngle = 45 .Padding = 5 .MinSlice = 10000000 .Bullet = "Square" .LegendDetails = 'Percent' .BorderSize = 0 .BorderColor = 0xFF004000 .Draw($hPic,$aData) EndWith GUISetState(@SW_SHOW,$hMain) Do Sleep(10) Until GUIGetMsg() = -3 _AutoItObject_Shutdown() Charts.au3 #include-once #include <AutoItObject.au3> #include <GDIPlus.au3> Func PieChart() Local $oClass = _AutoItObject_Class() With $oClass .AddMethod("Draw","__pie_draw") .AddProperty("Width",$ELSCOPE_PUBLIC) .AddProperty("Height",$ELSCOPE_PUBLIC) .AddProperty("Title",$ELSCOPE_PUBLIC) .AddProperty("TitleHeight",$ELSCOPE_PUBLIC,30) .AddProperty("TitleAlign",$ELSCOPE_PUBLIC,"Left") .AddProperty("TitleSize",$ELSCOPE_PUBLIC,12) .AddProperty("TitleStyle",$ELSCOPE_PUBLIC,'Bold') .AddProperty("LegendWidth",$ELSCOPE_PUBLIC,150) .AddProperty("LegendTextSize",$ELSCOPE_PUBLIC,10) .AddProperty("LegendStyle",$ELSCOPE_PUBLIC,'Italic') .AddProperty("Palette",$ELSCOPE_PUBLIC) .AddProperty("Background",$ELSCOPE_PUBLIC,0xFFFFFFFF) .AddProperty("TextColor",$ELSCOPE_PUBLIC,0xFF000000) .AddProperty("OthersColor",$ELSCOPE_PUBLIC,0xFFC0C0C0) .AddProperty("Font",$ELSCOPE_PUBLIC,'Arial') .AddProperty("StartAngle",$ELSCOPE_PUBLIC,0) .AddProperty("Padding",$ELSCOPE_PUBLIC,5) .AddProperty("MinSlice",$ELSCOPE_PUBLIC,1) .AddProperty("Bullet",$ELSCOPE_PUBLIC,"Square") .AddProperty("LegendDetails",$ELSCOPE_PUBLIC,"Percent") .AddProperty("BorderColor",$ELSCOPE_PUBLIC,0xFF000000) .AddProperty("BorderSize",$ELSCOPE_PUBLIC,0) .AddProperty("Aspect",$ELSCOPE_PUBLIC,1) EndWith Return $oClass.Object EndFunc Func __pie_draw($oObject,$hCtrl,$aData) If $oObject.Aspect < 0.2 Then $oObject.Aspect = 0.2 If $oObject.Aspect > 1 Then $oObject.Aspect = 1 $oObject.StartAngle = Mod($oObject.StartAngle,360) Local $iW = $oObject.Width Local $iH = $oObject.Height Local $iPadding = $oObject.Padding Local $iLW = $oObject.LegendWidth Local $iTH = $oObject.TitleHeight Local $aPalette = StringSplit($oObject.Palette,'|') Local $iBase = $oObject.StartAngle Local $iSweep Local $hBrush, $hTextBrush Local $Align Local $Others Local $TitleSize = $oObject.TitleSize Local $LegendTextSize = $oObject.LegendTextSize Local $TitleStyle, $LegendStyle Local $iHidden, $iVisible If $aPalette[0] < $aData[0][0] Then Return False Switch $oObject.TitleAlign Case "Left" $Align = 0 Case "Center" $Align = 1 Case "Right" $Align = 2 EndSwitch Switch $oObject.TitleStyle Case "Bold" $TitleStyle = 1 Case "Italic" $TitleStyle = 2 Case "Underline" $TitleStyle = 4 Case "Strikethrough" $TitleStyle = 8 EndSwitch Switch $oObject.LegendStyle Case "Bold" $LegendStyle = 1 Case "Italic" $LegendStyle = 2 Case "Underline" $LegendStyle = 4 Case "Strikethrough" $LegendStyle = 8 EndSwitch For $Index = 1 To $aData[0][0] $aData[0][1] += $aData[$Index][0] If $aData[$Index][0] < $oObject.MinSlice Then $Others += $aData[$Index][0] $iHidden += 1 EndIf Next _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW,$iH) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics,2) _GDIPlus_GraphicsSetPixelOffsetMode($hGraphics,4) _GDIPlus_GraphicsClear($hGraphics,$oObject.Background) If $oObject.BorderSize > 0 Then Local $hPen = _GDIPlus_PenCreate($oObject.BorderColor,$oObject.BorderSize) _GDIPlus_GraphicsDrawRect($hGraphics,0,0,$iW,$iH,$hPen) _GDIPlus_PenDispose($hPen) EndIf $iH *= $oObject.Aspect Local $hFamily = _GDIPlus_FontFamilyCreate($oObject.Font) Local $hFontTitle = _GDIPlus_FontCreate($hFamily,$TitleSize,$TitleStyle) Local $hFontLegend = _GDIPlus_FontCreate($hFamily,$LegendTextSize,$LegendStyle) Local $tLayout = _GDIPlus_RectFCreate($iPadding,$iPadding,$iW-$iPadding*2,$iTH) Local $hFormat = _GDIPlus_StringFormatCreate(0x0020) Local $hTextBrush = _GDIPlus_BrushCreateSolid($oObject.TextColor) _GDIPlus_StringFormatSetAlign($hFormat,$Align) _GDIPlus_GraphicsDrawStringEx($hGraphics,$oObject.Title,$hFontTitle,$tLayout,$hFormat,$hTextBrush) For $Index = 1 To $aData[0][0] If $aData[$Index][0] >= $oObject.MinSlice Then $iVisible += 1 $iSweep = $aData[$Index][0]*360/$aData[0][1] $hBrush = _GDIPlus_BrushCreateSolid($aPalette[$Index]) _GDIPlus_GraphicsFillPie($hGraphics,$iPadding,$iPadding+$iTH,$iW-$iLW-$iPadding*2,$iH-$iTH-$iPadding*2,$iBase,$iSweep,$hBrush) Switch $oObject.Bullet Case "Square" _GDIPlus_GraphicsFillRect($hGraphics,$iW-$iLW+$iPadding,$iVisible*$iTH+5,5,5,$hBrush) Case "Circle" _GDIPlus_GraphicsFillEllipse($hGraphics,$iW-$iLW+$iPadding,$iVisible*$iTH+5,5,5,$hBrush) EndSwitch Switch $oObject.LegendDetails Case 'Percent' _GDIPlus_GraphicsDrawStringEx($hGraphics,$aData[$Index][1] & ' (' & Round($aData[$Index][0]*100/$aData[0][1],2) & '%)',$hFontLegend,_GDIPlus_RectFCreate($iW-$iLW+$iPadding+10,$iVisible*$iTH,$iW-$iLW-$iPadding-10,$iTH),$hFormat,$hTextBrush) Case 'Value' _GDIPlus_GraphicsDrawStringEx($hGraphics,$aData[$Index][1] & ' (' & $aData[$Index][0] & ')',$hFontLegend,_GDIPlus_RectFCreate($iW-$iLW+$iPadding+10,$iVisible*$iTH,$iW-$iLW-$iPadding-10,$iTH),$hFormat,$hTextBrush) Case Else _GDIPlus_GraphicsDrawStringEx($hGraphics,$aData[$Index][1],$hFontLegend,_GDIPlus_RectFCreate($iW-$iLW+$iPadding+10,$iVisible*$iTH,$iW-$iLW-$iPadding-10,$iTH),$hFormat,$hTextBrush) EndSwitch _GDIPlus_BrushDispose($hBrush) $iBase += $iSweep EndIf Next If $Others > 0 Then $iSweep = $Others*360/$aData[0][1] $hBrush = _GDIPlus_BrushCreateSolid($oObject.OthersColor) _GDIPlus_GraphicsFillPie($hGraphics,$iPadding,$iPadding+$iTH,$iW-$iLW-$iPadding*2,$iH-$iTH-$iPadding*2,$iBase,$iSweep,$hBrush) Switch $oObject.Bullet Case "Square" _GDIPlus_GraphicsFillRect($hGraphics,$iW-$iLW+$iPadding,($aData[0][0]-$iHidden+1)*$iTH+5,5,5,$hBrush) Case "Circle" _GDIPlus_GraphicsFillEllipse($hGraphics,$iW-$iLW+$iPadding,($aData[0][0]-$iHidden+1)*$iTH+5,5,5,$hBrush) EndSwitch Switch $oObject.LegendDetails Case 'Percent' _GDIPlus_GraphicsDrawStringEx($hGraphics,'Others (' & Round($Others*100/$aData[0][1],2) & '%)',$hFontLegend,_GDIPlus_RectFCreate($iW-$iLW+$iPadding+10,($aData[0][0]-$iHidden+1)*$iTH,$iW-$iLW-$iPadding-10,$iTH),$hFormat,$hTextBrush) Case 'Value' _GDIPlus_GraphicsDrawStringEx($hGraphics,'Others (' & $Others & ')',$hFontLegend,_GDIPlus_RectFCreate($iW-$iLW+$iPadding+10,($aData[0][0]-$iHidden+1)*$iTH,$iW-$iLW-$iPadding-10,$iTH),$hFormat,$hTextBrush) Case Else _GDIPlus_GraphicsDrawStringEx($hGraphics,'Others',$hFontLegend,_GDIPlus_RectFCreate($iW-$iLW+$iPadding+10,($aData[0][0]-$iHidden+1)*$iTH,$iW-$iLW-$iPadding-10,$iTH),$hFormat,$hTextBrush) EndSwitch _GDIPlus_BrushDispose($hBrush) EndIf Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($hCtrl,0x0172,0,$hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontDispose($hFontTitle) _GDIPlus_FontDispose($hFontLegend) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hTextBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndFunc PS: Charts.au3 require AutoItObject.au3
    5 points
  2. Usually you get IP info by connecting to some site that echoes your IP address. The bad thing about that method is almost proverbial need of site administrators to make changes to sites or their policies requiring from you to frequently update your code. Another issue could be caching thingy of the Inet approach. I did some reading about alternative ways to get public IP, and initially tried with SMTP. This Works great but it's kind of slow and on top of that some ISPs tend to block users on port 25 to prevent spam. Then further reading lead me to STUN protocol documentation. STUN servers are made to resolve and echo users' IP addresses, and are often used by VoIP services. The protocol is extremly simple and everything happens very quickly. Client connects (it's UDP so you Know what Imean), sends request, server replies, client parses the response and IP is there. RFC5389 describes STUN in details, so knock yourself out, if you are that crazy. I have found some implementations written in c++ and c sharp, but OMG, some people are just to stubborn and love to write incomprehensible idiotic hundreds of thousands kilobytes of code for something as simple as STUN. That went nowhere for me and gave me only the pain, so I just fall back to RFC and wrote my own client based on documentation. Function is called STUN_GetMyIP() and you can find example of usage in this little script. It's UDP this and UDP that: STUN.au3 If something wouldn't work, do say.
    4 points
  3. 6/3/2014: re-Uploaded a new SciTE4AutoIt3.exe installer with an updated SciTE v3.4.1 release. These are the major changes: - 6/3 Fixed several regressions. - Fixes for reported bugs in Au3Stripper. - Many other minor fixes. Enjoy, Jos Addition/Changes/Fixes in the current installer: -------------------------------------------------------------------------------------------------- 6/3/2014 *** Updated AutoIt3Wrapper 2.2.0.3 (Jos) - Reverted the changes made for Environment variables translation due to a regression when using the GUI. *** Updated Tidy v2.4.1.6 (Jos) - Fixes regression when Delim=0 in some occasions adding a extra "(" character. *** Updated Syntax files to latest production version (Jos) *** Updated several small Helpfile issues. *** Included the proper latest version of the totally re-written AutoItIndentFix.lua. -------------------------------------------------------------------------------------------------- 5/31/2014 *** Updated our version of SciTE v 3.4.1 by Neil Hodgson. (Jos) - Fixed hardcrash in case a very long error line is displayed without spaces. *** Totally re-written the logic used in AutoItIndentFix.lua to better handle Auto Indent corrections. *** Updated AutoIt3Wrapper 2.2.0.2 (Jos) - Added to option to add Environment variables to #AutoIt3Wrapper directives. *** Updated SciTEConfig v1.6.11.13 - Fixed issue with Save+Apply asking again to update the settings. (Jos) - Fixed issue with 3 Checkboxes causing a flicker of the Status field. (Jos) - Fixed issue in UCTManager. (Melba23) *** Updated Tidy v2.4.1.5 (Jos) - Several minor spacing fixes with new syntax variations. - Changed the logic to restore the Folds, Bookmarks, initial line displayed and caret position to make it work on multiple instances of SciTE and better restore the original layout. - Fixed bug when using more than 200 include files. - Fixed writing Indent characters in Commentblocks for empty lines. - Fixed writing ending CRLF in case End_With_NewLine=0 when in commentblock or on commentline. *** Updated Au3Stripper v1.2.1.0 (Jos) - Fixed lexing issue which was in some occasions stripping variables while being used. - Fixed issue when /MO is specified to ensure no other option is performed crippling the output script. - Fixed bug when using more than 200 include files. *** Updated SciTEJump to the latest version v2.18.103.243 (guinness) -------------------------------------------------------------------------------------------------- ==> ScitillaHistory page containing all SciTE/Scintilla updates. ==> Visit the SciTE4AutoIt3 Download page for the latest versions ==> Check the newly formatted online documentation for an overview of all extras you get with this installer.
    2 points
  4. Note that this is a real Windows Explorer. But only the right pane. All functionality of Windows Explorer is working. E.g. keyboard shortcuts, the context (right click) menu, cut, copy, paste, drag & drop and automatic update of the window. Implementations There are three implementations: An implementation for Vista, 7 and 8, an implementation for Windows XP, and a SysListView32 based implementation for Vista, 7 and 8. The latter is named SysLv32.au3 in the examples. This is more or less the Windows XP implementation adapted for Vista, 7 and 8. Functionality The implementations are based on Shell interfaces. This means that most functionality of Windows Explorer is working automatically without any additional code. Other features: Position Explorer window in GUISpecify root and start foldersSpecify an initial icon view modeSpecify an icon view mode for the DesktopSpecify a file filter to filter files by extensionUse folder flags $FWF_NOBACKBROWSING, $FWF_SINGLESEL and $FWF_NOSUBFOLDERSBrowse to child/parent folder with Enter/Backspace keysDelete, disable and insert items in the context menuExecute context menu commands in codeDocumentation Use ExplorerWindowCreate() to create the right pane window. This function is located in Explorer\<Implementation>\WindowsExplorer.au3. You find documentation for the function in top of the file. Documentation for the Vista, 7, 8 implementation is included in the Examples section below. Ini file To handle Rename, New and View in the context menu, it's necessary to be able to identify these items. This seems only to be possible to do, by identifying the names. Because the names are localized, an ini file is used to store the names. Especially the View command depends on the ini file. If the View command isn't recognized, the icon view modes are not set properly. Rename and New commands are depending on the ini file, when the commands are selected with the keyboard. More information in the sections below. First release 2013-11-28 In first release Explorer right pane windows are created with enough functionality to get it to work. There are two implementations: One for Vista, 7 and 8, and one for Windows XP. First update 2014-03-14 This update consists primarily of bug fixes in first release. Because both APIConstants.au3 and WinAPIEx.au3 are included, the scripts can't run on AutoIt 3.3.10 without modifications. A new implementation for Vista, 7 and 8 is added. This implementation is based on a SysListView32 control. This is more or less the Windows XP implementation adapted for Vista, 7 and 8. Second update 2014-04-23 The implementations are based on Shell interfaces, and most functionality of Windows Explorer is working automatically. But you still have to integrate that functionality into your script. Especially you have to take care of keystrokes in combination with various controls and windows. E.g. the rename edit box, the context menu and dialog boxes. This update introduces an ini file: Explorer\Inifiles\ContextMenu.ini Third update 2014-05-02 The third update is mostly about the context menu. It's divided into two parts. The first part is about manipulating the context menu. The example shows how to delete, disable and add custom menu items. The second part shows how to execute context menu commands in code. The example implements Cut, Copy and Paste buttons. The spoiler section starts with an explanation of the message flow and message handlers. Final release 2014-05-10 Left, top, width and height parameters are added to the ExplorerWindowCreate() function. This makes it easier to position the Explorer window in the GUI. When the GUI is resized, the Explorer window is resized so that margins are retained. The margins can be used for buttons or other controls. The new parameters are implemented in the examples. Redundant code is moved from example files to common files. Some minor bug fixes. This is the final release of the small examples. It should not be too difficult to reuse the examples and code. I'm currently working on a large example where an address bar, a toolbar, a left pane and a status bar is implemented besides the right pane. This is a much bigger example, and it'll be more difficult to reuse the code. I'll probably add this example to a new thread. Final release, Vista update 2014-06-21 The Vista, 7, 8 example in first release dated 2013-11-28 was based on Vista code. The XP example was based on XP code. But most of the additional code in the next updates was XP code (see post 40). This meant that some functionality wasn't implemented completely under Vista and later. E.g. icon view modes. Examples The zip contains seven folders at the top level: 1. Basic example2. Position and size3. Navigation buttons4. Toolbar example5. Context menu6. Cut-copy-pasteExplorerThe first six folders are examples. The Explorer folder contains common files and includes. Resources specific for a particular example are contained in the example folder. There are three scripts for each example: Vista, 7, 8.au3, SysLv32.au3 and Windows XP.au3. Other examples (Vista and later) in posts below: Three examples where all panes are implemented (not just the right pane)You can find an example which implements the other panes in this post.This example shows how to merge all include files into a single Include folder.Implement proper tab order between LV and TV, and update LV on up/down keys in TV here.An example that shows how to cancel drag/drop operations can be found here. AutoIt 3.3.8 If you want to run the scripts on AutoIt 3.3.8 you need APIConstants.au3 and WinAPIEx.au3 by Yashied. The UDFs are not included in the zip. You must enable the UDFs in top of ShellFunctions.au3. The UDFs are already added, but commented out. And you must comment out the 3.3.10 UDFs in ShellFunctions.au3 and WERPFuncs.au3. Testet on XP 32 bit and Win 7 32/64 bit. The scripts can be run as both 32 and 64 bit programs. If you are running a 64 bit Windows you should run the scripts as 64 bit programs. Windows Explorer right pane.7z
    1 point
  5. WideBoyDixon

    3D Pie Chart

    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_GraphicsFillPath
    1 point
  6. Jon

    AutoIt v3.3.11.6 Beta

    File Name: AutoIt v3.3.11.6 Beta File Submitter: Jon File Submitted: 30 May 2014 File Category: Beta 3.3.11.6 (30th May, 2014) (Beta) AutoIt: - Changed #2718: SplashOff doc example. - Fixed #2717: Appendix constants page precision about Inet Constants. UDFs: - Added: _Array1DToHistogram(). (thanks jchd) - Added #2702: _ArrayTranspose() set @error to 2 if not Array. - Added #2726: Group ID to return array for _GUICtrlListView_GetGroupInfoByIndex(). - Fixed #2701: _ArrayTranspose() doc for 1D Array. - Fixed #2706: $tagWINDOWINFO bad struct. - Fixed #2718: SplashOff doc example. Au3Check: - Fixed: Undetected errors. Others: - Fixed #2725: AutoIt3.chm printing example. Click here to download this file
    1 point
  7. Andreik

    Return To Castle

    I wanna share a little game named Return To Castle. It's a simple game, until now have 10 levels, but can be created more with a map editor {included}. Maybe the pictures used are not so nice, if anyone want to create new pictures are welcome. To Do: Add soundsMore objects types on mapsBetter pictures for wall, mob, player, gate, castle, life upAdd more levelsHall of Fame Enjoy! Preview versions download: 95+95+152 Return To Castle.rar
    1 point
  8. Andreik

    Return To Castle

    Thank you for interest. I made some updates since I post here but I didn't submit them. For example I've done some new objects like teleport gate, extra speed, special life, etc. Anyway I enjoyed your modifications and cheats. Well done, I like it!
    1 point
  9. argumentum

    Return To Castle

    I liked your code. When I see that the mob move is random, I remembered something about "Extra sensory perception" and I decided to play with your code, I made a mess of the code, so my code don't deserve any attention and is based on yours anyways but I did fix a few things, add unlimited levels, cheats, build-in the editor, made it resizeable. Anyway, here is the compiled one. I see that its been a couple of years since anyone did anything with this. In a way I wanted to thank you for sharing the code to the game. if any one makes a level or a theme, post it here
    1 point
  10. Danp2

    xml scraping

    The error shown doesn't appear to match the code you posted. However, it looks like you are trying to use the $oIE object directly instead of calling one of its functions. To retrieve the XML from the webpage, you can try this: Local $sXML = _IEBodyReadHTML($oIE) You may also want to review the _IEBody* and _IEDoc* functions to see if one of them will work better for your given situation.
    1 point
  11. Hi, You will need a library (DLL if you prefer) to successfully use the SetWindowsHookEx function on an external window. Br, FireFox.
    1 point
  12. Yes, that is what I understood, but I found that I cannot install under different credentials as executing the latest SciTE4AutoIt3.exe installation file always (automatically) request elevated permissions even when evoked under different credentials as non admin - using Win 7. In that way only the admin User LocalAppData section is being populated. Thanks Mungo
    1 point
  13. Look in the help file for Eval() and Assign().
    1 point
  14. That should have been Sleep(10), but all the same really. Sleep(0) indeed has special meaning, which means nothing much here.
    1 point
×
×
  • Create New...