
pinkfoyd
Active Members-
Posts
90 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
pinkfoyd's Achievements

Wayfarer (2/7)
1
Reputation
-
How to draw nice graph / charts
pinkfoyd replied to pinkfoyd's topic in AutoIt General Help and Support
Hi, thanks for the reply, i found finally the solution myself, autoit and powershell... create_chart.au3 Example_conf_chart.ini -
Hi all, For my work, i need to produce automatically chart that i will include in my morning email. First I tried the graph function of powershell with Microsoft Chart Controls , very nice looking, with help of this script : https://gallery.technet.microsoft.com/Drawing-charts-with-6ab5de4e#content BUT is useless as i can't sort data in graph ( object array is ***** in powershell, order is random ) So trying back with autoit. After lot of forum research : RMChart : not working Another script not working, or working but only in autoit GUI ( or can't find the good topic ) Chart.udf : nice but not in GDI so can't produce image ImageMagick : possible but very hard to code the entire line can't use excel, because can't install it on the production server. In a perfect world i would produce this : But simplest will be fine too : Do you know an another solution, any help would be greatly appreciated.
-
Lol, find myself, I deleted the check box, and now is working, the line : _WinAPI_DragAcceptFiles($g_hLabel, GUICtrlRead($idCheck) = $GUI_CHECKED) doesn't work since the GuiCtrlRead change ( with autoit version xxx ? ) to the need of bitAnd. So here is the working example : #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400) Local $idLabel = GUICtrlCreateLabel('', 100, 100, 200, 200) Global $g_hLabel = GUICtrlGetHandle($idLabel) GUICtrlSetBkColor(-1, 0xD3D8EF) GUICtrlCreateLabel('Drop here', 175, 193, 50, 14) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_DROPFILES, $MSGFLT_ALLOW) EndIf ; Register label window proc Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') Global $g_pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_pDll) _WinAPI_DragAcceptFiles($g_hLabel) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_DROPFILES Local $sFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then ConsoleWrite('--------------------------------------------------' & @CRLF) For $i = 1 To $sFileList[0] ConsoleWrite($sFileList[$i] & @CRLF) Next EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit
-
Hi all, i feel stupid, can't made the drag and drop working, does it always work on Windows 10 x 64 ? Trying lot of code on this forum but nothing work Example in the help file don't work neither : #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400) Local $idCheck = GUICtrlCreateCheckbox('Enable Drag && Drop', 10, 370, 120, 19) Local $idLabel = GUICtrlCreateLabel('', 100, 100, 200, 200) Global $g_hLabel = GUICtrlGetHandle($idLabel) GUICtrlSetBkColor(-1, 0xD3D8EF) GUICtrlCreateLabel('Drop here', 175, 193, 50, 14) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_DROPFILES, $MSGFLT_ALLOW) EndIf ; Register label window proc Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') Global $g_pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_pDll) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCheck _WinAPI_DragAcceptFiles($g_hLabel, GUICtrlRead($idCheck) = $GUI_CHECKED) EndSwitch WEnd Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_DROPFILES Local $sFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then ConsoleWrite('--------------------------------------------------' & @CRLF) For $i = 1 To $sFileList[0] ConsoleWrite($sFileList[$i] & @CRLF) Next EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit I never have the console write, tested with file, folder with windows explorer, and nothing... thanks !
-
meoit reacted to a post in a topic: Multiple Translation Tools
-
Hi, I remember a script where i had seen an user inverse state of a button ( $GUI_ENABLE (64) / $GUI_DISABLE (128) ) in one line only I remember it use Bit operation but i cannot reproduce it, can someone help ? In fact if the button is enable i want to disable it and if he is disable , want to enable it, something like that : GuiCtrlSetState ( $button , BitOr ( GuiCtrlGetSate ( $button ) ) ; i know this is NOT working, for explanation only Thanks !
-
Hi, Here is a tool coded in AutoIt to edit multiple ini files ( up to 8 at the same time) to include multilanguage support in your script. The script himself have multilanguage support, simply by using : To change language, i read my global.ini file witch inform me what ini file i had to use... ConsoleWrite ( _string_lang(19) ) Func _string_lang($number) $number = _StringRepeat("0",6-StringLen($number)) & $number $string = IniRead($my_ini_folder & $interface_ini_file,"STRING",$number,"NOT_FOUND") Return($string) EndFunc where 19 is the 19 string in ini file witch look like this : Todo : Initial ini file not necessarily "english.ini" Feel free to use it, give me idea, critical or bug found..... As i am french please be gently Multilangue_autoit.zip
-
- translation
- translate
-
(and 1 more)
Tagged with:
-
Ok ISI360, i found the problem, new GPO on my work computer, I need to launch ISN Studio with administrator right, all is good now, thanks !
- 995 replies
-
- isn autoit studio
- isn
-
(and 3 more)
Tagged with:
-
Hi ISI360, For a long time i have an eye on ism studio, and yesterday, decided to give it a try to see the evolution. But i have a big problem, perhaps i am stupid but... I can't run any code, despite with F5 or launch shortcut from toolbar, it does nothing : Tested with installed or portable version, same problem ( and like your testprojekt, nothing happen ) Thanks !
- 995 replies
-
- isn autoit studio
- isn
-
(and 3 more)
Tagged with:
-
Generate Pie Graph Image File
pinkfoyd replied to pinkfoyd's topic in AutoIt General Help and Support
I successfully change the code to obtain what i want ( delete the graphical interface, fixed pie size & position, white background, external data file, etc...) Here is the code if it interest something else ( the script check data in a ini file ) ;http://www.autoitscript.com/forum/index.php?showtopic=97241 #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 = 5 Global $aChartValue[$NUM_VALUES] Global $aChartColour[$NUM_VALUES] ;~ TERMINEE $aChartValue [0] = IniRead("data.ini","CALYPSO","TERMINEE",0) $aChartColour[0] = 0 * 0x10000 + 255 * 0x100 + 0 ;~ TERMINEE EXCEPTION $aChartValue [1] = IniRead("data.ini","CALYPSO","TERMINEE_EXECP",0) $aChartColour[1] = 50 * 0x10000 + 200 * 0x100 + 0 ;~ EN_COURS $aChartValue [2] = IniRead("data.ini","CALYPSO","EN_COURS",0) $aChartColour[2] = 0 * 0x10000 + 150 * 0x100 + 255 ;~ En erreur $aChartValue [3] = IniRead("data.ini","CALYPSO","EN_ERREUR",0) $aChartColour[3] = 255 * 0x10000 + 0 * 0x100 + 0 ;~ INCONNUES $aChartValue [4] = IniRead("data.ini","CALYPSO","INCONNUE",0) $aChartColour[4] = 0 * 0x10000 + 0 * 0x100 + 0 ; 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 ; Set up GDI+ Global $hWnd = GUICreate("Pie Chart", $PIE_AREA, $PIE_AREA + 100, Default, Default) GUISetBkColor(0xFFFFFF,$hWnd) 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)) _DrawPie($aChartValue, 0.45, 10, 0, 0) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\GDIPlus_Image.jpg") ; 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 ;~ ============================================================ FUNCTIONS ; 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, 0xFFFFFFFF) ; 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) EndSwitch ; Now draw the bitmap on to the device context of the window _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) EndFunc ;==>_DrawPie 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 $hPath = _GDIPlus_PathCreate() If $iStart < 180 And ($iStart + $iSweep > 180) Then _GDIPlus_PathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, $iStart, 180 - $iStart) _GDIPlus_PathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, 180, $iStart - 180) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $ahBrush[$nCount][1]) _GDIPlus_GraphicsDrawPath($hGraphics, $hPath, $ahPen[$nCount]) $fDrawn = True EndIf If $iStart + $iSweep > 360 Then _GDIPlus_PathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, 0, $iStart + $iSweep - 360) _GDIPlus_PathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, $iStart + $iSweep - 360, 360 - $iStart - $iSweep) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $ahBrush[$nCount][1]) _GDIPlus_GraphicsDrawPath($hGraphics, $hPath, $ahPen[$nCount]) $fDrawn = True EndIf If $iStart < 180 And (Not $fDrawn) Then _GDIPlus_PathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep) _GDIPlus_PathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, $iStart + $iSweep, -$iSweep) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $ahBrush[$nCount][1]) _GDIPlus_GraphicsDrawPath($hGraphics, $hPath, $ahPen[$nCount]) EndIf _GDIPlus_PathDispose($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 and here is the DATA.ini file : [CALYPSO] EN_ERREUR=5 EN_COURS=6 TERMINEE=80 TERMINEE_EXECP=3 INCONNUE=1 and the result : All credits to WideBoyDixon -> '?do=embed' frameborder='0' data-embedContent>> -
Generate Pie Graph Image File
pinkfoyd replied to pinkfoyd's topic in AutoIt General Help and Support
Thanks guy, but i need to save the pie in an image format ( PNG, JPG ... ) to integrate it in my html page.... The problem is the mail, witch limit me to display the chart... EDIT : oh ! Trying to play with the code in #4 of topic www.autoitscript.com/forum/topic/161750-pie-chart added "_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "Image.jpg") " and it works ! will study the code to understand why it works with this code, thanks :! -
HI, I have made an AutoIt script to chek report of Calypso and BackupExec at work. I generate an html page that i send by email to us. It works pretty well. But now, i want to improve the report with some graph. After 2 hours search, i can't find a good an eay solution. I want to integrate a Pie graph in my report, so the easiest and safer way to to this is to integrate a PNG or JPG image in my html report. But do you know a method to generate a pie in autoit or in command line. The closest solution is to use ImageMagick tools, but the syntax is pretty complicated. ( and i can't successfully use the "_GDIPlus_ImageSaveToFile" function work with pie ) I CAN'T USE any web online or PHP tools, like my script run on a PROD server without any appache, php, or internet access. Thanks a lot !
-
GDI+ animated loading screens build 2014-06-20 (32 examples)
pinkfoyd replied to UEZ's topic in AutoIt Example Scripts
Hi again, Two little question please ^^ Can you explain me the purpose of this : Global Const $STM_SETIMAGE = 0x0172; ( tried to change 172, only this number seem working ) Can we have a transparent backgroung or changing the background color ? Thanks !!