Popular Post AutoBert Posted February 5, 2023 Popular Post Share Posted February 5, 2023 (edited) 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. expandcollapse popup#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 : expandcollapse popup#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. Spoiler Edit: newest version in GuiRichEditPlus_43.au3 rename to GuiEditPlus.au3. Example : GuiRichEditPlus_Demo.au3uses this unrenamed This example uses _GUICtrlRichEdit_ ... functions to list the Install Directory Structure from Autoitdirectory What's new: 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_AppendTextEx 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. Spoiler _42: Also new is a added func from @Corgano: _GUICtrlRichEdit_AppendTextEx modifiended by me (.._42 & later). I plan to extend it for bkColors. UrlFriendly.au3 GuiRichEditPlus.au3 GuiRichEditPlus_2.au3 GuiRichEditPlus_3.au3 GuiRichEditPlus_4.au3 GuiRichEditPlus_42.au3 GuiRichEditPlus_Demo.au3 Edited February 18, 2023 by AutoBert newer files uploaded ioa747, Andreik, argumentum and 2 others 5 Link to comment Share on other sites More sharing options...
Andreik Posted February 5, 2023 Share Posted February 5, 2023 Tested with some files from my PC, it works good in most of the cases. With certain filenames (containing underscores, unicode characters, etc) the insert function fails but it works pretty good in most cases. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoBert Posted February 6, 2023 Author Share Posted February 6, 2023 (edited) 14 hours ago, Andreik said: With certain filenames (containing underscores, unicode characters, etc) the insert function fails I will have a look at this. A hotfix for underscores: disable first line from Func _GUICtrlRichEdit_insertFileLink($hWnd, $sFile, $sDisplay, $bCRLF = False) ;autor autoBert If Not FileExists(StringReplace($sFile, '_', ' ')) Then Return SetError(1, 1, '') in this line i check for file existing. The _GUICtrlRichEdit_GetFileLink fails with these links. You can hotfix with changing in _GUICtrlRichEdit_GetFileLink $sLink = StringReplace(StringReplace(_GUICtrlRichEdit_GetTextInRange($hWnd, $cpMin, $cpMax), 'File:', ''), '_', ' ') to $sLink = StringReplace(_GUICtrlRichEdit_GetTextInRange($hWnd, $cpMin, $cpMax), 'File:', '') Edited February 6, 2023 by AutoBert Link to comment Share on other sites More sharing options...
AutoBert Posted February 6, 2023 Author Share Posted February 6, 2023 New version, DL-Files in #1 @Andreik can you please test again (are problems solved?) Link to comment Share on other sites More sharing options...
Andreik Posted February 7, 2023 Share Posted February 7, 2023 It's good but these two lines Local Const $sbinDisplay = '{\fldrslt\ul\cf1' Local Const $sbinEndLine = '\ul0\cf0}}\f0\fs17' can cause problems also, because if the filename starts with a number it won't work correctly. Most probably a space after cf1 and fs17 would fix this. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoBert Posted February 7, 2023 Author Share Posted February 7, 2023 (edited) 28 minutes ago, Andreik said: if the filename starts with a number it won't work correctly. Just tested with such a filename: +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. encoding False $EN_LINK insertFileLink: C:\Users\(len)Bert\Downloads\Rezepte\1 Allgäuer Bauernschnitzel mit Petersilienkartöffelchen und Preiselbeeren.pdf 1 Allgäuer Bauernschnitzel mit Petersilienkartöffelchen und Preiselbeeren.pdf {\rtf1{\field{\*\fldinst{HYPERLINK "File:\\\\C:\\\\Users\\\\(len)Bert\\\\Downloads\\\\Rezepte\\\\1 Allgäuer Bauernschnitzel mit Petersilienkartöffelchen und Preiselbeeren.pdf"}}{\fldrslt\ul\cf1 1 Allgäuer Bauernschnitzel mit Petersilienkartöffelchen und Preiselbeeren.pdf \ul0\cf0}}\f0\fs17}}}}\par\par} True|0 1 FileLinks inserted $EN_LINK $EN_LINK $EN_LINK File:\C:\Users\(len)Bert\Downloads\Rezepte\1 Allgäuer Bauernschnitzel mit Petersilienkartöffelchen und Preiselbeeren.pdf: 0|0 $EN_LINK a test with the a space after both const's makes no differences in resutlt: "It works for me" so by the next update these is changed. Edited February 8, 2023 by AutoBert Link to comment Share on other sites More sharing options...
AutoBert Posted February 8, 2023 Author Share Posted February 8, 2023 (edited) A newer Version is in #1, Added: _GUICtrlRichEdit_insertLink which should work with Files also, if not use _GUICtrlRichEdit_insertFileLink. Edit: added: _GUICtrlRichEdit_AppendTextEx (Original from @corgano). I plan to integrate settings for bkColor and CharAttributes. Edited February 9, 2023 by AutoBert Link to comment Share on other sites More sharing options...
Zedna Posted February 10, 2023 Share Posted February 10, 2023 Very good and useful!! 👍 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
AutoBert Posted February 10, 2023 Author Share Posted February 10, 2023 7 hours ago, Zedna said: Very good and useful!! 👍 i am searching for: a RTF printing routine converter routine to PDF format to make it better. After printing is ok i will try mailmerging routines. A newer revision is uploaded in #1. Link to comment Share on other sites More sharing options...
mLipok Posted February 11, 2023 Share Posted February 11, 2023 On 2/10/2023 at 8:11 PM, AutoBert said: a RTF printing routine Take a look for Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mLipok Posted February 11, 2023 Share Posted February 11, 2023 (edited) On 2/10/2023 at 8:11 PM, AutoBert said: converter routine to PDF format IT is possible with Open/Libre Office SDK. Edited February 11, 2023 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
AutoBert Posted February 17, 2023 Author Share Posted February 17, 2023 New Revision: GuiRicheditPlus_433 and DirListSDI uploaded Link to comment Share on other sites More sharing options...
mLipok Posted February 17, 2023 Share Posted February 17, 2023 @AutoBert please reedit your post and change code by changing #CS #CE to #cs #ce becuase Code highlighting on web page will be fixed when you do this. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
AutoBert Posted February 17, 2023 Author Share Posted February 17, 2023 1 hour ago, mLipok said: @AutoBert please reedit your post and change code by changing #CS #CE to #cs #ce becuase Code highlighting on web page will be fixed when you do this. done. Link to comment Share on other sites More sharing options...
mLipok Posted February 17, 2023 Share Posted February 17, 2023 not all: 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 = '/\' should be: 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 = '/\' Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now