estemarito Posted March 22, 2010 Share Posted March 22, 2010 Hi, I'm new at AutoIt, and I must say that AutoIt is Amazing!but I have only one problem.How can I select specific text in notepad?select from "here" to "here2" (the underlined text)ej:Julius Caesar is probably one of the most popular Roman military of all time. With him, casting the foundations for the future Roman Empire. But Caesar's military career would be boosted by an indisputable fact that led him to obtain great wealth and increase his personal prestige far."HERE"For any Roman military to annex new territories, then the Roman Republic, led to great privileges, titles and power ... very powerful. Caesar, a military and political career with a good chance of promotion"HERE2"thanks and greetings! Link to comment Share on other sites More sharing options...
Bert Posted March 22, 2010 Share Posted March 22, 2010 (edited) Look at StringRegExp in the helpfile Also look at StringInStr Edited March 22, 2010 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
estemarito Posted March 22, 2010 Author Share Posted March 22, 2010 I was looking for information on StringRegExp, and got the following code: #Include <String.au3> $Text = FileRead("email.txt") $EmailFound = StringRegExp($Text, "([A-Za-z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})", 3) If @error = 1 Then MsgBox(0, "E-Mail", "No E-Mail addressess found in the supplied text") Else For $i = 0 To UBound($EmailFound) - 1 MsgBox(0, "E-Mail", $EmailFound[$i]) Next EndIf But this works only for e-mails... I need that works for any text any idea? Link to comment Share on other sites More sharing options...
estemarito Posted March 23, 2010 Author Share Posted March 23, 2010 Please, i need some help whith this. is only select X text between A and B and copy to clipboard. plz.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2010 Moderators Share Posted March 23, 2010 estemarito, We expect you to do some work for yourself here. Just posting a script you found on the forum does not qualify as "work". However, wnat you want is very simple. And as I have some time to spare, here is how you do what you want. Put your complete text into Notepad and run this: #Include <String.au3> ; Activate Notepad WinActivate("Untitled - Notepad") WinWaitActive("Untitled - Notepad") ; Get the text from Notepad $sText = ControlGetText("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]") ; And display it MsgBox(0, "Notepad text", $sText) ; Set UNIQUE start and end points for your extract $sStart = "For any " $sEnd = " promotion." ; Extract the extract $aExtract = _StringBetween($sText, $sStart, $sEnd) ; Add back the start and end strings $sExtract = $sStart & $aExtract[0] & $sEnd ; And display it MsgBox(0, "Extract", $sExtract) ; Put the extract on the clipboard ClipPut($sExtract) But remember, the next time you ask for help, we will expect you to have made much more effort to solve your problem by yourself first. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
estemarito Posted March 24, 2010 Author Share Posted March 24, 2010 Thank you very much Melba23 and Volly. Please understand that just 2 days ago I found autoit. I know php, html and many other languages, but recently I'm starting with autoit. again, thank you very much. the script worked perfectly sry my english, i use traductor.,.. Link to comment Share on other sites More sharing options...
grooveman Posted January 29, 2022 Share Posted January 29, 2022 On 3/23/2010 at 9:33 AM, Melba23 said: estemarito, We expect you to do some work for yourself here. Just posting a script you found on the forum does not qualify as "work". However, wnat you want is very simple. And as I have some time to spare, here is how you do what you want. Put your complete text into Notepad and run this: #Include <String.au3> ; Activate Notepad WinActivate("Untitled - Notepad") WinWaitActive("Untitled - Notepad") ; Get the text from Notepad $sText = ControlGetText("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]") ; And display it MsgBox(0, "Notepad text", $sText) ; Set UNIQUE start and end points for your extract $sStart = "For any " $sEnd = " promotion." ; Extract the extract $aExtract = _StringBetween($sText, $sStart, $sEnd) ; Add back the start and end strings $sExtract = $sStart & $aExtract[0] & $sEnd ; And display it MsgBox(0, "Extract", $sExtract) ; Put the extract on the clipboard ClipPut($sExtract) But remember, the next time you ask for help, we will expect you to have made much more effort to solve your problem by yourself first. M23 I too have only discovered autoIt recently, and created a very basic script to automate 1 particular repetitive task and it works fine - but I'm very new, but excited to have found this program. However, having browsed the form, I've seen a particular trend and similar replies whereby experienced users here get upset with new folk asking for help, if they haven't already busted a gut trying to figure out a solution for themselves. Why does this forum expect new folk to reinvent the wheel, fail at the task, and then its only permisable to ask for help? And whilst I'm here, can I ask, I have several lines of contact info in a notepad. Name, Company, Email, Tel, Address, and want to automate to insert into a CRM program. Whilst I can handle the date paste into specified text boxes in the CRM, how would I select individual lines of info from the notepad? Some folks are not full time coders or professional coders but can be small business owners, trying to streamline processes, whilst handling many other aspects of their business, but the fact they have shown interest in AutoIt I felt would be enough encouragement for experienced users to maybe provide some help? This is just an observation, and a comment made with good intention. thanks all! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2022 Moderators Share Posted January 29, 2022 (edited) grooveman, Quote Why does this forum expect new folk to reinvent the wheel, fail at the task, and then its only permisable to ask for help? You are by no means the first to have made this comment - and the answer is always the same: The forum ethos is to help you get your code running as you wish, but also to get you to understand why so that you have a better chance of getting it right next time. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. We do not expect people to "bust a gut", but (in most cases) neither are we prepared to just "barf up code" (as one of my US colleagues puts it). There are several websites where you can pay to get code written to spec - we are a bunch of enthusiastic volunteers who want to help people along the road to becoming proficient coders by getting them to do some of the work themselves. No-one here minds (or laughs at) an amateurish, non-functioning script - all we want to see is that the poster has made some attempt to use the Help file to make a start. I hope that you find that explanation sufficient. And thank you for the restrained manner in which you expressed yourself above - we try to run a civilised forum and polite comments such as yours are always welcome. And as to your questions - I am sure you can guess the answer I am about to give you: What have you tried that has not worked to your satisfaction? Which functions does the Help file suggest might be of use? I suggest that a couple which might be include: FileRead (to get the text into a variable) and _StringBetween (to extract the required data from within the variable). Sight of a sample (suitably redacted) text would also be useful if you require further help. Over to you! M23 Edited January 29, 2022 by Melba23 Typo Earthshine and robertocm 1 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2022 Share Posted January 29, 2022 Additional comment on your requirement. In case of .txt file, it is not recommended to go thru Notepad (or any other text editor) for automation. You can easily read, write and delete lines with File* functions. I would strongly suggest you invest your time learning those functions instead of trying to automate Notepad. Let us know if you need help with your script if you face an issue, we will gladly be able to help assuming you provide script and data. It is quite important that you make your script runable to us in order to get proper help. BTW, welcome to the forum ! Earthshine 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
robertocm Posted February 1, 2022 Share Posted February 1, 2022 (edited) On 1/29/2022 at 6:59 AM, grooveman said: Some folks are not full time coders or professional coders but can be small business owners, trying to streamline processes, whilst handling many other aspects of their business, but the fact they have shown interest in AutoIt I felt would be enough encouragement for experienced users to maybe provide some help? Even from business perspective, it could be better "to take some time to learn the language, and then understand for yourself what the code is doing", not just relying on uncontrolled black boxes for processes that can change over time. Edited February 1, 2022 by robertocm 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