Copying text and automated search.

Get help with using AutoHotkey and its commands and hotkeys
Posts: 1
Joined: 27 Oct 2017, 03:33

Copying text and automated search.

27 Oct 2017, 05:43


I apologise in advance for my newbish question concerning copying and pasting text in a specific manner, but I had no luck figuring it myself. I would be most grateful if someone could help me with my lengthy inquiry.
Let me explain my intended script function:
- I need it to copy specific part of a Firefox HTML document (I believe in this case it makes it easier to do so cause the “ctrl+f” function works to the advantage) to a separate file, but I need it to do so not for one, but multiple documents in a folder.
- Example: I have a 100 documents in a folder and I am searching for a number (which will wary between 0.0 to – 100.0) that will be after certain text.
o For example: from a text
 “WBC (*10e9/l) - 6,79, NEU (%) - 44,0, LYM (%) - 41,2, MON (%) - 10,9, EOS (%) - 3,1, BAS (%) - 0,7”
o In this example I would need to copy 6,79, which would always be right after “WBC (*10e9/l) –“.
- So I need the script to open the hundred documents (which have different names) and to copy those specific numbers in a separate one file (for example: an excel sheet).

Thank you very much!!
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: Copying text and automated search.

27 Oct 2017, 15:30

Petras wrote:but I had no luck figuring it myself.
Then show what You tried so far.

For this task You'll likely need LoopFile, read the file and RegExMatch it.

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
User avatar
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Copying text and automated search.

02 Nov 2017, 11:03

- It sounds like you have 100 htm/html files.
- You could, like SirRFI mentioned, parse the text, e.g. FileRead and InStr/RegExMatch.
- You could also use an HTMLFile object and JavaScript to loop through various web elements, find your match, and then retrieve the contents of an element relative to that one.

- It might sound daunting to use objects, but I've often found that this is much quicker and easier than parsing text.

- If you make available to download somewhere, a copy of one of your htm files, with dummy data and/or names removed, we may be able to assist you in retrieving the information. I'm quite willing to help with what looks like medical data.

Here is an example of using JavaScript. If you search for AutoHotkey and HTMLFile you should be able to find more examples.
webpages: get table text - AutoHotkey Community

When I want to do something like this myself, I normally end up using JavaScript including getElementsByTagName or getElementsByClassName somewhere, and I open the htm file or webpage url in Internet Explorer and investigate it using iWB2 Learner. I would need to find identifying information for the html elements that I want to retrieve text from, such as their ID, tag name or class name, or perhaps information for an easily identifiable element which they are relative to.

[Link for iWB2 Learner]
Acc library (MSAA) and AccViewer download links - AutoHotkey Community

homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: Chunjee, Google [Bot], LeFunk, mikeyww, Miki86, RaZorwiresc2, Xtra and 64 guests