Spider001 Posted December 18, 2014 Share Posted December 18, 2014 these are lines at a .bat file Example regedit.exe /e:a "D:databackuplaptopCCleanerCCleaner.reg" "HKEY_CURRENT_USERSoftwarePiriformCCleaner" c:testtest7z.exe a "D:databackuplaptopThunderbirdThunderbird.7z" "C:Documents and SettingsEXPERTApplication DataThunderbird" and i want regedit.exe /e:a "D:...CCleaner.reg" "HKEY_CURRENT_USER..CCleaner" c:test...7z.exe a "D:data..Thunderbird.7z" "C:Documents and Settings..Thunderbird" How can i do this ? Or how do i do this at a good way. Must this be done with StringRegExpReplace ? Can i set where he can short it example regedit.exe /e:a "D:databackuplaptop...CCleaner.reg" "HKEY_CURRENT_USER...PiriformCCleaner" regedit.exe /e:a "D:data...CCleanerCCleaner.reg" "HKEY_CURRENT_USER...CCleaner" regedit.exe /e:a "D:databackup..CCleanerCCleaner.reg" "HKEY_CURRENT_USERSoftware...CCleaner" Link to comment Share on other sites More sharing options...
computergroove Posted December 18, 2014 Share Posted December 18, 2014 If you format this in a bat file this way I would be surprised if the bat file still worked at all. You could use stringtrimleft and stringinstr. I don't understand exactly what this does for you. Please explain further. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Spider001 Posted December 18, 2014 Author Share Posted December 18, 2014 (edited) No the lines from the bat must be shorter to show at the screen not for run. think i had to say it at the post before to use at example notify udf, or baloontip, or popupwindows,...... Edited December 18, 2014 by Spider001 Link to comment Share on other sites More sharing options...
BrewManNH Posted December 18, 2014 Share Posted December 18, 2014 You'd need to use either $DT_PATH_ELLIPSIS or $DT_END_ELLIPSIS when creating the label you're planning to put the text into. There is a Window's bug with these variables though, End works like Path and vice versa. This is a Windows issue and not an AutoIt one. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $sPath = "C:\I am a very long path\Which needs to be\Shortened to fit\In the label.txt" $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("Using $DT_PATH_ELLIPSIS:", 10, 10, 200, 20) GUICtrlCreateLabel($sPath, 10, 40, 300, 30, $DT_PATH_ELLIPSIS) GUICtrlSetBkColor(-1, 0xCCCCFF) GUICtrlCreateLabel("MSDN says:" & @CRLF & _ "'replaces characters in the middle of the string with ellipses so that the result fits in the specified rectangle'", 10, 80, 480, 40) GUICtrlCreateLabel("Using $DT_END_ELLIPSIS:", 10, 200, 200, 20) GUICtrlCreateLabel($sPath, 10, 230, 300, 30, $DT_END_ELLIPSIS) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("MSDN says:" & @CRLF & _ "'if the end of a string does not fit in the rectangle, it is truncated and ellipses are added'", 10, 270, 480, 40) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Solution jguinch Posted December 18, 2014 Solution Share Posted December 18, 2014 BrewManNH's suggestion seems appropriate. You can use this kind of regexp to : $string = 'regedit.exe /e:a "D:\data\backup\laptop\CCleaner\CCleaner.reg" "HKEY_CURRENT_USER\Software\Piriform\CCleaner"' $short = StringRegExpReplace($string, '("[^\\]+\\)(?:[^\\"]+\\)*([^"]+")', "$1...\\$2") ConsoleWrite($short) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Spider001 Posted June 4, 2015 Author Share Posted June 4, 2015 BrewManNH's suggestion seems appropriate.You can use this kind of regexp to :$string = 'regedit.exe /e:a "D:\data\backup\laptop\CCleaner\CCleaner.reg" "HKEY_CURRENT_USER\Software\Piriform\CCleaner"' $short = StringRegExpReplace($string, '("[^\\]+\\)(?:[^\\"]+\\)*([^"]+")', "$1...\\$2") ConsoleWrite($short)can some one turn this in c# ? Link to comment Share on other sites More sharing options...
SadBunny Posted June 4, 2015 Share Posted June 4, 2015 A somewhat surprising resurrection of your own old AutoIt topic.But yes, someone can. You can. For a working example, try: https://msdn.microsoft.com/en-us/library/xwewhkd1(v=vs.110).aspx. Or Google. It's not that hard. Try "regular expression search replace c#". Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Spider001 Posted June 4, 2015 Author Share Posted June 4, 2015 i did google the whole day long.but that part is the problem'("[^\\]+\\)(?:[^\\"]+\\)*([^"]+")', "$1...\\$2" Link to comment Share on other sites More sharing options...
SadBunny Posted June 5, 2015 Share Posted June 5, 2015 But... But... There's literally an example on that page (the second one) that does a regexp replace with a backreference and writes it to console, it does literally exactly what you ask. All you have to do is drop the pattern and the replace string in the example, fix the escaping in the strings to adhere to C# string escape rules, and run it.I tried it on http://rextester.com/, works like a charm. Took me a few minutes to minutes to put it all together. including the two google searches. Note that I never wrote any C# code ever before in my life. It's really not that hard. Spider001 1 Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Spider001 Posted June 5, 2015 Author Share Posted June 5, 2015 i had to do this this way but thanks SadBunny that helps a lot your postseveral of my problems are solved because of that site. string pattern = @"(""[^\]+\)(?:[^\""]+\)*([^""]+"")"; string data = regedit.exe /e:a "D:\data\backup\laptop\CCleaner\CCleaner.reg" "HKEY_CURRENT_USER\Software\Piriform\CCleaner" string replacement = "$1...\$2"; Regex rgx = new Regex(pattern); data = rgx.Replace("\"" + data + "\"", replacement); data = data.TrimStart('"'); data = data.TrimEnd('"'); 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