Leaderboard
Popular Content
Showing content with the highest reputation on 02/05/2023 in all areas
-
For a project of mine i needed Hyperlink creating in GuiRichEdit. These functions and some functions from @UEZ, 1 function from @corgannoand some Global Const from @velted (autoit.de) i put in this UDF. #INCLUDE-ONCE #AUTOIT3WRAPPER_AU3CHECK_PARAMETERS=-Q -D -W 1 -W 2 -W 3 -W 4 #INCLUDE <GUICONSTANTSEX.AU3> ;; #INCLUDE <WINDOWSCONSTANTS.AU3> #INCLUDE <GDIPLUS.AU3> #INCLUDE <GUIRICHEDIT.AU3> #INCLUDE <URLFRIENDLY.AU3> #INCLUDE <WINAPISYS.AU3> #INCLUDE <ARRAY.AU3> #INCLUDE <STRING.AU3> #INCLUDE <DATE.AU3> #INCLUDE <RTF_PRINTER.AU3> ; FEHLENDE KONSTANTEN ;HTTPS://AUTOIT.DE/THREAD/87954-RICHEDIT-VERLINKEN-EINER-DATEI-PER-DRAG-AND-DROP/?POSTID=709978#POST709978 GLOBAL CONST $AURL_ENABLEURL = 1 ; FÜE $EM_AUTOURLDETECT GLOBAL CONST $AURL_ENABLEDRIVELETTERS = 16 ; FÜR $EM_AUTOURLDETECT GLOBAL CONST $ECOOP_OR = 2 ; FÜR $EM_SETOPTIONS GLOBAL CONST $ECO_SELECTIONBAR = 0X01000000 ; FÜR $EM_SETOPTIONS GLOBAL CONST $ES_NOOLEDRAGDROP = 0X08 ; RICHEDIT CONTROLSTYLE GLOBAL CONST $SES_HYPERLINKTOOLTIPS = 8 ; FÜR $EM_SETEDITSTYLE GLOBAL CONST $TAGENDROPFILES = $TAGNMHDR & ";HANDLE HDROP;LONG CP;BOOL FPROTECTED" ; FÜR $EN_DROPFILES ;GLOBAL CONST $TAGDROPFILES = $TAGNMHDR & ";HANDLE HDROP;LONG CP;BOOL FPROTECTED" #REGION FILEINSTALL AND OTHER DIRECTORIES GLOBAL $G_SAPPINIT = @APPDATADIR & '\GUIRICHEDITPLUS\INIT' ;FILEINSTALL FOR EX. ;DUMMY (=SHELLEXUTE-) PRINTER AND HIS SOURCE IF NOT FILEEXISTS($G_SAPPINIT) THEN DIRCREATE($G_SAPPINIT) GLOBAL $SPRNEXE = $G_SAPPINIT & '\RTF_SHELLEXPRINT.EXE ' GLOBAL $G_SAPPWORK = @APPDATADIR & '\GUIRICHEDITPLUS\WORK.TMP' IF NOT FILEEXISTS($G_SAPPWORK) THEN DIRCREATE($G_SAPPWORK) ;SHELLEXECUTE($G_SAPPINIT GLOBAL $G_SAPPICONS = @APPDATADIR & '\GUIRICHEDITPLUS\ICONS' IF NOT FILEEXISTS($G_SAPPICONS) THEN DIRCREATE($G_SAPPICONS) GLOBAL $G_SAPPEXAMPLES = @APPDATADIR & '\GUIRICHEDITPLUS\EXAMPLES' IF NOT FILEEXISTS($G_SAPPEXAMPLES) THEN DIRCREATE($G_SAPPEXAMPLES) #ENDREGION FILEINSTALL AND OTHER DIRECTORIES ;ERÄNZENDE GLOBALEN VARS GLOBAL $G_SSAVEPATH, $G_SVERSNR GLOBAL $G_BSAVEIT = FALSE ;FALSE: NO MASGBOX|TRUE: A MSGBOX REMEMBERS TO SAVE GLOBAL $G_REDEBUG = FALSE ;TRUE CONSOLE OUTPUT FOR DEGBUG REASONS GLOBAL $G_BENCODE = FALSE ;FALSE = SPAVE > '_' |TRUE = ENCODES A STRING TO BE URL-FRIENDLY PRACTICAL ENCODING (ENCODE ONLY WHAT IS NECESSARY) GLOBAL $G_SALLOWEDEXT = 'AU3,TXT,RTF,PDF,ICO,JPG,PNG,MP3,MP4' ;ALLOWED FILE-EXTENSIONS AUTOSHELLEXECUTE ON DBLCLICK ;NEW FUNC'S FUNC _GUICTRLRICHEDIT_INSERTFILELINK($HWND, $SFILE, $SDISPLAY, $BCRLF = FALSE, $BENCODE = $G_BENCODE) ;AUTOR AUTOBERT $SDISPLAY = ' ' & $SDISPLAY & ' ' IF $G_REDEBUG THEN CONSOLEWRITE('INSERTFILELINK: ' & $SFILE & @TAB & $SDISPLAY & @CRLF) IF NOT FILEEXISTS(STRINGREPLACE($SFILE, '_', ' ')) AND _ ;FOR THOSE PEOPLE WHICH USES THIS SIMPLEST ENCODING IN MAIN-SCRIPT (NOBODY? AND ME) NOT FILEEXISTS($SFILE) THEN RETURN SETERROR(1, 1, '') $SFILE = STRINGREPLACE('FILE:\' & $SFILE, '\', '\\\\') IF $BENCODE THEN $SFILE = _URLENCODE($SFILE) ELSE ; $SFILE = STRINGREPLACE($SFILE, '_', ' ') ENDIF LOCAL $STEXT LOCAL CONST $SBINEND = '}}' LOCAL CONST $SBINLINK = '{\FIELD{\*\FLDINST{HYPERLINK "' LOCAL CONST $SBINDISPLAY = '{\FLDRSLT\UL\CF1 ' LOCAL CONST $SBINENDLINE = '\UL0\CF0}}\F0\FS17 ' LOCAL $SLINK = "{\RTF1" & $SBINLINK & $SFILE & '"' & $SBINEND & $SBINDISPLAY & $SDISPLAY & $SBINENDLINE & $SBINEND & $SBINEND IF $BCRLF THEN $SLINK &= '\PAR\PAR}' & @CRLF LOCAL $IRET = _GUICTRLRICHEDIT_INSERTTEXT($HWND, $SLINK) LOCAL $IEXT = @EXTENDED IF $BCRLF THEN _GUICTRLRICHEDIT_INSERTTEXT($HWND, @CRLF) IF $G_REDEBUG THEN CONSOLEWRITE($SLINK & @TAB & $IRET & '|' & $IEXT & @CRLF) IF $IRET THEN RETURN SETERROR($IRET, $IEXT, $IRET) ELSE RETURN SETERROR($IRET, $IEXT, $SLINK) ENDIF ENDFUNC ;==>_GUICTRLRICHEDIT_INSERTFILELINK FUNC _GUICTRLRICHEDIT_INSERTLINK($HWND, $SURL, $SDISPLAY, $BCRLF = FALSE, $BENCODE = $G_BENCODE) #cs CAN BE USED FOR ALL LINKS, IF NOT WORK FOR FILES USE _GUICTRLRICHEDIT_INSERTFILELINK ;AUTOR AUTOBERT #ce $SDISPLAY = ' ' & $SDISPLAY & ' ' IF $G_REDEBUG THEN CONSOLEWRITE('INSERTLINK: ' & $SURL & @TAB & $SDISPLAY & @CRLF) LOCAL CONST $ALINKS[4] = ['HTTP:', 'FTP:', 'WWW.', 'HINT:'] LOCAL $SMODE = '/\' FOR $I = 0 TO 3 IF STRINGINSTR($SURL, $ALINKS[$I]) THEN $SMODE = '\/' NEXT IF $SMODE = '\/' THEN $SURL = STRINGREPLACE($SURL, '\', '/') ELSE $SURL = STRINGREPLACE($SURL, '/', '\') $SURL = STRINGREPLACE('FILE:\' & $SURL, '\', '\\\\') ENDIF IF $BENCODE THEN $SURL = _URLENCODE($SURL) ELSE ; $SURL = STRINGREPLACE($SURL, '_', ' ') ENDIF LOCAL $STEXT LOCAL CONST $SBINEND = '}}' LOCAL CONST $SBINLINK = '{\FIELD{\*\FLDINST{HYPERLINK "' LOCAL CONST $SBINDISPLAY = '{\FLDRSLT\UL\CF1' LOCAL CONST $SBINENDLINE = '\UL0\CF0}}\F0\FS17' LOCAL $SLINK = "{\RTF1" & $SBINLINK & $SURL & '"' & $SBINEND & $SBINDISPLAY & $SDISPLAY & $SBINENDLINE & $SBINEND & $SBINEND IF $BCRLF THEN $SLINK &= '\PAR\PAR}' & @CRLF LOCAL $IRET = _GUICTRLRICHEDIT_INSERTTEXT($HWND, $SLINK) LOCAL $IEXT = @EXTENDED IF $BCRLF THEN _GUICTRLRICHEDIT_INSERTTEXT($HWND, @CRLF) IF $G_REDEBUG THEN CONSOLEWRITE($SURL & @TAB & $IRET & '|' & $IEXT & @CRLF) IF $IRET THEN RETURN SETERROR($IRET, $IEXT, $IRET) ELSE RETURN SETERROR($IRET, $IEXT, $SURL) ENDIF ENDFUNC ;==>_GUICTRLRICHEDIT_INSERTLINK FUNC _GUICTRLRICHEDIT_GETLINK($HWND, $WPARAM, $LPARAM, $BENCODE = $G_BENCODE) ;AUTOR AUTOBERT IF $G_REDEBUG THEN CONSOLEWRITE('GETFILELINK: ' & $WPARAM & '|' & $LPARAM & '|' & $G_BENCODE & @CRLF) LOCAL $TENLINK, $CPMIN, $CPMAX, $SLINK, $SDISPLAY, $ASPLIT $TENLINK = DLLSTRUCTCREATE($TAGENLINK, $LPARAM) $CPMIN = DLLSTRUCTGETDATA($TENLINK, "CPMIN") $CPMAX = DLLSTRUCTGETDATA($TENLINK, "CPMAX") $SLINK = _GUICTRLRICHEDIT_GETTEXTINRANGE($HWND, $CPMIN, $CPMAX) IF $G_REDEBUG THEN CONSOLEWRITE('LINK RAW: :' & $SLINK & @CRLF) $SLINK = STRINGREPLACE($SLINK, 'FILE:', '') IF $BENCODE THEN $SLINK = _URLDECODE($SLINK) ELSE ;$SLINK = STRINGREPLACE($SLINK, '_', ' ') ENDIF $SLINK = _REMOVETRAILINGBACKSLASH('\' & $SLINK) ;CONSOLEWRITE('\ REMOVED: ' & @EXTENDED & @CRLF) IF $G_REDEBUG THEN CONSOLEWRITE('LINK DECODED: ' & $SLINK & @CRLF) IF FILEEXISTS($SLINK) THEN RETURN SETERROR(1, 0, $SLINK) ELSE RETURN SETERROR(0, 9998, $SLINK) ENDIF ;IF $G_REDEBUG THEN ENDFUNC ;==>_GUICTRLRICHEDIT_GETLINK FUNC _REMOVETRAILINGBACKSLASH($STEXT) ;NEEDED FOR _GUICTRLRICHEDIT_GETFILELINK AND MAYBE OTHERWHERE ;AUTOR AUTOBERT LOCAL $IPOS, $IREPLACED DO $IPOS = STRINGINSTR($STEXT, '\') IF $IPOS < 2 THEN $STEXT = STRINGREPLACE($STEXT, '\', '', 1) IF NOT @ERROR THEN $IREPLACED += 1 ENDIF UNTIL $IPOS > 1 RETURN SETERROR(0, $IREPLACED, $STEXT) ENDFUNC ;==>_REMOVETRAILINGBACKSLASH FUNC _GUICTRLRICHEDIT_SAVE($HWND, $SPATH = $G_SSAVEPATH, $BSAVEIT = TRUE) ;AUTOR AUTOBERT IF NOT $BSAVEIT THEN $BSAVEIT = _GUICTRLRICHEDIT_ISMODIFIED($HWND) ;IF _GUICTRLRICHEDIT_GETLINECOUNT($HWND) = 0 THEN RETURN SETERROR(TRUE, 7777, 0) ;NOT A REAL ERROR 7777 = NOTHING TO DO LOCAL $SRET, $IEXT IF NOT $BSAVEIT THEN IF MSGBOX(BITOR($MB_ICONQUESTION, $MB_YESNO), 'SAVE BEFORE EXIT', 'WITHOUT CHANGES ARE BE LOST!', 0, $HWND) = $IDYES THEN $BSAVEIT = TRUE ENDIF IF $BSAVEIT THEN ;INCLUDE ALREADY EXITING FILECHECKING _GUICTRLRICHEDIT_DESELECT($HWND) $SRET = _GUICTRLRICHEDIT_STREAMTOFILE($HWND, $SPATH, FALSE, $SFF_PLAINRTF, 1031) ;, BITOR($FO_OVERWRITE, $FO_CREATEPATH,$FO_ANSI )) $IEXT = @ERROR ELSE $SRET = FALSE $IEXT = 9999 ENDIF ;IF $G_REDEBUG THEN CONSOLEWRITE(@SCRIPTLINENUMBER & @TAB & $G_SSAVEPATH & @TAB & 'SAVED: ' & $SRET & @TAB & $IEXT & @CRLF) RETURN SETERROR($SRET, $IEXT, $SRET) ENDFUNC ;==>_GUICTRLRICHEDIT_SAVE FUNC _GUICTRLRICHEDIT_PRINT($HWND, $SPATH = $G_SSAVEPATH) ;AUTOR AUTOBERT LOCAL $SRET LOCAL $SRTF_NAME = $SPATH ;_GETPRINTFILENAME($SPATH) ;MSGBOX(0, 'PRINT', $SRTF_NAME) _GUICTRLRICHEDIT_DESELECT($HWND) ;IF _GUICTRLRICHEDIT_GETLINECOUNT($HWND) = 0 THEN RETURN SETERROR(TRUE, 7777, 0) ;NOT A REAL ERROR 7777 = NOTHING TO DO $SRET = _GUICTRLRICHEDIT_STREAMTOFILE($HWND, $SPATH, FALSE, $SFF_PLAINRTF, 1031) ;, BITOR($FO_OVERWRITE, $FO_CREATEPATH,$FO_ANSI)) IF $G_REDEBUG THEN CONSOLEWRITE(@SCRIPTLINENUMBER & ': ' & $SRET & '|' & @ERROR & @CRLF) IF @ERROR THEN RETURN SETERROR(@ERROR, @ERROR, $SRTF_NAME) IF NOT FILEEXISTS($SPRNEXE) THEN MSGBOX(BITOR($MB_ICONERROR, $MB_TASKMODAL), 'PRINT', $SPRNEXE & 'NOT FOUND!', 0, $HWND) ;_SHOWBUSY() ;LOCAL $SARCHIV = @SCRIPTDIR & '\ARCHIV' ;CONSOLEWRITE($SARCHIV & @CRLF) LOCAL $SPRINT = STRINGFORMAT('%S "" "" "PRINT" @SW_HIDE', $SRTF_NAME) LOCAL $IPID = RUN($SPRNEXE & $SPRINT, "", @SW_HIDE) IF $G_REDEBUG THEN CONSOLEWRITE('RTF_SHELLEXPRINT.EXE ' & $SPRINT & ' RET: ' & INT($IPID) & '|' & @ERROR & @CRLF) ;#CS WHILE PROCESSEXISTS($IPID) SLEEP(100) WEND RETURN SETERROR($IPID, 8888, '') ;ERROR CODE NOCH "NORMEN" ENDFUNC ;==>_GUICTRLRICHEDIT_PRINT FUNC _GETPRINTFILENAME($STEXT) LOCAL $IPOS = STRINGINSTR($STEXT, '\', 0, -1) LOCAL $SRET = STRINGMID($STEXT, $IPOS + 1) ;$IPOS = STRINGINSTR($SRET, '.', 0, -1) $STEXT = STRINGREPLACE($STEXT, $SRET, '~PRN~' & $SRET) ;MSGBOX(64, '', $STEXT, 20) RETURN SETERROR(0, $IPOS, $STEXT) ENDFUNC ;==>_GETPRINTFILENAME #REGION FILES FROM @UEZ FUNC _GUICTRLRICHEDIT_INSERTBITMAP($HWND, $SFILE, $SFORMATFUNCTIONS = "\", $SBITMAPFUNCTIONS = "\", $IBGCOLOR = DEFAULT) ;CODED BY UEZ BUILD 2016-02-16 # HTTPS://WWW.AUTOITSCRIPT.COM/FORUM/TOPIC/180635-HOW-TO-INSERT-PICTURE-TO-RICH-EDIT/?DO=FINDCOMMENT&COMMENT=1296908 IF NOT FILEEXISTS($SFILE) THEN RETURN SETERROR(0, 0, 1) IF NOT _WINAPI_ISCLASSNAME($HWND, $__G_SRTFCLASSNAME) THEN RETURN SETERROR(0, 0, 2) _GDIPLUS_STARTUP() LOCAL $HIMAGE = _GDIPLUS_IMAGELOADFROMFILE($SFILE) IF @ERROR THEN _GDIPLUS_SHUTDOWN() RETURN SETERROR(0, 0, 3) ENDIF LOCAL CONST $ADIM = _GDIPLUS_IMAGEGETDIMENSION($HIMAGE) LOCAL CONST $HBITMAP = _GDIPLUS_BITMAPCREATEFROMSCAN0($ADIM[0], $ADIM[1]), $HGFX = _GDIPLUS_IMAGEGETGRAPHICSCONTEXT($HBITMAP) IF $IBGCOLOR = DEFAULT THEN $IBGCOLOR = 0XFF000000 + _WINAPI_SWITCHCOLOR(_GUICTRLRICHEDIT_GETBKCOLOR($HWND)) ENDIF _GDIPLUS_GRAPHICSCLEAR($HGFX, $IBGCOLOR) _GDIPLUS_GRAPHICSDRAWIMAGERECT($HGFX, $HIMAGE, 0, 0, $ADIM[0], $ADIM[1]) _GDIPLUS_GRAPHICSDISPOSE($HGFX) LOCAL $BINSTREAM = _GDIPLUS_STREAMIMAGE2BINARYSTRING($HBITMAP, "BMP") IF @ERROR THEN _GDIPLUS_IMAGEDISPOSE($HIMAGE) _GDIPLUS_IMAGEDISPOSE($HBITMAP) _GDIPLUS_SHUTDOWN() RETURN SETERROR(0, 0, 4) ENDIF LOCAL $BINBMP = STRINGMID($BINSTREAM, 31) LOCAL CONST $BINRTF = "{\RTF1\VIEWKIND4" & $SFORMATFUNCTIONS & " {\PICT{\*\PICPROP}" & $SBITMAPFUNCTIONS & "DIBITMAP " & $BINBMP & "}\PAR}" ;CHECK OUT HTTP://WWW.BIBLIOSCAPE.COM/RTF15_SPEC.HTM _GUICTRLRICHEDIT_APPENDTEXT($HWND, $BINRTF) $BINSTREAM = 0 $BINBMP = 0 _GDIPLUS_IMAGEDISPOSE($HIMAGE) _GDIPLUS_IMAGEDISPOSE($HBITMAP) _GDIPLUS_SHUTDOWN() RETURN 1 ENDFUNC ;==>_GUICTRLRICHEDIT_INSERTBITMAP FUNC _GDIPLUS_STREAMIMAGE2BINARYSTRING($HBITMAP, $SFORMAT = "JPG", $IQUALITY = 80, $BSAVE = FALSE, $SFILENAME = @SCRIPTDIR & "\CONVERTED.JPG") ;CODED BY UEZ 2013 BUILD 2014-01-25 (BASED ON THE CODE BY ANDREIK) LOCAL $SIMGCLSID, $TGUID, $TPARAMS, $TDATA SWITCH $SFORMAT CASE "JPG" $SIMGCLSID = _GDIPLUS_ENCODERSGETCLSID($SFORMAT) $TGUID = _WINAPI_GUIDFROMSTRING($SIMGCLSID) $TDATA = DLLSTRUCTCREATE("INT QUALITY") DLLSTRUCTSETDATA($TDATA, "QUALITY", $IQUALITY) ;QUALITY 0-100 LOCAL $PDATA = DLLSTRUCTGETPTR($TDATA) $TPARAMS = _GDIPLUS_PARAMINIT(1) _GDIPLUS_PARAMADD($TPARAMS, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $PDATA) CASE "PNG", "BMP", "GIF", "TIF" $SIMGCLSID = _GDIPLUS_ENCODERSGETCLSID($SFORMAT) $TGUID = _WINAPI_GUIDFROMSTRING($SIMGCLSID) CASE ELSE RETURN SETERROR(1, 0, 0) ENDSWITCH LOCAL $HSTREAM = _WINAPI_CREATESTREAMONHGLOBAL() ;HTTP://MSDN.MICROSOFT.COM/EN-US/LIBRARY/MS864401.ASPX IF @ERROR THEN RETURN SETERROR(2, 0, 0) _GDIPLUS_IMAGESAVETOSTREAM($HBITMAP, $HSTREAM, DLLSTRUCTGETPTR($TGUID), DLLSTRUCTGETPTR($TPARAMS)) IF @ERROR THEN RETURN SETERROR(3, 0, 0) LOCAL $HMEMORY = _WINAPI_GETHGLOBALFROMSTREAM($HSTREAM) ;HTTP://MSDN.MICROSOFT.COM/EN-US/LIBRARY/AA911736.ASPX IF @ERROR THEN RETURN SETERROR(4, 0, 0) LOCAL $IMEMSIZE = _MEMGLOBALSIZE($HMEMORY) IF NOT $IMEMSIZE THEN RETURN SETERROR(5, 0, 0) LOCAL $PMEM = _MEMGLOBALLOCK($HMEMORY) $TDATA = DLLSTRUCTCREATE("BYTE[" & $IMEMSIZE & "]", $PMEM) LOCAL $BDATA = DLLSTRUCTGETDATA($TDATA, 1) _WINAPI_RELEASESTREAM($HSTREAM) ;HTTP://MSDN.MICROSOFT.COM/EN-US/LIBRARY/WINDOWS/DESKTOP/MS221473(V=VS.85).ASPX _MEMGLOBALFREE($HMEMORY) IF $BSAVE THEN LOCAL $HFILE = FILEOPEN($SFILENAME, 18) IF @ERROR THEN RETURN SETERROR(6, 0, $BDATA) FILEWRITE($HFILE, $BDATA) FILECLOSE($HFILE) ENDIF RETURN $BDATA ENDFUNC ;==>_GDIPLUS_STREAMIMAGE2BINARYSTRING #ENDREGION FILES FROM @UEZ #REGION FILES FROM CORGANO FUNC _GUICTRLRICHEDIT_APPENDTEXTEX($RICHEDIT, $TEXT, $FONT = "ARIAL", $COLOR = "000000", $SIZE = 12, $BOLD = 0, $ITALIC = 0, $STRIKE = 0, $UNDERLINE = 0) LOCAL $COMMAND = "{\RTF1\ANSI" LOCAL $R, $G, $B, $UL[9] = ["8", '\UL', '\ULDB', '\ULTH', '\ULW', '\ULWAVE', '\ULD', '\ULDASH', '\ULDASHD'] $TEXT = STRINGREPLACE($TEXT, '\', '\\') ;EINGEFÜGT AUTOBERT IF $FONT <> "" THEN $COMMAND &= "{\FONTTBL\F0\F" & $FONT & ";}" IF $COLOR <> "" THEN IF STRINGLEN($COLOR) <> 6 AND STRINGLEN($COLOR) = 8 THEN RETURN SETERROR(1) $B = DEC(STRINGRIGHT($COLOR, 2)) IF @ERROR THEN SETERROR(1, 1) $COLOR = STRINGTRIMRIGHT($COLOR, 2) $G = DEC(STRINGRIGHT($COLOR, 2)) IF @ERROR THEN SETERROR(1, 2) $COLOR = STRINGTRIMRIGHT($COLOR, 2) $R = DEC(STRINGRIGHT($COLOR, 2)) IF @ERROR THEN SETERROR(1, 3) IF $R + $B + $G > 0 THEN $COMMAND &= "{\COLORTBL;\RED" & $R & "\GREEN" & $G & "\BLUE" & $B & ";}\CF1" ENDIF ENDIF IF $SIZE THEN $COMMAND &= "\FS" & ROUND($SIZE * 2) & " " IF $STRIKE THEN $COMMAND &= "\STRIKE " IF $ITALIC THEN $COMMAND &= "\I " IF $BOLD THEN $COMMAND &= "\B " IF $UNDERLINE > 0 AND $UNDERLINE < 9 THEN $COMMAND &= $UL[$UNDERLINE] & " " RETURN _GUICTRLRICHEDIT_APPENDTEXT($RICHEDIT, $COMMAND & STRINGREPLACE($TEXT, @CRLF, "\LINE") & "}") ENDFUNC ;==>_GUICTRLRICHEDIT_APPENDTEXTEX FUNC _GUICTRLRICHEDIT_INSERTTEXTEX($RICHEDIT, $TEXT, $FONT = "ARIAL", $COLOR = "000000", $SIZE = 12, $BOLD = 0, $ITALIC = 0, $STRIKE = 0, $UNDERLINE = 0) #AUTOR COPY&PASTE + SEARCH&REPLACE FROM _GUICTRLRICHEDIT_APPENDTEXT LOCAL $COMMAND = "{\RTF1\ANSI" LOCAL $R, $G, $B, $UL[9] = ["8", '\UL', '\ULDB', '\ULTH', '\ULW', '\ULWAVE', '\ULD', '\ULDASH', '\ULDASHD'] $TEXT = STRINGREPLACE($TEXT, '\', '\\') ;EINGEFÜGT AUTOBERT IF $FONT <> "" THEN $COMMAND &= "{\FONTTBL\F0\F" & $FONT & ";}" IF $COLOR <> "" THEN IF STRINGLEN($COLOR) <> 6 AND STRINGLEN($COLOR) = 8 THEN RETURN SETERROR(1) $B = DEC(STRINGRIGHT($COLOR, 2)) IF @ERROR THEN SETERROR(1, 1) $COLOR = STRINGTRIMRIGHT($COLOR, 2) $G = DEC(STRINGRIGHT($COLOR, 2)) IF @ERROR THEN SETERROR(1, 2) $COLOR = STRINGTRIMRIGHT($COLOR, 2) $R = DEC(STRINGRIGHT($COLOR, 2)) IF @ERROR THEN SETERROR(1, 3) IF $R + $B + $G > 0 THEN $COMMAND &= "{\COLORTBL;\RED" & $R & "\GREEN" & $G & "\BLUE" & $B & ";}\CF1" ENDIF ENDIF IF $SIZE THEN $COMMAND &= "\FS" & ROUND($SIZE * 2) & " " IF $STRIKE THEN $COMMAND &= "\STRIKE " IF $ITALIC THEN $COMMAND &= "\I " IF $BOLD THEN $COMMAND &= "\B " IF $UNDERLINE > 0 AND $UNDERLINE < 9 THEN $COMMAND &= $UL[$UNDERLINE] & " " RETURN _GUICTRLRICHEDIT_INSERTTEXT($RICHEDIT, $COMMAND & STRINGREPLACE($TEXT, @CRLF, "\LINE") & "}") ENDFUNC ;==>_GUICTRLRICHEDIT_INSERTTEXTEX #ENDREGION FILES FROM CORGANO The script where these funcs are used and tested : #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=..\..\..\Desktop\DirListSDI.exe #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 #AutoIt3Wrapper_Run_Tidy=y #Au3Stripper_Parameters=/mo #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> ;; #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiRichEditPlus_433.au3> #include <WinAPISys.au3> #include <WinAPIDlg.au3> #include <Array.au3> #include <String.au3> #include <GuiSlider.au3> #include <File.au3> #include <ScreenCapture.au3> #Region Fileinstall Global $iError = FileInstall("C:\File.Installer\RTF_SHellExPrint.exe", $g_sAppInit & "\RTF_SHellExPrint.exe", 1) $iError = FileInstall("C:\File.Installer\RTF_SHellExPrint.au3", $g_sAppInit & "\RTF_SHellExPrint.au3", 1) #EndRegion Fileinstall #Region Assign global vars (if needed) $g_bEncode = False ;(False: no encoding, True Filename encoding = on $g_REDebug = False Global $g_ToPrint = False Global $iBold ConsoleWrite($g_bEncode & @CRLF) #EndRegion Assign global vars (if needed) ;$g_sSavePath = $g_sAppWork & '\Directory Listing.rtf' ;StringReplace($g_sSavePath, @ScriptDir, 'x:') ;Test for errorhandling throws erros ######################################################## If FileExists($g_sSavePath) Then FileDelete($g_sSavePath) ######################################################## Global Const $g_aToLower = StringSplit('notneeded,', ',', 3) ;substrings => lowercase Global $sTitle = 'GuiRichEditPlus_Example ' & $g_sVersNr, $oldText, $newText Global $hGUI = GUICreate($sTitle, 600, 400, -1, 100) Global $g_aFileList, $g_Busy, $g_inserted, $g_failed Global $g_hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 10, 10, 580, 380, BitOR($ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) ;_GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True) ;If FileExists($g_sSavePath) Then _GUICtrlRichEdit_StreamFromFile($g_hRichEdit, $g_sSavePath) ; In this example allway start empty ;_WinAPI_DragAcceptFiles($g_hRichEdit) ;not wanted in this example ;_GUICtrlRichEdit_SetEventMask($g_hRichEdit, BitOR($ENM_DROPFILES, $ENM_LINK)) ;not wanted in this example _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK) ;not wanted in this example _SendMessage($g_hRichEdit, $EM_SETEDITSTYLE, $SES_HYPERLINKTOOLTIPS, $SES_HYPERLINKTOOLTIPS) ;_SendMessage($g_hRichEdit, $EM_SETZOOM, 1000, 500) ; erwarte 200% GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_SIZE, "WM_SIZE") Global $aParts[4] = [32, 90, 80, -1] Global $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts) Global $idAnim = GUICtrlCreateIcon('Shell32.dll', -24, 0, 0) Global $hAnim = GUICtrlGetHandle($idAnim) _GUICtrlStatusBar_EmbedControl($g_hStatus, 0, $hAnim) _GUICtrlStatusBar_SetMinHeight($g_hStatus, 38) _GUICtrlStatusBar_SetParts($g_hStatus, $aParts) _GUICtrlStatusBar_SetText($g_hStatus, 'Debug: ' & $g_REDebug, 1) _GUICtrlStatusBar_EmbedControl($g_hStatus, 0, $hAnim) ;ConsoleWrite('Icons' & _GUICtrlStatusBar_SetIcon($g_hStatus, 2, 23, "SyncCenter.dll")) WinMove($hGUI, '', 0, 0, @DesktopWidth, @DesktopHeight) GUISetState() Global $sListdir Global Const $sInitDir = @ProgramFilesDir Global $hBrowseLiatProc = DllCallbackRegister('_BrowseLiatProc', 'int', 'hwnd;uint;lparam;ptr') Global $pBrowseLiatProc = DllCallbackGetPtr($hBrowseLiatProc) Global $pText = _WinAPI_CreateString($sInitDir) Do $sListdir = _WinAPI_BrowseForFolderDlg(_WinAPI_PathStripToRoot($sInitDir), 'Select a folder from the list below.', BitOR($BIF_RETURNONLYFSDIRS, $BIF_EDITBOX, $BIF_VALIDATE), $pBrowseLiatProc, $pText) ConsoleWrite($sListdir & @CRLF) Until Not @error _WinAPI_FreeMemory($pText) If $sListdir Then ConsoleWrite('--------------------------------------------------' & @CRLF) ConsoleWrite($sListdir & @CRLF) EndIf ;$aChar = StringSplit($sListdir, '', 3) ;_ArrayDisplay($aChar) DllCallbackFree($hBrowseLiatProc) $g_sSavePath = $g_sAppWork & '\Directory Listing ' & StringReplace(StringTrimLeft($sListdir, 3), '\', ' ') & '.rtf' ;StringReplace($g_sSavePath, @ScriptDir, 'x:') ;Test for errorhandling throws erros ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $g_sSavePath = ' & $g_sSavePath & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console _GUICtrlStatusBar_SetText($g_hStatus, '_FileListToArrayRec ', 1) $g_Busy = True AdlibRegister('_ShowBusy', 20) $g_aFileList = _FileListToArrayRec($sListdir, '*', $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) ;If Not IsArray($g_aFileList) Then Exit MsgBox _GUICtrlRichEdit_InsertTextEx($g_hRichEdit, "Install Directory Structure" & @CRLF & @CRLF, "Arial", "FF1234", 20) _GUICtrlRichEdit_InsertTextEx($g_hRichEdit, "" & @CRLF & @CRLF, "Arial", "000000", 1) _GUICtrlRichEdit_SetFont($g_hRichEdit, 'Arial', 1) ;_GUICtrlRichEdit_StreamToFile($g_hRichEdit, $g_sSavePath) _GUICtrlRichEdit_SetModified($g_hRichEdit, False) _GUICtrlRichEdit_insertLink($g_hRichEdit, 'hint://Info: LastSaved: ' & _NowCalc(), 'LS') _ArrayInsert($g_aFileList, 1, $sListdir) $g_aFileList[0] += 1 ;_ArrayDisplay($g_aFileList) _ArrayColInsert($g_aFileList, 1) _GUICtrlStatusBar_SetText($g_hStatus, 'RichEdit_insertLink(s)', 1) ; $g_Busy = True For $i = 1 To $g_aFileList[0][0] Switch GUIGetMsg() Case $Gui_EVENT_CLOSE If MsgBox(BitOR($MB_ICONQUESTION, $MB_YESNO), 'User break ', 'Realy end dir listing ? ' & @CRLF _ & "It can't continued" & @CRLF & ' You have To restart it!') = $IDYES Then _GUICtrlRichEdit_AppendTextEx($g_hRichEdit, "User break: " & @UserName, "Arial", "FA4321", 24, $iBold) ExitLoop EndIf Case Else $g_aFileList[$i][1] = _GetDisplayName($g_aFileList[$i][0]) Switch @extended Case 0 #cs _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, '009999') _GUICtrlRichEdit_SetCharAttributes($g_hRichEdit, '+bo') _GUICtrlRichEdit_InsertText($g_hRichEdit, StringReplace($g_aFileList[$i][0], $g_aFileList[$i][1], '')) #ce $iBold = 1 _GUICtrlRichEdit_AppendTextEx($g_hRichEdit, StringReplace($g_aFileList[$i][0], $g_aFileList[$i][1], ''), "Arial", "FA4321", 14, $iBold) $iBold = 0 _GUICtrlRichEdit_AppendTextEx($g_hRichEdit, ' ', "", "881111", 10, $iBold) ContinueCase Case Else If _GUICtrlRichEdit_insertLink($g_hRichEdit, $g_aFileList[$i][0], $g_aFileList[$i][1], True) Then $g_inserted += 1 Else $g_failed += 1 EndIf $g_inserted &= ' ' & _FormatedStatPer($i, $g_aFileList[0][0]) $g_failed &= ' ' & _FormatedStatPer($i, $g_aFileList[0][0]) _GUICtrlStatusBar_SetText($g_hStatus, $g_inserted, 1) _GUICtrlStatusBar_SetText($g_hStatus, $g_failed, 2) EndSwitch EndSwitch Next _GUICtrlRichEdit_SetCharAttributes($g_hRichEdit, '+hi') _GUICtrlRichEdit_insertLink($g_hRichEdit, 'hint://' & $g_inserted & ' Links succesfully inserted.| Links total: ' & $g_aFileList[0][0], 'Status', True) For $i = 1 To 5 Do Until GUIGetMsg() = 0 Next $g_Busy = False ;#ce Global $nMsg While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Deselect($g_hRichEdit) If $nMsg = _GUICtrlRichEdit_GetLineLength($g_hRichEdit, 1) = 0 Then $g_ToPrint = _GUICtrlRichEdit_Save($g_hRichEdit, $g_sSavePath, True) ;ConsoleWrite($nMsg & '|' & @error & '|' & @extended & @CRLF) _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes ;GUIDelete() Else $g_ToPrint = False EndIf If $g_ToPrint Then _PrintIt() Exit #cs Case $idPrint If _GUICtrlRichEdit_IsModified($g_hRichEdit) Then _GUICtrlRichEdit_StreamToFile($g_hRichEdit, $g_sSavePath) _GUICtrlRichEdit_SetModified($g_hRichEdit, False) EndIf _PrintIt($g_sSavePath) #ce ;Case $idZoom ;_Zoom() EndSwitch WEnd Func _FormatedStatPer($iDone, $iAll) Return (Ceiling($iDone * 100 / $iAll) & '%') EndFunc ;==>_FormatedStatPer ;#cs ;_GUICtrlRichEdit_ReplaceFieldValue($g_sSavePath, 'LastSaved: ', '"}', _NowCalc()) Func _Zoom() #cs Local $ipos = GUICtrlRead($idZoom) Switch $ipos + 50 Case 0 To 49 ConsoleWrite('<100%' & @CRLF) Case 50 ConsoleWrite('100%' & @CRLF) Case Else ConsoleWrite('>100%' & @CRLF) EndSwitch #ce EndFunc ;==>_Zoom Func _PrintIt($sPath = $g_sSavePath) If MsgBox(BitOR($MB_ICONQUESTION, $MB_YESNO), 'Print', $sPath) = $IDNO Then Return SetError(False, 88, '') $g_Busy = True ConsoleWrite($g_sAppInit & @CRLF) Local $sPRNexe = $g_sAppInit & '\RTF_SHellExPrint.exe ' If Not FileExists($sPRNexe) Then Return MsgBox(BitOR($MB_ICONERROR, $MB_TASKMODAL), 'Print', $sPRNexe & 'not found!', 0, $hGUI) _ShowBusy() ;Local $sArchiv = @ScriptDir & '\Archiv' ;ConsoleWrite($sArchiv & @CRLF) Local $sPrint = StringFormat('%s "" "" "Print" @SW_HIDE', StringReplace($sPath, ' ', '%20')) Local $iPid = Run($sPRNexe & $sPrint, "", @SW_HIDE) ConsoleWrite('RTF_SHellExPrint.exe ' & $sPrint & ' Ret: ' & Int($iPid) & '|' & @error & @CRLF) ;#cs While ProcessExists($iPid) Sleep(100) WEnd ;#ce $g_Busy = False #cs ; here Setting default margin - all = 1 centimeters ; you can set your own margins _RTF_SetMargins() ; here setting number of copies - default is 1 _RTF_SetNumberOfCopies(1) ; here getting data to Print Local $vRTF_Stream = _GUICtrlRichEdit_StreamToVar($g_hRichEdit) ; and here Printing _RTF_PrintFile($vRTF_Stream, Default, True, True) #ce ; here Setting default margin - all = 1 centimeters EndFunc ;==>_PrintIt Func _GetDisplayName($sText) Local $ipos = StringInStr($sText, '\', 0, -1) Local $sRet = _StringProper(StringMid($sText, $ipos + 1)) $sRet = _CheckToLower($sRet) $ipos = StringInStr($sRet, '.', 0, -1) Return SetError(0, $ipos, $sRet) EndFunc ;==>_GetDisplayName Func _CheckToLower($sText) For $i = 0 To UBound($g_aToLower) - 1 If StringInStr($sText, $g_aToLower[$i]) Then For $j = 1 To 4 Switch $j Case 1 $sText = StringReplace($sText, '-' & $g_aToLower[$i] & '-', ' ' & $g_aToLower[$i] & ' ') If @extended Then ContinueLoop Case 2 $sText = StringReplace($sText, $g_aToLower[$i] & '-', $g_aToLower[$i] & ' ') If @extended Then ContinueLoop Case 3 If @extended Then ContinueLoop $sText = StringReplace($sText, '-' & $g_aToLower[$i], ' ' & $g_aToLower[$i]) Case 4 $sText = StringReplace($sText, $g_aToLower[$i], $g_aToLower[$i]) EndSwitch Next ;ConsoleWrite($g_aToLower[$i] & @TAB) EndIf Next ;ConsoleWrite($sText & @CRLF) Return $sText EndFunc ;==>_CheckToLower Func _ShowBusy() Local Static $iBusy Local $sBusy ;ConsoleWrite($iBusy & @TAB) AdlibUnRegister('_ShowBusy') $iBusy += 1 If $iBusy < 23 Then $iBusy = 23 If $iBusy > 30 Then $iBusy = 23 ;$sBusy = $g_sAppIcons & '\SyncCenter_' & $iBusy & '.ico' ;ConsoleWrite($sBusy & @CRLF) GUICtrlSetImage($idAnim, 'SyncCenter.dll', ($iBusy + 1) * -1) ;to show Busy Icons If $g_Busy Then AdlibRegister('_ShowBusy', 20) Else ; WinSetTitle($hGUI, "", $sTitel) & $sProgVer & $sDLLName) GUICtrlSetImage($idAnim, 'SyncCenter', $iBusy * -1 + 1) EndIf EndFunc ;==>_ShowBusy Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR, $aFileList, $tDropFiles, $hDrop, $tEnLink, $cpMin, $cpMax, $tMsgFilter, $ipos, $sLink, $sDisplay, $aSplit, $iInserted, $sRet ; Local $hWndFrom, $iCode, $tNMHDR, $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hRichEdit Switch $iCode Case $EN_DROPFILES ;Droped File Names extrahieren $tDropFiles = DllStructCreate($tagENDROPFILES, $lParam) $hDrop = DllStructGetData($tDropFiles, "hDrop") $aFileList = _WinAPI_DragQueryFileEx($hDrop, 0) For $i = 1 To $aFileList[0] $sLink = $aFileList[$i] $aSplit = StringSplit($sLink, '\', 1) $sDisplay = $aSplit[$aSplit[0]] $sRet = _GUICtrlRichEdit_insertLink($g_hRichEdit, $sLink, $sDisplay, True) If $sRet = True Then $iInserted += 1 Else ConsoleWrite($i & ': ' & $sRet & 'Failed') EndIf Next _GUICtrlRichEdit_SetSel($g_hRichEdit, -1, -1) ;_GUICtrlRichEdit_SetSel($hWndFrom, $tDropFiles.cp, $tDropFiles.cp) If Not $g_REDebug Then ConsoleWrite($iInserted & ' FileLinks inserted' & @CRLF) Return 1 Case $iCode = $EN_LINK ;ConsoleWrite('$EN_LINK' & @CRLF) $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam) If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONDBLCLK Then $tEnLink = DllStructCreate($tagENLINK, $lParam) $cpMin = DllStructGetData($tEnLink, "cpMin") $cpMax = DllStructGetData($tEnLink, "cpMax") $sLink = _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $cpMin + 6, $cpMax) ConsoleWrite($sLink & ': ' & @error & '|' & @extended & @CRLF) _GetDisplayName($sLink) Switch @extended Case 0 ;quickckeck for Directory ShellExecute($sLink) ;opens a explorer link Case Else If FileExists($sLink) Then If StringInStr($g_sAllowedExt, StringRight($sLink, 3)) Then ShellExecute($sLink) Else MsgBox(64, 'Link:', $sLink) EndIf Else ;it must be a hint or file is delete MsgBox(64, 'Hint:', StringReplace($sLink, '/', '')) EndIf EndSwitch EndIf EndSwitch #cs Case $hZoom Switch $iCode Case $NM_RELEASEDCAPTURE ; The control is releasing mouse capture _WM_NOTIFY_DebugEvent("$NM_RELEASEDCAPTURE", $tagNMHDR, $lParam, "hWndFrom,IDFrom") ; No return value EndSwitch #ce EndSwitch Return $Gui_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_SIZE($hWndGUI, $MsgID, $wParam, $lParam) Local $iWidth = _WinAPI_LoWord($lParam) Local $iHeight = _WinAPI_HiWord($lParam) ; _WinAPI_MoveWindow($g_hRichEdit, 0, 0, $iWidth, $iHeight) _WinAPI_MoveWindow($g_hRichEdit, 4, 4, $iWidth - 8, $iHeight - 44) _WinAPI_MoveWindow($g_hStatus, 2, 2, $iWidth - 4, $iHeight - 38) ;Return 1 Return 0 ; "an application should return zero if it processes this message" (MSDN) EndFunc ;==>WM_SIZE Func _BrowseProc($hWnd, $iMsg, $wParam, $lParam) Local $sPath, $hSearch Switch $iMsg Case $BFFM_INITIALIZED _WinAPI_SetWindowText($hWnd, 'MyTitle') _SendMessage($hWnd, $BFFM_SETSELECTIONW, 1, $lParam) Case $BFFM_SELCHANGED $sPath = _WinAPI_ShellGetPathFromIDList($wParam) $hSearch = FileFindFirstFile($sPath & '\*') If Not @error Then ConsoleWrite($sPath & @CRLF) EndIf Case $BFFM_VALIDATEFAILED MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', _WinAPI_GetString($wParam) & ' is invalid.', 0, $hWnd) Return 1 EndSwitch Return $hSearch EndFunc ;==>_BrowseProc maybe a mvp will proof and polish the code and integrate them in the GuiRichedit.UDF. What's new: small fixes/changes in GuiRichEditPlus_433.au3using Example:DirListSDI.au3you can select the directory which should be listed. This example will be extended to a MDI. Realy new: RTF_SHellExPrint.au3please complile and copy the exe to ..\AppData\Roaming\GuiRichEditPlus\Init. ) I suggest: using _GUICtrlRichEdit_insertLink for all kind of links which should work with files also, if not use _GUICtrlRichEdit_insertFileLink. Handle all kind of Links in theWM_Notify (like i did in _GuiRichEditPlus_Demo. 3. a small test to insert hint's is tested in Case $Gui_EVENT_CLOSE _GUICtrlRichEdit_insertLink($g_hRichEdit, 'hint://Info: GuiRichEditPlus(_3).au3 autor autobert', 'Version') Use the added Global $g_bEncode = False ;False = no encoding |True = Encodes a string to be URL-friendly Practical Encoding (Encode only what is necessary) in your Mainscript. #Region ReAssign global vars (if needed) $g_sSavePath = @ScriptDir & '\Rezeptsammlung.rtf' $g_bEncode = True ;(True Filename encoding = on) $g_REDebug = False ConsoleWrite($g_bEncode & @CRLF) #EndRegion Assign global vars (if needed) A real integrated the Statusbar is a future plan. UrlFriendly.au3 GuiRichEditPlus.au3 GuiRichEditPlus_2.au3 GuiRichEditPlus_3.au3 GuiRichEditPlus_4.au3 GuiRichEditPlus_42.au3 GuiRichEditPlus_Demo.au34 points
-
Runtimes and Speed Comparisons
argumentum reacted to LarsJ for a topic
Virtual TreeViews Development of the Runtime measurement code is largely carried out in parallel with development of the second part of Virtual TreeViews. Especially for measuring the gain using compiled VB.NET code. The following example is used to demonstrate new functionality of the Runtime measurement code: 1) Example.au3: ; Copied from TVSourceCreatePlainExConstCount() output ; $iLevels, $iItems0, $iMultiplier, $iCount = 3, 90, 10, 10701 Example( 3, 90, 10, 10701 ) ; 10,701 treeview items Func Example( $iLevels, $iItems0, $iMultiplier, $iCount ) Local $sSources = ".\Sources\" & $iLevels & " levels, " & $iCount & " items, " Local $sPlain = $sSources & "Plain, debug.txt" ; Plain source Local $sVirtual = $sSources & "Virtual, debug.txt" ; Virtual source TVSourceCreatePlainExConst( $iLevels, $iItems0, $iMultiplier, $sPlain ) ; Create plain source TVSourceDisplayPlain( $sPlain ) ; Display plain TreeView TVSourceConvertPlainToVirtual( $iLevels, $sPlain, $sVirtual ) ; Convert to virtual source TVSourceDisplayVirtual( $sVirtual ) ; Display virtual TreeView FileDelete( $sPlain ) ; Delete plain source FileDelete( $sVirtual ) ; Delete virtual source EndFunc ; Copied from TVSourceCreatePlainExConstCount() output ; $iLevels, $iItems0, $iMultiplier, $iCount = 3, 90, 10, 10701 ExampleVb( 3, 90, 10, 10701 ) ; 10,701 treeview items Func ExampleVb( $iLevels, $iItems0, $iMultiplier, $iCount ) Local $sSources = ".\Sources\" & $iLevels & " levels, " & $iCount & " items, " Local $sPlain = $sSources & "Plain, debug.txt" ; Plain source Local $sVirtual = $sSources & "Virtual, debug.txt" ; Virtual source TVSourceCreatePlainExConstVb( $iLevels, $iItems0, $iMultiplier, $sPlain ) ; Create plain source TVSourceDisplayPlain( $sPlain ) ; Display plain TreeView TVSourceConvertPlainToVirtualVb( $iLevels, $sPlain, $sVirtual ) ; Convert to virtual source TVSourceDisplayVirtual( $sVirtual ) ; Display virtual TreeView FileDelete( $sPlain ) ; Delete plain source FileDelete( $sVirtual ) ; Delete virtual source EndFunc In the Runtime examples, time measurement of these 4 tasks is carried out: Create a constant source file for a plain treeview Display the corresponding semi-virtual treeview Convert the source file to a virtual source file Display the corresponding virtual treeview Measurements are performed on an increasing number of treeview items. The features demonstrated below are: Using the Runtime data section Visual validation of Runtime data The GUI must be closed after validation Set individual max time $aTimes[1][2] = 10000 Local variables for the current Runtime function Creation time measurement of GUI with blocking main loop The idea is to create the GUI in a new process with Run() Additional initialization code for the current function Necessary for time measurement of compiled VB.NET code Divide task into sub-tasks with individual time measurements Implementing sub-task time measurement inside a VB.NET method Sub-task time measurement during a GUI creation process Uses a ROT object to pass data back to the Runtime script Time limits in relation to interdependent measurements All examples can be found in Examples\Virtual TreeView\. Run the examples with F5 in SciTE. Runtime data sectionThe Runtime data section contains additional data that is used in the Runtime functions: ; --- Additional data for the current Runtimes --- ; Copied from TVSourceCreatePlainExConstCount() output ; $iLevels, $iItems0, $iMultiplier, $iCount = 3, 90, 10, 10701 ; $iLevels, $iItems0, $iMultiplier, $iCount = 5, 24, 4, 20346 ; $iLevels, $iItems0, $iMultiplier, $iCount = 5, 30, 5, 52134 ; $iLevels, $iItems0, $iMultiplier, $iCount = 4, 80, 10, 112472 ; $iLevels, $iItems0, $iMultiplier, $iCount = 5, 49, 7, 259399 ; $iLevels, $iItems0, $iMultiplier, $iCount = 5, 64, 8, 533240 ; $iLevels, $iItems0, $iMultiplier, $iCount = 6, 50, 5, 758890 ; $iLevels, $iItems0, $iMultiplier, $iCount = 5, 81, 9, 1012329 ; $iLevels, $iItems0, $iMultiplier, $iCount = 6, 42, 7, 2399622 ; $iLevels, $iItems0, $iMultiplier, $iCount = 6, 56, 8, 5511625 ;Local $aRuntime_Data = 0 Local $aRuntime_Data = [ _ [ 3, 90, 10 ], _ [ 5, 24, 4 ], _ [ 5, 30, 5 ], _ [ 4, 80, 10 ], _ [ 5, 49, 7 ], _ [ 5, 64, 8 ], _ [ 6, 50, 5 ], _ [ 5, 81, 9 ], _ [ 6, 42, 7 ], _ [ 6, 56, 8 ] ] ; ------------------------------------------------ 2) First test.au32) First test.au3 contains 2 Runtime functions that perform these Runtime tests: In Runtimes1() with pure AutoIt code: TVSourceCreatePlainExConst() TVSourceDisplayPlain() TVSourceConvertPlainToVirtual() TVSourceDisplayVirtual() In Runtimes2() also with VB.NET code: TVSourceCreatePlainExConstVb() TVSourceDisplayPlain() TVSourceConvertPlainToVirtualVb() TVSourceDisplayVirtual() Because Runtimes2() executes VB.NET code, additional initializations are needed to load the VB.NET code: ; --- Additional initializations for the current function --- If Not TVSourceCreateVbNetCodeObject( "..\..\Includes\Virtual TreeView\TVSourceFile.vb" ) Then ConsoleWrite( "TVSourceCreateVbNetCodeObject: @error = " & @error & @CRLF ) Exit 1 EndIf Note that the settings in 2) First test.au3 are defined to only execute Runtimes2(). These settings are used to develop and test time measurement of the VB.NET code. 3) First test - Cycle.au3 executes both Runtime functions as 32 and 64 bit code and generates a report with 4 columns. TVSourceDisplayPlain()TVSourceDisplayPlain() in both Runtime functions displays a plain source file as a semi-virtual treeview in a GUI. Because the GUI contains a blocking main loop, TVSourceDisplayPlain() is executed in a new process with the Run() command. The time measurement is coded this way: $hTimer = TimerInit() Run( $sAutoItExePath & ( $iBit = 32 ? "AutoIt3.exe" : "AutoIt3_x64.exe" ) & " /AutoIt3ExecuteScript " & _ """" & $sScriptPathPlain & """" & " " & """" & $sSources & "Plain, debug.txt" & """" & " " & 1 ) WinClose( WinWaitActive( "Display Plain TreeView From Source File" ) ) $aTimes[$iTest][1] = TimerDiff( $hTimer ) You can briefly see the GUI appear and close down again. $sScriptPathPlain is the name of the script to run, here TVSourceDisplayPlain.au3: #include "..\..\Includes\Virtual TreeView\TVSourceFile.au3" If UBound( $CmdLine ) > 1 Then TVSourceDisplayPlain( $CmdLine[1], $CmdLine[2]+0 ) TVSourceDisplayPlain() isn't that interesting compared to true virtual treeviews. It can only handle semi-virtual treeviews, where only the item texts are virtual. The entire treeview structure must be created before the treeview can be displayed in the GUI. This can be very time consuming for large source files. In both Runtime functions, the time taken to create this GUI is limited to 10 seconds. All other time measurements are limited to 30 seconds. 4) Divided tasks.au3The functions TVSourceConvertPlainToVirtual(), TVSourceConvertPlainToVirtualVb() and TVSourceDisplayVirtual() are divided into a few smaller and clearly separated sub-tasks. For the first two functions, it's about Read the plain source file from the disk Convert plain source to virtual source file Save the virtual source file to the disk For the last function, it's about Read the virtual source file from the disk Display the source file in a treeview in a GUI Because these are clearly separated sub-tasks, it provides more information with separate time measurements of the different sub-tasks. In 4) Divided tasks.au3, separate time measurements are performed for the sub-tasks. In the sections below, the techniques are discussed. TVSourceConvertPlainToVirtual()In 4) Divided tasks.au3, time measurements in TVSourceConvertPlainToVirtual() are divided into 3 sub-measurements that measure reading and converting the plain source file as well as saving the new virtual source file. Read and write times must be measured directly in TVSourceConvertPlainToVirtual(). Therefore the TVSourceFile.au3 include is copied to TVSourceFileRt.au3 and time measurement code is added in TVSourceConvertPlainToVirtual() in this new include. Also added 2 parameters to pass read and write times. Then the same functions (with the same names) can be used everywhere in the code, and only the name of the include file needs to be corrected. The read and write times in the parameters must of course be handled. The actual conversion time is calculated by subtracting read and write times from the total time measurement for the entire function. This ensures that the numbers match when added together. The time measurements in the report look like this: Load source: 57.9840 Convert src: 1634.2488 Save source: 646.1083 Convert source: 2338.3411 The sub-measurements are marked with an indentation. The new code in TVSourceConvertPlainToVirtual() Func TVSourceConvertPlainToVirtual( _ $iLevels, _ ; Treeview levels, 2 <= $iLevels <= 100 $sTVPlainSrc, _ ; Name of plain treeview input source file $sTVVirtualSrc, _ ; Name of virtual treeview output source file ByRef $fTimeLoad, ByRef $fTimeSave ) ; ... ; Read treeview input source file into array Local $hTimer = TimerInit() Local $aSource, $iSource, $bTVVirtual, $iTVLevels, $iTVItems If Not TVSourceReadToArray( $sTVPlainSrc, $aSource, $iSource, $bTVVirtual, $iTVLevels, $iTVItems ) _ Or $bTVVirtual Then Return SetError( @error+1, 0, 0 ) $fTimeLoad = TimerDiff( $hTimer ) $hTimer = 0 ; ... ; Save $oSource in source file $hTimer = TimerInit() Local $hTVVirtualSrc = FileOpen( $sTVVirtualSrc, 2+256 ) ; $FO_OVERWRITE+$FO_UTF8_NOBOM For $i = 0 To $iCnt FileWriteLine( $hTVVirtualSrc, $oSource( $i+0.0 ) ) Next FileClose( $hTVVirtualSrc ) $fTimeSave = TimerDiff( $hTimer ) The code in Runtimes1() ; Time test 3 - 6 $iTest += 1 If Not $aTimes[$iTest][2] Or ( $aTimes[$iTest][1] < $aTimes[$iTest][2] ) Then $hTimer = TimerInit() TVSourceConvertPlainToVirtual( $iLevels, $sSources & "Plain, debug.txt", $sSources & "Virtual, debug.txt", $fTimeLoad, $fTimeSave ) $aTimes[$iTest][1] = TimerDiff( $hTimer ) Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $fTimeLoad, $aRuntime_Info, " Load source:" ) $iTest += 1 ; Time test 4 Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest-1][1] - $fTimeLoad - $fTimeSave, $aRuntime_Info, " Convert src:" ) $iTest += 1 ; Time test 5 Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $fTimeSave, $aRuntime_Info, " Save source:" ) $iTest += 1 ; Time test 6 Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest-3][1], $aRuntime_Info, "Convert source:" ) Else Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, " Load source:" ) $iTest += 1 ; Time test 4 Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, " Convert src:" ) $iTest += 1 ; Time test 5 Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, " Save source:" ) $iTest += 1 ; Time test 6 Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, "Convert source:" ) EndIf Note how $iTest is used to indicate line locations in the report of sub-measurements and total measurement, as well as index in $aTimes, where column 1 (zero based) contains the time measurements and column 2 contains the maximum times. TVSourceConvertPlainToVirtualVb()The time measurements in TVSourceConvertPlainToVirtualVb() are performed in the same way as the time measurements in TVSourceConvertPlainToVirtual() except that the read and write times must be measured in the VB.NET code. The code in TVSourceConvertPlainToVirtualVb() Func TVSourceConvertPlainToVirtualVb( _ $iLevels, _ ; Treeview levels, 2 <= $iLevels <= 100 $sTVPlainSrc, _ ; Name of plain treeview input source file $sTVVirtualSrc, _ ; Name of virtual treeview output source file ByRef $fTimeLoad, ByRef $fTimeSave ) If Not ( 2 <= $iLevels And $iLevels <= 100 ) Then Return SetError( 1, 0, 0 ) If Not FileExists( $sTVPlainSrc ) Then Return SetError( 2, 0, 0 ) ; Get $oVbNetCode object to execute function as compiled VB.NET code Local $oVbNetCode = TVSourceCreateVbNetCodeObject() If Not IsObj( $oVbNetCode ) Then Return SetError( 6, 0, 0 ) ; Execute TVSourceConvertPlainToVirtualVb() as compiled VB.NET code Local $aRet = $oVbNetCode.TVSourceConvertPlainToVirtualVb( $iLevels, $sTVPlainSrc, $sTVVirtualSrc ) If $aRet[0] < 0 Then Return SetError( -$aRet[0]+2, 0, 0 ) $fTimeLoad = $aRet[1] $fTimeSave = $aRet[2] Return 1 EndFunc TVSourceFile.vb is copied to TVSourceFileRt.vb and VB.NET code for time measurement in TVSourceConvertPlainToVirtualVb() method is added to this file: Public Function TVSourceConvertPlainToVirtualVb( iLevels As Integer, sTVPlainSrc As String, sTVVirtualSrc As String ) As Object() Dim oStopWatch As New Stopwatch(), iFrequency As Long = oStopWatch.Frequency, fTicksPerMillisecond As Double = iFrequency / 1000 'Read treeview input source file into array oStopWatch.Restart() Dim aSource() As String = File.ReadAllLines( sTVPlainSrc ) Dim iSource As Integer, bVirtual As Boolean, iItems As Integer, aRet(2) As Object aRet(0) = TVSourceCheckArray( aSource, iSource, bVirtual, iLevels, iItems ) If aRet(0) = 0 And bVirtual Then aRet(0) = -2 If aRet(0) < 0 Then Return aRet oStopWatch.Stop() aRet(1) = oStopWatch.ElapsedTicks / fTicksPerMillisecond '$fTimeLoad '... 'Save $oSource in source file oStopWatch.Restart() Using SW As StreamWriter = New StreamWriter( sTVVirtualSrc ) For i As Integer = 0 To iCnt SW.WriteLine( oSource.Item(i) ) Next End Using oStopWatch.Stop() aRet(2) = oStopWatch.ElapsedTicks / fTicksPerMillisecond '$fTimeSave Return aRet End Function The code in Runtimes2() is similar to the code in Runtimes1(). TVSourceDisplayVirtual()Time measurement of TVSourceDisplayVirtual() is done in the same way as time measurement of TVSourceDisplayPlain() above by running the function in a separate process with Run(). But now there is an additional complication, as the time to read the source file must be sent back to the Runtime function through interprocess communication. The interprocess communication is implemented by a ROT object that is initialized in this way at the top of the Runtime function: ; --- Additional initializations for the current function --- ; Create a default ROT-object (Dictionary object) ; The script that creates the ROT object is the server Local $sDataTransferObject = "DataTransferObject", $oDict $oDict = ROT_CreateDefaultObject( $sDataTransferObject ) $oDict.Item( "Time" ) = 0.0 The $sDataTransferObject string identifying the ROT object must be passed to the process where TVSourceDisplayVirtual() is executed. This is done with a simple command line parameter. This is the code in TVSourceFileRt.au3 for separate time measurement of loading the virtual source file: Func TVSourceDisplayVirtual( $sTVVirtualSrc, $bLargeGui, $sDataTransferObject ) ; Get default ROT-object (Dictionary object) ; IRunningObjectTable.au3 not needed in client Local $oDict = ObjGet( $sDataTransferObject ) ; ... ; Read source file into $aSource ; Source file specification in TVCreateVirtualSrcDbg() Local $hTimer = TimerInit() If Not FileExists( $sTVVirtualSrc ) Then Return SetError( 1, 0, 0 ) Local $hTVVirtualSrc = FileOpen( $sTVVirtualSrc, 256 ) ; $FO_UTF8_NOBOM $aSource = FileReadToArray( $hTVVirtualSrc ) Local $iSource = @extended $iLevels = StringSplit( $aSource[$iSource-1], ":", 2 )[0] + 1 ; Last line in $aSource ; The line has this format: 4:218705|14151 Local $eLevels = @error ; 4->level, 218705->first row, 14151->number of rows FileClose( $hTVVirtualSrc ) ; Level in this line indicates the total number of levels $oDict.Item( "Time" ) = TimerDiff( $hTimer ) $hTimer = 0 The code in Runtimes1() ; Time test 7 - 9 ; This time test is dependent on the previous test being completed within $iTest += 1 ; the time limit. $aTimes[$iTest-4][0] indicates whether this is the case. If Not $aTimes[$iTest][2] Or ( $aTimes[$iTest-4][0] And $aTimes[$iTest][1] < $aTimes[$iTest][2] ) Then $hTimer = TimerInit() Run( $sAutoItExePath & ( $iBit = 32 ? "AutoIt3.exe" : "AutoIt3_x64.exe" ) & " /AutoIt3ExecuteScript " & """" & $sScriptPathVirtual & """" & " " & """" & $sSources & "Virtual, debug.txt" & """" & " " & 1 & " " & $sDataTransferObject ) WinClose( WinWaitActive( "Display Virtual TreeView From Source File" ) ) ; $aTimes[$iTest-4][0] = 0 indicates that the previous test wasn't completed within the time limit. $aTimes[$iTest][1] = TimerDiff( $hTimer ) ; Because $aTimes[$iTest-4][0] is set at this place in the code and not immediately after the prev If $aTimes[$iTest-4][1] > $aTimes[$iTest-4][2] Then $aTimes[$iTest-4][0] = 0 ; test, this test is still executed the FIRST time the previous test exceeds the time limit. Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $oDict.Item( "Time" ), $aRuntime_Info, " Load source:" ) ; Time tests 7 and 8 are subtests $iTest += 1 ; Time test 8 ; (indicated by indentation) of test 9. Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest-1][1] - $oDict.Item( "Time" ), $aRuntime_Info, " Create GUI:" ) $iTest += 1 ; Time test 9 Runtime_Info1( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest-2][1], $aRuntime_Info, "Display virtual:" ) ; Time test 9 is the sum of tests 7 and 8 Else Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, " Load source:" ) ; Time tests 7 and 8 are subtests $iTest += 1 ; Time test 8 ; (indicated by indentation) of test 9. Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, " Create GUI:" ) $iTest += 1 ; Time test 9 Runtime_Info2( 8+$iTest, $i, $iTests, $iLineLen, $aTimes[$iTest][2], $aRuntime_Info, "Display virtual:" ) ; Time test 9 is the sum of tests 7 and 8 EndIf 5) Divided tasks - No limit.au35) Divided tasks - No limit.au3 runs the same code as 4) Divided tasks.au3 but without time limits except for the 10 second time limit on TVSourceDisplayPlain(). The report is saved in 5) Divided tasks - No limit.txt: Pure AutoIt Code Compiled VB.NET Code Create, Convert and Display TreeView Source File Create, Convert and Display TreeView Source File Code executed as 32-bit code Code executed as 64-bit code Code executed as 32-bit code Code executed as 64-bit code ============================== ============================== ============================== ============================== 10,701 items 10,701 items 10,701 items 10,701 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 62.1074 Create source: 55.0925 Create source: 6.9292 Create source: 5.2162 Display plain: 1310.1184 Display plain: 1279.0274 Display plain: 1466.3365 Display plain: 1248.0080 Load source: 6.4438 Load source: 5.3520 Load source: 1.4844 Load source: 0.8248 Convert src: 174.8612 Convert src: 168.1489 Convert src: 105.6492 Convert src: 108.3194 Save source: 45.1033 Save source: 57.4945 Save source: 2.9284 Save source: 1.6936 Convert source: 226.4083 Convert source: 230.9954 Convert source: 110.0620 Convert source: 110.8378 Load source: 31.3393 Load source: 31.4346 Load source: 17.5593 Load source: 17.4069 Create GUI: 777.7560 Create GUI: 759.7363 Create GUI: 757.9427 Create GUI: 741.3450 Display virtual: 809.0953 Display virtual: 791.1709 Display virtual: 775.5019 Display virtual: 758.7519 20,346 items 20,346 items 20,346 items 20,346 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 127.3154 Create source: 118.0155 Create source: 22.1183 Create source: 16.5561 Display plain: 2682.8592 Display plain: 1684.5415 Display plain: 2682.5587 Display plain: 1668.7154 Load source: 12.7071 Load source: 10.2092 Load source: 2.1324 Load source: 1.9302 Convert src: 350.3479 Convert src: 315.0080 Convert src: 224.8100 Convert src: 216.9120 Save source: 87.9589 Save source: 83.4993 Save source: 3.1977 Save source: 3.2877 Convert source: 451.0139 Convert source: 408.7165 Convert source: 230.1401 Convert source: 222.1299 Load source: 43.2681 Load source: 40.9371 Load source: 39.6455 Load source: 48.5210 Create GUI: 769.5770 Create GUI: 735.3170 Create GUI: 752.2369 Create GUI: 741.1237 Display virtual: 812.8451 Display virtual: 776.2541 Display virtual: 791.8823 Display virtual: 789.6446 52,134 items 52,134 items 52,134 items 52,134 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 299.3385 Create source: 281.6153 Create source: 47.1510 Create source: 35.3964 Display plain: 4039.9790 Display plain: 3197.4666 Display plain: 4086.8056 Display plain: 3165.9145 Load source: 30.7583 Load source: 26.7869 Load source: 4.6710 Load source: 5.1739 Convert src: 964.1700 Convert src: 883.4936 Convert src: 651.3202 Convert src: 689.5954 Save source: 254.3325 Save source: 232.0731 Save source: 11.8061 Save source: 7.2628 Convert source: 1249.2608 Convert source: 1142.3536 Convert source: 667.7973 Convert source: 702.0320 Load source: 71.0920 Load source: 94.0728 Load source: 37.3873 Load source: 66.1594 Create GUI: 745.4110 Create GUI: 744.5920 Create GUI: 768.2801 Create GUI: 738.8671 Display virtual: 816.5030 Display virtual: 838.6648 Display virtual: 805.6674 Display virtual: 805.0266 112,472 items 112,472 items 112,472 items 112,472 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 599.4971 Create source: 524.5084 Create source: 66.0073 Create source: 47.0230 Display plain: 7170.9434 Display plain: 5738.8998 Display plain: 7189.4322 Display plain: 5519.9219 Load source: 82.1756 Load source: 71.4516 Load source: 17.2459 Load source: 11.6925 Convert src: 2127.0630 Convert src: 2129.2415 Convert src: 1199.6497 Convert src: 1291.4186 Save source: 677.1560 Save source: 662.6223 Save source: 22.0474 Save source: 15.3304 Convert source: 2886.3945 Convert source: 2863.3154 Convert source: 1238.9430 Convert source: 1318.4415 Load source: 113.3855 Load source: 147.0694 Load source: 83.1979 Load source: 83.3907 Create GUI: 754.7151 Create GUI: 766.5056 Create GUI: 757.5615 Create GUI: 741.4110 Display virtual: 868.1006 Display virtual: 913.5751 Display virtual: 840.7593 Display virtual: 824.8017 259,399 items 259,399 items 259,399 items 259,399 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 1421.3263 Create source: 1213.4943 Create source: 128.4674 Create source: 98.3820 Display plain: 16345.0322 Display plain: 12618.3510 Display plain: 16548.6287 Display plain: 12383.4254 Load source: 171.1753 Load source: 145.5609 Load source: 57.0352 Load source: 41.5014 Convert src: 5476.9818 Convert src: 5336.6914 Convert src: 3044.4364 Convert src: 3101.9301 Save source: 2407.9014 Save source: 2475.1453 Save source: 50.0090 Save source: 38.3763 Convert source: 8056.0586 Convert source: 7957.3976 Convert source: 3151.4806 Convert source: 3181.8079 Load source: 232.9671 Load source: 206.9770 Load source: 213.1691 Load source: 195.5270 Create GUI: 762.8132 Create GUI: 768.1915 Create GUI: 768.0311 Create GUI: 753.9219 Display virtual: 995.7803 Display virtual: 975.1685 Display virtual: 981.2001 Display virtual: 949.4488 533,240 items 533,240 items 533,240 items 533,240 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 2940.3783 Create source: 2493.9978 Create source: 269.4767 Create source: 201.4929 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Load source: 321.2050 Load source: 286.1879 Load source: 157.4970 Load source: 57.1485 Convert src: 12323.8170 Convert src: 14228.8776 Convert src: 5353.2245 Convert src: 5461.8312 Save source: 7808.0456 Save source: 8588.9200 Save source: 92.7671 Save source: 69.4851 Convert source: 20453.0676 Convert source: 23103.9855 Convert source: 5603.4885 Convert source: 5588.4648 Load source: 425.8721 Load source: 421.7100 Load source: 453.9295 Load source: 370.9353 Create GUI: 759.1212 Create GUI: 775.5487 Create GUI: 784.2907 Create GUI: 788.6021 Display virtual: 1184.9933 Display virtual: 1197.2588 Display virtual: 1238.2202 Display virtual: 1159.5374 758,890 items 758,890 items 758,890 items 758,890 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 4226.6064 Create source: 3571.2496 Create source: 333.9886 Create source: 257.9039 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Load source: 477.4109 Load source: 401.9269 Load source: 157.8519 Load source: 83.5317 Convert src: 21411.7366 Convert src: 28981.0439 Convert src: 7530.1962 Convert src: 7341.7639 Save source: 15719.9689 Save source: 16863.5387 Save source: 126.6347 Save source: 99.2910 Convert source: 37609.1165 Convert source: 46246.5095 Convert source: 7814.6828 Convert source: 7524.5866 Load source: 625.1885 Load source: 543.1343 Load source: 582.0656 Load source: 514.3804 Create GUI: 762.6148 Create GUI: 791.0991 Create GUI: 829.6602 Create GUI: 771.9499 Display virtual: 1387.8033 Display virtual: 1334.2335 Display virtual: 1411.7258 Display virtual: 1286.3303 1,012,329 items 1,012,329 items 1,012,329 items 1,012,329 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 5516.6633 Create source: 4676.4791 Create source: 415.8247 Create source: 322.2628 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Load source: 612.9120 Load source: 568.7687 Load source: 229.1037 Load source: 99.2511 Convert src: 30923.4898 Convert src: 43359.6711 Convert src: 9938.2783 Convert src: 10027.4878 Save source: 23744.0712 Save source: 27398.9498 Save source: 161.4105 Save source: 131.0168 Convert source: 55280.4730 Convert source: 71327.3896 Convert source: 10328.7925 Convert source: 10257.7557 Load source: 774.1494 Load source: 687.2840 Load source: 760.0064 Load source: 643.1498 Create GUI: 755.2697 Create GUI: 755.7249 Create GUI: 778.1790 Create GUI: 786.9553 Display virtual: 1529.4191 Display virtual: 1443.0089 Display virtual: 1538.1854 Display virtual: 1430.1051 2,399,622 items 2,399,622 items 2,399,622 items 2,399,622 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 13276.6749 Create source: 11204.7845 Create source: 1000.4516 Create source: 953.3488 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Load source: 1586.1944 Load source: 1426.5512 Load source: 805.6862 Load source: 306.9113 Convert src: 172994.7627 Convert src: 297646.4029 Convert src: 23464.3343 Convert src: 23343.9714 Save source: 126799.6477 Save source: 153536.8562 Save source: 386.7730 Save source: 313.0233 Convert source: 301380.6048 Convert source: 452609.8102 Convert source: 24656.7935 Convert source: 23963.9060 Load source: 1862.5236 Load source: 1635.9128 Load source: 2377.0049 Load source: 1607.1037 Create GUI: 774.3998 Create GUI: 760.4771 Create GUI: 785.4887 Create GUI: 785.5621 Display virtual: 2636.9234 Display virtual: 2396.3899 Display virtual: 3162.4935 Display virtual: 2392.6658 5,511,625 items 5,511,625 items 5,511,625 items 5,511,625 items ------------------------------ ------------------------------ ------------------------------ ------------------------------ Create source: 30928.5165 Create source: 25546.8734 Create source: 2851.4060 Create source: 2027.6535 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Display plain: >10000.0000 Load source: 3519.3227 Load source: 3262.8841 Load source: 2177.5527 Load source: 1571.7511 Convert src: 1143691.3887 Convert src: 3183438.0475 Convert src: 54347.2599 Convert src: 52933.0415 Save source: 687139.3046 Save source: 832546.3303 Save source: 2222.7075 Save source: 1536.9030 Convert source: 1834350.0160 Convert source: 4019247.2619 Convert source: 58747.5201 Convert source: 56041.6956 Load source: 4317.9148 Load source: 3456.4418 Load source: 6037.6460 Load source: 5253.7490 Create GUI: 769.7396 Create GUI: 750.2432 Create GUI: 818.7498 Create GUI: 773.9574 Display virtual: 5087.6544 Display virtual: 4206.6850 Display virtual: 6856.3959 Display virtual: 6027.7064 Note that the difference between AutoIt and VB.NET code is significant for large treeviews. For the largest treeview with 5.5 million items, it takes ½ - 1+ hours to execute the AutoIt code to convert the source. It takes 1 minute to execute the VB.NET code. It's also noteworthy that 32 bit AutoIt code is twice as fast as 64 bit code. You would have expected the opposite. Probably caused by an intense use of Dictionary objects. Overview section added at top of first post. New 7z-file at bottom of first post.1 point -
Take an example #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> Local $hGUI = GUICreate("MyGUI", 480, 350, -1, -1, -1, $WS_EX_TOPMOST) Local $Pic1 = GUICtrlCreatePic("", 0, 0, 480, 320) Local $Label1 = GUICtrlCreateLabel("Label1", 10, 325, 400, 17) Local $Button1 = GUICtrlCreateButton("Capture", 420, 325, 51, 21) GUISetState(@SW_SHOW) Local $hWnd, $WPos, $Pic_cnt = 1 Local $iMsgBoxAnswer, $Msg $Msg = "First Select (Activate) the window" & @CRLF _ & " you wand the capture " & @CRLF _ & "and then click ok" $iMsgBoxAnswer = MsgBox($MB_OKCANCEL + $MB_TOPMOST + $MB_ICONINFORMATION, "Get Menu Information", $Msg) Select Case $iMsgBoxAnswer = 1 ;OK ; ok Case $iMsgBoxAnswer = 2 ;Cancel Exit EndSelect ; Retrieve the class of the active window. $hWnd = WinGetHandle("[ACTIVE]") WinWaitActive($hWnd, "", 5) ; If the directory exists Remove the directory If FileExists(@ScriptDir & "\Shots") Then DirRemove(@ScriptDir & "\Shots", $DIR_REMOVE) EndIf ; and then make new directory DirCreate (@ScriptDir & "\Shots") While 1 $WPos = WinGetPos($hWnd) ; [0]=X [1]=Y [2]=Width [3]=Height Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop Case $Button1 TakeShot() EndSwitch Sleep(10) WEnd Func TakeShot() ; Capture region _ScreenCapture_Capture(@ScriptDir & "\Shots\shot_" & $Pic_cnt & ".jpg", $WPos[0], $WPos[1], $WPos[2], $WPos[3]) Sleep(50) GUICtrlSetImage($Pic1, @ScriptDir & "\Shots\shot_" & $Pic_cnt & ".jpg") GUICtrlSetData($Label1, @ScriptDir & "\Shots\shot_" & $Pic_cnt & ".jpg") $Pic_cnt += 1 EndFunc ;==>TakeShot1 point
-
You can check the registry for the DisplayName example can be found here: Note: This is based on your script being compiled as 32-bit, if you want to compile the script as 64-bit you'll need to use: ::64-bit Key Convert HKLM64\SOFTWARE\... with HKEY_LOCAL_MACHINE\SOFTWARE\... :: 32-bit Key Convert HKLM\SOFTWARE\... with HKEY_LOCAL_MACHINE\WOW6432Node\SOFTWARE\...1 point
-
@mistersquirrleI solved it! I will post soon a complete package including all needed functions to add a "Buy Now" feature in .au3 applications and to manage all activities up to the completion of the payment procedures.1 point
-
SAX-XML-Parser in pure AutoIt
ioa747 reacted to AspirinJunkie for a topic
Introduction: To parse XML data, a so-called DOM parser is usually used - e.g. the Microsoft.XMLDOM object. This parser goes through the entire structure and rebuilds it hierarchically in its own data structure. Afterwards you can continue working on this basis. In other programming languages, however, one occasionally encounters a different approach: the SAX parser. Here the idea is as follows: The parser traverses the XML string and calls user-defined functions at certain breakpoints. Usually this would be at the beginning of an element, for example. The parser then passes the element type, the position in the string and the attributes of the element to the user-defined function. The parser doesn't care what the user does with it - it just calls functions at the breakpoints. Further breakpoints would be when closing an element or as soon as the content of an element has been reached. This approach has advantages as well as disadvantages. The advantage is that the user can decide what is really needed and what is not. This can result in faster parsing. Also it is possible to process the data before it is completely loaded or processed. The disadvantage however is that the work with this can not only take some getting used to but also quickly become very complex. In particular, since it is important for a reasonable processing to exchange information between the individual user functions one will have to use global variables. Example of use: The following example reads the Autoitscript.com forum page and extracts a list of recent topics using the SAX parser: To use or not? So what's the point of all this? For most use cases I think it is better to use the known DOM-based approaches, because working with a SAX parser can quickly degenerate into enormous complexity. However, a certain acceleration can(!) be achieved with this approach. I have tested this in the example above: If I process the page with the HTMLFile object, it needs ~150ms for parsing alone. The topics were already processed with the SAX parser after 60ms (the parsing continues - but can be stopped). The question is whether the higher complexity for the user is worth it for these cases. The Sax parser also reacts more kindly to errors in the XML file in many cases and could be used as a more robust alternative. With the SAX parser as a fundament, it should also be fairly easy to write your own purely AutoIt-based DOM parser. And last but not least, we can now say for AutoIt: Now we have our own Sax parser too! >>sourcecode and download on github<<1 point