Jump to content

taz742

Active Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by taz742

  1. Many thanks for the function. It work like a charm.
  2. Great tool! Adopted & now I can't work without BTW, I've rewrite an internal function because sometime it crash because of not finding the script path. Get it here: Func _SciTEGetFilePath() Local $tTitle = WinGetTitle("[CLASS:SciTEWindow]"), $tSplitBy = '*' If StringInStr($tTitle, 'Untitled') Then SetError(2) ; Not File Return '' EndIf If $tmpSciTETitle == $tTitle Then Return $tmpFileSciTE $tmpSciTETitle = $tTitle Local $SS = StringRegExpReplace ($tTitle, "(.*?)([ ].[ ]SciTE(?i:[ ]\[\d*[ ]of[ ]\d*\])?)\Z","\1") If FileExists($SS) Then $tmpFileSciTE = $SS Return $SS EndIf Return SetError(3, 0, 0) EndFunc ;==>_SciTEGetFilePath
  3. @Bowmore: Thanks for feedback same result here after commented lines related to $LVN_ITEMCHANGED -> No crash at all. Here my last result with 5000 rows : [3.3.4.0-x86] _display(5000) : 2803.02598332793 ms [3.3.4.0-x64] _display(5000) : 2490.92321654795 ms [3.3.5.1-x86] _display(5000) : 11922.7872642731 ms !!!! [3.3.5.1-x64] _display(5000) : 2535.45626555862 ms [3.3.5.3-x86] _display(5000) : 32257.3882287615 ms !!!! from bad to worse [3.3.5.3-x64] _display(5000) : 5542.96872995024 ms !!!! slower too @PsaltyDS: Yes I'm on Win7x64 but I work with AutoIt x86 I've revert back to 3.3.5.1 since 3.3.5.2 is reported buggy on x86 x86 Results are still 4x slower than 3.3.4.0 with the demo from the help or why my fixed script.
  4. Damn you're right the demo from the help wronk like a charm: 2D loads 5000x4 in 2.14sec using v3.3.5.2 2D loads 5000x4 in 0.48sec using v3.3.4.0 so latest beta is around 4 times slower than stable version.... any reason? BTW I find what cause my crash: It's the GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") line So I've made some errors in the _WM_NOTIFY() func: if somebody have idea...
  5. Maybe I've post in the wrong place: _GUICtrlListView_AddArray() can be more suitable here "Graphical User Interface (GUI) Help and Support"...
  6. Well I've a problem with _GUICtrlListView_AddArray() when array is larger than 1000 items with last stable & beta version So using 1000 items: it work (sometimes very slow but it work) So using more than 1000 items: v3.3.0.0: work finev3.3.2.0: work at very slow speedv3.3.4.0: Failedv3.3.5.1: FailedTest yourself and if somebody know the reason: just let me know #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ListviewConstants.au3> #include <GuiListView.au3> #include <GuiStatusBar.au3> #include <Array.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Global $ProcessTime Global $bSort = 0, $bColumn = 1 $GUI = GUICreate("ListView TEST", 600, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $Btn_1000 = GUICtrlCreateButton("Populate" & @CRLF & "ListView 1000", 150, 13, 100, 36, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetCursor(-1, 0) $Btn_1001 = GUICtrlCreateButton("Populate" & @CRLF & "ListView 1001", 350, 13, 100, 36, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetCursor(-1, 0) $Debug_LV = False $ListView = GUICtrlCreateListView("column1|column2|column3|column4|column5|column6|column7|column8|column9", 1, 60, 598, 314, $LVS_REPORT) _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) GUICtrlSetResizing($ListView, $GUI_DOCKBORDERS) For $j = 1 To 8 If $j = 4 Then ContinueLoop _GUICtrlListView_JustifyColumn($ListView, $j, 1) Next Dim $a_ctrl_status_part[7] = [115, 180, 255, 300, 335, 385, -1] Dim $a_ctrl_status_text[10] = [@AutoItVersion, 'by "taz742"', "", "#Items", "Total", "", ""] Global $ctrl_status = _GUICtrlStatusBar_Create($GUI, $a_ctrl_status_part, $a_ctrl_status_text) _GUICtrlStatusBar_SetMinHeight($ctrl_status, 23) GUIRegisterMsg($WM_SIZE, "_WM_SIZE") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg;[0] Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_SIZE, "") GUIRegisterMsg($WM_NOTIFY, "") If $ProcessTime Then MsgBox("", "ProcessTime Results", "Current ProcessTime Results are copied to ClipBoard" & @CRLF & @CRLF & $ProcessTime) EndIf Exit Case $Btn_1000 _display(1000) Case $Btn_1001 _display(1001) EndSwitch WEnd Func _display($rows) $chrono = TimerInit() GUISetCursor(15, 1, $GUI) Local $a_filelist_ext = "" Dim $a_filelist_ext[$rows][9] For $x = 0 To $rows - 1 $a_filelist_ext[$x][0] = Random(100000000, 9999999999, 1) $a_filelist_ext[$x][1] = Random(1, 365 * 2, 1) $a_filelist_ext[$x][2] = StringFormat("%04d/%02d/%02d %02d:%02d:%02d", Random(2009, 2010, 1), Random(1, 12, 1), Random(1, 31, 1), Random(0, 23, 1), Random(1, 59, 1), Random(1, 59, 1)) $a_filelist_ext[$x][3] = Random(0, 4000, 1) $a_filelist_ext[$x][4] = StringFormat("%x", Random(3, 9999999999, 1)) $a_filelist_ext[$x][5] = Random(1, 210000000, 1) $a_filelist_ext[$x][6] = Random(1, 9999999999) $a_filelist_ext[$x][7] = StringFormat("%08x", Random(3, 9999999999, 1)) $a_filelist_ext[$x][8] = Random(3, 9999999999, 0) Next _ArraySort($a_filelist_ext, $bSort, 0, 0, 2) _UpdateColumnArrowSort(2) ConsoleWrite('@@ Trace(63) : _GUICtrlListView_BeginUpdate($ListView)' & @crlf) ;### Trace Console _GUICtrlListView_BeginUpdate($ListView) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(65) : _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView))' & @crlf) ;### Trace Console _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView)) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(67) : _GUICtrlListView_AddArray($ListView, $a_filelist_ext)' & @crlf) ;### Trace Console _GUICtrlListView_AddArray($ListView, $a_filelist_ext) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(69) : _GUICtrlListView_EndUpdate($ListView)' & @crlf) ;### Trace Console _GUICtrlListView_EndUpdate($ListView) ConsoleWrite('>Error code: ' & @error & @crlf & @CRLF) _UpdateColumnWidth($ListView) GUISetCursor(2, 0, $GUI) Local $autoitarch Switch @AutoItX64 Case 0 $autoitarch = "x86" Case 1 $autoitarch = "x64" EndSwitch $ProcessTime &= "[" & @AutoItVersion & "-" & $autoitarch & "] _display(" & $rows & ") : " & TimerDiff($chrono) & " ms" & @CRLF ClipPut($ProcessTime) EndFunc ;==>_display Func _UpdateColumnWidth(ByRef $ListView) GUISetCursor(15, 1, $GUI) For $cw = 0 To _GUICtrlListView_GetColumnCount($ListView) - 1 _GUICtrlListView_SetColumnWidth($ListView, $cw, $LVSCW_AUTOSIZE_USEHEADER) Next GUISetCursor(2, 0, $GUI) EndFunc ;==>_UpdateColumnWidth Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $ListView If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) Local $nIndex = DllStructGetData($tInfo, "Index") Switch _GUICtrlListView_GetItemChecked($hWndFrom, $nIndex) Case True _GUICtrlListView_SetItemChecked($hWndFrom, $nIndex, False) Case False _GUICtrlListView_SetItemChecked($hWndFrom, $nIndex, True) EndSwitch Case $LVN_ITEMCHANGED Local $ItemsTotal = _GUICtrlListView_GetItemCount($hWndFrom) If Not (_GUICtrlStatusBar_GetText($ctrl_status, 5) == $ItemsTotal) Then _GUICtrlStatusBar_SetText($ctrl_status, $ItemsTotal, 5) EndSwitch EndSwitch Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Func _WM_SIZE() _GUICtrlStatusBar_Resize($ctrl_status) Return $GUI_RUNDEFMSG EndFunc ;==>_WM_SIZE Func _UpdateColumnArrowSort($nColumn) ; bells and whistles (I): ; mark the sorted column with a grey rectangle GUICtrlSendMsg($ListView, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($ListView), 0) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($ListView), "int", 0, "int", 1) ; bells and whistles (II): ; create an arrow in the listview header Local $iFormat Local Const $hHeader = _GUICtrlListView_GetHeader($ListView) ; clear existing arrows For $x = 0 To _GUICtrlHeader_GetItemCount($hHeader) - 1 $iFormat = _GUICtrlHeader_GetItemFormat($hHeader, $x) If BitAND($iFormat, $HDF_SORTDOWN) Then _GUICtrlHeader_SetItemFormat($hHeader, $x, BitXOR($iFormat, $HDF_SORTDOWN)) ElseIf BitAND($iFormat, $HDF_SORTUP) Then _GUICtrlHeader_SetItemFormat($hHeader, $x, BitXOR($iFormat, $HDF_SORTUP)) EndIf Next ; set arrow in current column ;~ Local $nColumn = GUICtrlGetState($ListView) $iFormat = _GUICtrlHeader_GetItemFormat($hHeader, $nColumn) If $bSort == 0 And $bColumn == $nColumn Then ; ascending _GUICtrlHeader_SetItemFormat($hHeader, $nColumn, BitOR($iFormat, $HDF_SORTUP)) Else ; descending _GUICtrlHeader_SetItemFormat($hHeader, $nColumn, BitOR($iFormat, $HDF_SORTDOWN)) EndIf $bColumn = $nColumn EndFunc ;==>_UpdateColumnArrowSort Here my timer results (average of 10 run each) using previous script on different AutoIt version: (would know why some of them are so slow or failed...) /----------------------------------------------------+-----------------------------------------------------\ | AutoIt 32 bits | AutoIt 64 bits | |----------------------------------------------------+-----------------------------------------------------| | [3.3.0.0-x86] _display(1000) : 2436.50217791475 ms | [3.3.0.0-x64] _display(1000) : 1317.69232025496 ms | | [3.3.0.0-x86] _display(1001) : 2179.04862337590 ms | [3.3.0.0-x64] _display(1001) : 1126.74880605477 ms | | | | | [3.3.2.0-x86] _display(1000) : 9651.61576311007 ms | [3.3.2.0-x64] _display(1000) : 63151.07472569010 ms | | [3.3.2.0-x86] _display(1001) : 9662.51303599217 ms | [3.3.2.0-x64] _display(1001) : 63430.03399273480 ms | | | | | [3.3.4.0-x86] _display(1000) : 2524.11897690500 ms | [3.3.4.0-x64] _display(1000) : 2111.093483520410 ms | | [3.3.4.0-x86] _display(1001) : Failed at 1000 rows | [3.3.4.0-x64] _display(1001) : Failed at 1000 rows | | | | | [3.3.5.1-x86] _display(1000) : 2459.72735820223 ms | [3.3.5.1-x64] _display(1000) : 2065.324377480340 ms | | [3.3.5.1-x86] _display(1001) : Failed at 1000 rows | [3.3.5.1-x64] _display(1001) : Failed at 1000 rows | \----------------------------------------------------+-----------------------------------------------------/
  7. I think that you need to redefine your variable twice on your 1st posted script because you're waiting StdOut data from a process and once you've received data this process die & its handle too. Am I wrong? If I'm right: maybe this script can help you (Done from scratch ) Global $result1 = "", $result2 = "" $result1 = _SNMPget() sleep(1000) $result2 = _SNMPget() If BitAND(IsArray($result1), IsArray($result2)) = 1 Then MsgBox(0, "Octets", StringMid($result2[0], $result2[1] + 10) & StringMid($result1[0], $result1[1] + 10)) MsgBox(0, "works? ", (StringMid($result2[0], $result2[1] + 10) - StringMid($result1[0], $result1[1] + 10)) * 8 / 1000000) Else MsgBox(4096,"Bug", "Are $result# Array?" & @crlf & @crlf & _ "$result1 = " & IsArray($result1) & @crlf & _ "$result2 = " & IsArray($result2)) EndIf ;MsgBox(0, '', StringMid($snmp, 1)) Exit ;-Func _SNMPget() ;- ;-Retrieve the data(s) you want and return them into an array Func _SNMPget() Local $result Dim $result[2] Local $SNMPget = Run(@ComSpec & " /c c:\windows\system32\snmputil.exe get 10.10.10.10 public .1.3.6.1.2.1.2.2.1.10.4", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 Sleep(100) $result[0] = StdoutRead($SNMPget) If @error Then ExitLoop WEnd $result[1] = StringInStr($result[0], "Counter32") Return $result EndFunc ;==>_SNMPget
  8. Why using UDF if you need to replace output after? Just rewrite it as you need Here is want you want: $filenameformat = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & ";" & @MIN & ";" & @SEC ;output = yyyy-mm-dd_hh;mm;ss ;~ $filenameformat = @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC ;output = yyyymmdd_hhmmss $file = $filenameformat & ".txt" $o_file = FileOpen($file, 1+8) FileWriteLine($o_file , "your text here") FileClose($o_file)
  9. Nice app BTW I just made little change by replacing: If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" by this one: If @AutoItX64 = 0 Then $sGUITitle = "Icon Configuration Utility - 32bit version"
  10. Thanks for your reply. I've discovered what you explain doing a copy and move operation with DOS routine. So it's definitely NOT an AutoIt lack or bug.
  11. I've a problem when using FileMove function with resulting file permission. I've discover the problem because there is a lock overlayed icon the moved file: Here an example script to reproduce my problem: $file=@TempDir & "\filetest.txt" $filehndl=FileOpen($file,2) FileWriteLine($filehndl, "some text") FileClose($filehndl) FileCopy($file, @SystemDir & "\filetest_copy.txt",1) FileMove($file, @SystemDir & "\filetest_move.txt",1) Run('Explorer.exe "' & @SystemDir & '"') The @SystemDir & "\filetest_copy.txt" has it permissions inherit from the @systemdir folder (which is normal) but the @SystemDir & "\filetest_move.txt" has it own permissions (and this is problematic) So my questions are simple: Is this normal or a bug?If it's a bug how can I solve it?PS: I'm using Win7x64 OS
  12. Thanks a lot trancexx for this useful unix timestamp encode/decode functions
  13. I use Lazycat's "WM_DROPFILES_FUNC" for a while with no problem but yesterday i've notice a lack in this function: Files with unicode char in their name aren't supported so i've search the unicode function... And i've found it: "DragQueryFileW" instead of DragQueryFile or DragQueryFileA for ANSI #include <GUIConstants.au3> #include <WindowsConstants.au3> Global $WM_DROPFILES = 0x233 Global $gaDropFiles[1], $str = "" ### Koda GUI section start ### $hGUI = GUICreate("Test", 400, 200, 219, 178, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) $hList = GUICtrlCreateList("", 5, 5, 390, 190) GUICtrlSetState (-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) ### Koda GUI section end ### GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_UNICODE_FUNC") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $str = "" For $i = 0 To UBound($gaDropFiles) - 1 $str &= "|" & $gaDropFiles[$i] Next GUICtrlSetData($hList, $str) EndSwitch WEnd Func WM_DROPFILES_UNICODE_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("wchar[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "int", DllStructGetPtr($pFileName), "int", $nSize) ReDim $gaDropFiles[$i + 1] $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next EndFunc ;==>WM_DROPFILES_UNICODE_FUNCMultiDropUnicodeTest.au3 Njoy !
  14. All the donwload links are no working... so we can't test it...
  15. @Valuter: you're right using a filefullpath without extention for a file is not recommanded. @Redbeard: Replace @LF by @CRLF into your script and it will run as expected.
  16. To write Null char the file must be open in binary mode before writing. and it's better to always use this form when writing/reading file FileOpen ( "filename", mode ) "filename" = Filename of the text file to open. "mode" = Mode (read or write) to open the file in. Can be a combination of the following: 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks). 16 = Force binary(byte) reading and writing mode with FileRead and FileWrite 32 = Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM 64 = Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM 128 = Use Unicode UTF8 reading and writing mode. Reading does not override existing BOM Both write modes will create the file if it does not already exist. The folder path must already exist (except using mode '8') $handle = FileOpen("path_to_your_file_to_open") FileWrite($handle, "some text") FileClose($handle)oÝ÷ Ù*-¯+aȧ¶¨º»®*mjÆ«zZqéÖ®¶­sdgVæ2fÆTFBb33c¶fÆR¢b33c¶öfÆSÔfÆT÷VâgV÷Cµv÷&¶ærb3#µ&W6÷W&6W2b3#·v#6Öæ×gV÷C²Ã³b²÷""³bFòW&6R&Wf÷W2fÆR6öçFVç@¢fÆUw&FRb33c¶öfÆRÂb33c¶fÆRf×´6"f×´6"2¢fÆT6Æ÷6Rb33c¶öfÆR¤VæDgVæ
  17. You want that your autoit script compiled as a console application return data why do not simply use: ConsoleWrite() for return data and ConsoleWriteError() for @error code. Compile this code: #AutoIt3Wrapper_OutFile=C:\StdOut_demo.exe #AutoIt3Wrapper_Change2CUI=y; needed only if your really want a console application ; your code $ReturnData = "Hello World!" ;this could be data binary if needed $ReturnError = 0; ConsoleWrite($ReturnData) ConsoleWriteError($ReturnError) Exit; end of your scriptoÝ÷ Ø Ý¶§®éí+ºÚ"µÍÚ[ÛYH ÐÛÛÝ[Ë]LÉÝÂÌÍÔÝÝ]Ñ^HH ][ÝØÎÌLÔÝÝ]Ù[[Ë^I][ÝÂYÝ[Q^ÝÊ ÌÍÔÝÝ]Ñ^JH[^]ÙÐÞ M ][ÝÑÜ][ÝË ][ÝÐØ[ÌÎNÝ[I][ÝÈ [È ÌÎNÉ][ÝÉÌÎNÈ [È ÌÍÔÝÝ]Ñ^H [È ÌÎNÉ][ÝÉÌÎNÊBÌÍÚTQH[ ÌÍÔÝÝ]Ñ^K ][ÝÉ][ÝË ][ÝÉ][ÝË ÌÍÔÕÕUÐÒS ÉÌÍÔÕTÐÒS B[H ÌÍÜÔXYH ][ÝÉ][ÝË ÌÍÜÑÜXYH ][ÝÉ][ÝÂÚ[HB ÌÍÜÔXY [ÏHÝÝ]XY ÌÍÚTQ[ÙK[ÙJBIÌÍÜÑÜXY [ÏHÝXY ÌÍÚTQ[ÙK[ÙJBYÜ[^]ÛÜÑ[ÙÐÞ ÌÎNÔXYÛH ][ÝÉÌÎNÈ [È ÌÍÔÝÝ]Ñ^H [È ÌÎNÉ][ÝÉÌÎNË ][ÝÔÕÕUH ][ÝÈ [È ÌÍÜÔXY [ÈÔ [È ][ÝÔÕTH ][ÝÈ [È ÌÍÜÑÜXY
  18. I hope this RegExp pattern help you $file = 'path to html-file' $source = FileRead($file) $ret = StringRegExp($source, '(?:<script>)(?s)(.*?)(?:</script>)', 3) _Array2Console($ret) Func _Array2Console(ByRef $array);Enumerate Array in SciTE Console or in Console when compiled as a Console application Local $i If IsArray($array) Then Switch UBound($array, 0) Case 1 For $i = 0 To UBound($array) - 1 ConsoleWrite("[" & $i & "] = " & $array[$i] & @CRLF) Next ConsoleWrite(@CRLF) Case Else ConsoleWrite("Error : Max Array Dimension Supported = 1 >> Current is " & UBound($array, 0) & @CRLF) EndSwitch Else ConsoleWrite("[not array] String = " & $array & @CRLF) EndIf EndFunc ;==>_Array2Console
  19. The last working imagemagickobject.dll version is the static v6.4.1-2: you could get it here: ImageMagick-6.4.1-2-Q8-windows-static.exe ImageMagick-6.4.1-2-Q16-windows-static.exe After this version imagemagickobject.dll seems to be not fully static
  20. @Malkey: you and others have inspired me so take a look to my little job here: _GDIPlus_PicSetGradient()
  21. I've play with GDIPlus User fonction and finally I wrote this one from other. It fill a Pic Control with a gradient color linear or not. Capture: #include <GDIPlus.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> $hGui = GUICreate("Pic Gradients", 670, 450) GUISetState() Global $picW = 100, $picH = 100 Dim $aBlends3[3] = [0xFFFFFFFF, 0xFFAA0000, 0xFF000000];3 colors gradient set Dim $aBlends4[4] = [0xFF00FF00, 0xFFFFFF00, 0xFF00FFFF, 0xFFFF0000];4 colors gradient set Dim $aPositions3[3] = [0, 0.8, 1];custom positions array for 3 colors Dim $aPositions4[4] = [0, 0.2, 0.4, 1]; custom positions array for 4 colors $Pic1 = GUICtrlCreatePic("", 10+($picW+10)*0, 10+($picH+10)*0, $picW, $picH) $Pic2 = GUICtrlCreatePic("", 10+($picW+10)*1, 10+($picH+10)*0, $picW, $picH) $Pic3 = GUICtrlCreatePic("", 10+($picW+10)*0, 10+($picH+10)*1, $picW, $picH) $Pic4 = GUICtrlCreatePic("", 10+($picW+10)*1, 10+($picH+10)*1, $picW, $picH) _GDIPlus_PicSetGradient($Pic1, $aBlends3, 0x00000000);Linear Gradient Horizontal 3 colors _GDIPlus_PicSetGradient($Pic2, $aBlends3, 0x00000001);Linear Gradient Vertical 3 colors _GDIPlus_PicSetGradient($Pic3, $aBlends3, 0x00000002);Linear Gradient ForwardDiagonal 3 colors _GDIPlus_PicSetGradient($Pic4, $aBlends3, 0x00000003);Linear Gradient BackwardDiagonal 3 colors $Pic5 = GUICtrlCreatePic("", 10+($picW+10)*3, 10+($picH+10)*0, $picW, $picH) $Pic6 = GUICtrlCreatePic("", 10+($picW+10)*4, 10+($picH+10)*0, $picW, $picH) $Pic7 = GUICtrlCreatePic("", 10+($picW+10)*3, 10+($picH+10)*1, $picW, $picH) $Pic8 = GUICtrlCreatePic("", 10+($picW+10)*4, 10+($picH+10)*1, $picW, $picH) _GDIPlus_PicSetGradient($Pic5, $aBlends3, 0x00000000, $aPositions3);Custom Gradient Horizontal 3 colors _GDIPlus_PicSetGradient($Pic6, $aBlends3, 0x00000001, $aPositions3);Custom Gradient Vertical 3 colors _GDIPlus_PicSetGradient($Pic7, $aBlends3, 0x00000002, $aPositions3);Custom Gradient ForwardDiagonal 3 colors _GDIPlus_PicSetGradient($Pic8, $aBlends3, 0x00000003, $aPositions3);Custom Gradient BackwardDiagonal 3 colors $Pic9 = GUICtrlCreatePic("", 10+($picW+10)*0, 10+($picH+10)*2, $picW, $picH) $Pic10 = GUICtrlCreatePic("", 10+($picW+10)*1, 10+($picH+10)*2, $picW, $picH) $Pic11 = GUICtrlCreatePic("", 10+($picW+10)*0, 10+($picH+10)*3, $picW, $picH) $Pic12 = GUICtrlCreatePic("", 10+($picW+10)*1, 10+($picH+10)*3, $picW, $picH) _GDIPlus_PicSetGradient($Pic9, $aBlends4, 0x00000000);Linear Gradient Horizontal 4 colors _GDIPlus_PicSetGradient($Pic10, $aBlends4, 0x00000001);Linear Gradient Vertical 4 colors _GDIPlus_PicSetGradient($Pic11, $aBlends4, 0x00000002);Linear Gradient ForwardDiagonal 4 colors _GDIPlus_PicSetGradient($Pic12, $aBlends4, 0x00000003);Linear Gradient BackwardDiagonal 4 colors $Pic13 = GUICtrlCreatePic("", 10+($picW+10)*3, 10+($picH+10)*2, $picW, $picH) $Pic14 = GUICtrlCreatePic("", 10+($picW+10)*4, 10+($picH+10)*2, $picW, $picH) $Pic15 = GUICtrlCreatePic("", 10+($picW+10)*3, 10+($picH+10)*3, $picW, $picH) $Pic16 = GUICtrlCreatePic("", 10+($picW+10)*4, 10+($picH+10)*3, $picW, $picH) _GDIPlus_PicSetGradient($Pic13, $aBlends4, 0x00000000, $aPositions4);Custom Gradient Horizontal 4 colors _GDIPlus_PicSetGradient($Pic14, $aBlends4, 0x00000001, $aPositions4);Custom Gradient Vertical 4 colors _GDIPlus_PicSetGradient($Pic15, $aBlends4, 0x00000002, $aPositions4);Custom Gradient ForwardDiagonal 4 colors _GDIPlus_PicSetGradient($Pic16, $aBlends4, 0x00000003, $aPositions4);Custom Gradient BackwardDiagonal 4 colors Do Sleep(25) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;==== _GDIPlus_PicSetGradient === Taz742 function ; Description - Fill a Pic control with linear or custom gradient from a set of boundary points and boundary colors. ; =========== ; $cID - Pic ControlID ; ; $aBlend - Pointer to an array of ARGB colors that specify the colors to be interpolated ; for this linear gradient brush. A color of a given index in the blend array ; corresponds to the blend position of that same index in the positions array. ; ; $iDirection - {Opt} GradientHorizontal = 0x00000000 <Default> ; GradientVertical = 0x00000001 ; GradientForwardDiagonal = 0x00000002 ; GradientBackwardDiagonal = 0x00000003 ; ; $aPositions - {Opt} If non-array or non specified, a linear array will be internaly created. ; Pointer to an array of real numbers that specify blend factors' positions. Each number in the array ; indicates a percentage of the distance between the starting boundary and the ending boundary ; and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the ; gradient and 1.0 indicates the ending boundary. There must be at least two positions ; specified: the first position, which is always 0.0, and the last position, which is always ; 1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a ; line, parallel to the boundary lines, that is a certain fraction of the distance from the ; starting boundary to the ending boundary. For example, a blend position of 0.7 indicates ; the line that is 70 percent of the distance from the starting boundary to the ending boundary. ; ; Requirement: #include <GDIPlus.au3> ;============= _GDIPlus_CreateLineBrushFromRect() ; _GDIPlus_SetLinePresetBlend() ;================================================= Func _GDIPlus_PicSetGradient($cID, $aBlends, $iDirection = 0x00000000, $aPositions = "") If Not IsArray($aBlends) Then Dim $aBlends[2] = [0xFFFFFFFF, 0xFF000000] If Not IsArray($aPositions) Then Local $BlendsDim = UBound($aBlends) Dim $aPositions[$BlendsDim] For $i=0 To $BlendsDim -1 $aPositions[$i] = 1/($BlendsDim-1)*$i Next EndIf Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local $hWnd, $cID_Pos, $hBitmap, $hImage, $hGraphic, $hBrushLin, $hbmp, $aBmp $hWnd = GUICtrlGetHandle($cID) $cID_Pos = ControlGetPos("", "", $hWnd) $hBitmap = _WinAPI_CreateBitmap($cID_Pos[2], $cID_Pos[3], 1, 32) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrushLin = _GDIPlus_CreateLineBrushFromRect(0, 0, $cID_Pos[2], $cID_Pos[3], $aPositions, $aPositions, $aBlends[0], $aBlends[UBound($aBlends)-1], $iDirection) _GDIPlus_SetLinePresetBlend($hBrushLin, $aBlends, $aPositions) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $cID_Pos[2], $cID_Pos[3], $hBrushLin) $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hbmp) If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0]) _GDIPlus_ImageDispose($hImage) _GDIPlus_BrushDispose($hBrushLin) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hbmp) _WinAPI_DeleteObject($hBitmap) _GDIPlus_Shutdown() EndFunc ;==>_GDIPlus_PicSetGradient ;====_GDIPlus_CreateLineBrushFromRect === Malkey's function ;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors. ; $aFactors - If non-array, default array will be used. ; Pointer to an array of real numbers that specify blend factors. Each number in the array ; specifies a percentage of the ending color and should be in the range from 0.0 through 1.0. ;$aPositions - If non-array, default array will be used. ; Pointer to an array of real numbers that specify blend factors' positions. Each number in the array ; indicates a percentage of the distance between the starting boundary and the ending boundary ; and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the ; gradient and 1.0 indicates the ending boundary. There must be at least two positions ; specified: the first position, which is always 0.0, and the last position, which is always ; 1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a ; line, parallel to the boundary lines, that is a certain fraction of the distance from the ; starting boundary to the ending boundary. For example, a blend position of 0.7 indicates ; the line that is 70 percent of the distance from the starting boundary to the ending boundary. ; The color is constant on lines that are parallel to the boundary lines. ; $iArgb1 - First Top color in 0xAARRGGBB format ; $iArgb2 - Second color in 0xAARRGGBB format ; $LinearGradientMode - LinearGradientModeHorizontal = 0x00000000, ; LinearGradientModeVertical = 0x00000001, ; LinearGradientModeForwardDiagonal = 0x00000002, ; LinearGradientModeBackwardDiagonal = 0x00000003 ; $WrapMode - WrapModeTile = 0, ; WrapModeTileFlipX = 1, ; WrapModeTileFlipY = 2, ; WrapModeTileFlipXY = 3, ; WrapModeClamp = 4 ; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2, ; LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient) ; Reference: http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _ $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0) Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount If $iArgb1 = Default Then $iArgb1 = 0xFF0000FF If $iArgb2 = Default Then $iArgb2 = 0xFFFF0000 If $LinearGradientMode = -1 Or $LinearGradientMode = Default Then $LinearGradientMode = 0x00000001 If $WrapMode = -1 Or $LinearGradientMode = Default Then $WrapMode = 1 $tRect = DllStructCreate("float X;float Y;float Width;float Height") $pRect = DllStructGetPtr($tRect) DllStructSetData($tRect, "X", $iX) DllStructSetData($tRect, "Y", $iY) DllStructSetData($tRect, "Width", $iWidth) DllStructSetData($tRect, "Height", $iHeight) ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _ "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0) If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0] If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0] $iCount = UBound($aPositions) $tFactors = DllStructCreate("float[" & $iCount & "]") $pFactors = DllStructGetPtr($tFactors) For $iI = 0 To $iCount - 1 DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1) Next $tPositions = DllStructCreate("float[" & $iCount & "]") $pPositions = DllStructGetPtr($tPositions) For $iI = 0 To $iCount - 1 DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1) Next $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _ "ptr", $pFactors, "ptr", $pPositions, "int", $iCount) Return $aRet[6] ; Handle of Line Brush EndFunc ;==>_GDIPlus_CreateLineBrushFromRect ;=========================================================== ; Description: Sets the colors to be interpolated for this linear gradient brush and their ; corresponding blend positions. ; Parameters ; $hBrush [in] Pointer to the LinearGradientBrush object. ; $aBlend [in] Pointer to an array of ARGB colors that specify the colors to be interpolated ; for this linear gradient brush. A color of a given index in the blend array ; corresponds to the blend position of that same index in the positions array. ; $aPositions [in] Pointer to an array of real numbers that specify the blend positions. ; Each number in the array specifies a percentage of the distance between ; the starting boundary and the ending boundary and is in the range from ; 0.0 through 1.0, where 0.0 indicates the starting boundary of the gradient ; and 1.0 indicates the ending boundary. There must be at least two positions ; specified: the first position, which is always 0.0f, and the last position, ; which is always 1.0f. Otherwise, the behavior is undefined. A blend position ; between 0.0 and 1.0 indicates the line, parallel to the boundary lines, ; that is a certain fraction of the distance from the starting boundary to the ; ending boundary. For example, a blend position of 0.7 indicates the line that ; is 70 percent of the distance from the starting boundary to the ending boundary. ; The color is constant on lines that are parallel to the boundary lines. ; GdipSetLinePresetBlend(GpLineGradient *brush, GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count) ; Reference: http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx Func _GDIPlus_SetLinePresetBlend($hBrush, $aBlend = 0, $aPositions = 0) Local $iCount, $tBlend, $pBlend, $tPositions, $pPositions, $hStatus, $res ; Red, Yellow, Green, Blue If IsArray($aBlend) = 0 Then Dim $aBlend[4] = [0xFFFF0000, 0xffffff00, 0xFF00FF00, 0xFF0000FF] If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0] $iCount = UBound($aPositions) $tBlend = DllStructCreate("int[" & $iCount & "]") $pBlend = DllStructGetPtr($tBlend) For $iI = 0 To $iCount - 1 DllStructSetData($tBlend, 1, $aBlend[$iI], $iI + 1) Next $tPositions = DllStructCreate("float[" & $iCount & "]") $pPositions = DllStructGetPtr($tPositions) For $iI = 0 To $iCount - 1 DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1) Next $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLinePresetBlend", "hwnd", $hBrush, _ "int", $pBlend, "ptr", $pPositions, "int", $iCount) Return EndFunc ;==>_GDIPlus_SetLinePresetBlend
  22. Amazing thanks for this
  23. I think this one is working as you want !!! Tip is here: Func _GUICtrlButton_SetBackgroundToSystemColor($CtrlhWnd) GUICtrlSetStyle($CtrlhWnd,BitXOR(_GUICtrlGetStyle($CtrlhWnd),0x0000000B));remove colored style EndFunc ;==>_GUICtrlButton_SetBackgroundToSystemColor Func _GUICtrlGetStyle($CtrlhWnd) If Not IsHWnd($CtrlhWnd) Then $CtrlhWnd = GUICtrlGetHandle($CtrlhWnd) Local $a_Style = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $CtrlhWnd, "int", -16);get existing Style Return $a_Style[0] EndFunc ;==>_GUICtrlGetStyle
  24. Here the manifest for RegFreeCOM use of ImageMagickObject.dll Copy/Past this in NotePad <?xml version="1.0" encoding="utf-8"?> <assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <file name="ImageMagickObject.dll"> <typelib tlbid="{9AA0FC6A-63C7-3632-BD6B-7CAF646E51A0}" version="1.0" helpdir="" resourceid="0" flags="" /> <comClass clsid="{5630BE5A-3F5F-4BCA-A511-AD6A6386CAC1}" threadingModel="both" tlbid="{9AA0FC6A-63C7-3632-BD6B-7CAF646E51A0}" progid="ImageMagickObject.MagickImage.1" description="ImageMagick Class" /> </file> </assembly>Then Save it to "your_AutoIt_compiled_script_name.exe.manifest" with "Filetype=All" and "Codage=UTF-8" Or juste Download this Winrared one and rename it to "your_AutoIt_compiled_script_name.exe.manifest" : ImageMagickObject.dll.exe.manifest.rar Enjoy
  25. Here the manifest for use of ImageMagickObject.dll Copy/Past this in NotePad <?xml version="1.0" encoding="utf-8"?> <assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <file name="ImageMagickObject.dll"> <typelib tlbid="{9AA0FC6A-63C7-3632-BD6B-7CAF646E51A0}" version="1.0" helpdir="" resourceid="0" flags="" /> <comClass clsid="{5630BE5A-3F5F-4BCA-A511-AD6A6386CAC1}" threadingModel="both" tlbid="{9AA0FC6A-63C7-3632-BD6B-7CAF646E51A0}" progid="ImageMagickObject.MagickImage.1" description="ImageMagick Class" /> </file> </assembly>Then Save it to "your_AutoIt_compiled_script_name.exe.manifest" with "Filetype=All" and "Codage=UTF-8" Or juste Download this Winrared one and rename it to "your_AutoIt_compiled_script_name.exe.manifest" : ImageMagickObject.dll.exe.manifest.rar Enjoy
×
×
  • Create New...