Text searching in a document

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RuneTrout
Posts: 26
Joined: 22 Mar 2016, 04:15

Text searching in a document

16 Oct 2017, 21:55

I haven't edited AHK in over a year now, the scripts created aren't used anymore and I kinda fell out of it. I have need for a one time use script and would rather write it myself, however if it's easy enough I'm not going to not use something made for me. I'm looking in the help file again but I'd like some suggestions because I'm missing quite a bit.

The function of the script will be to search over 7000 emails associated with purchases made on my friends website over the past year. The emails that made purchases as well as ordered a free sample are what I'm trying to get a list of. If the email did not get the free sample, I don't want it in the final list. I can find words in a text document so far, then I get lost lol. Help please?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Text searching in a document

16 Oct 2017, 23:19

I think it's important to understand how the emails are accessed.

Are these local copies, are they saved in a format that AHK can even open them as and parse? That is, could use you use FileRead (or FileOpen()) to get an email into AHK and use MsgBox %variable% to see the contents of the email? If so, you can use that FileRead (possibly in conjunction with Loop, Files) and then use IfInString() or InStr(), or RegExMatch() to find what you're looking for and compile a list of matching documents.

If you're using a client like Outlook Application, it can be controlled by COM. ComObjCreate() or ComObjActive(). Check out these two threads from the old forums. (The old thread(s) mention AHK_L; it'll work in today's updated AHK)

https://autohotkey.com/board/topic/8107 ... es-in-ahk/
https://autohotkey.com/board/topic/7133 ... for-ahk-l/

If this is a web-browser email site you'd need to search, and for some reason it doesn't have it's own search function, you may be able to use COM on Internet Explorer (tutorials on both the new forums and old forums).

If it's anywhere else, I'm not sure about any good API for it. Most modern clients would have a search function.
RuneTrout
Posts: 26
Joined: 22 Mar 2016, 04:15

Re: Text searching in a document

17 Oct 2017, 00:12

Oh no just the addresses attached to purchase orders, not individual text emails. It's an excel sheet with three columns: email address, product name, price. Trying to separate out any email address that did not get a free product (meaning they only purchased items), so that anyone who got the free product (spent 0$) could have their follow up purchases tallied. Trying to see if the free product is worth it, basically. My friend would do it by hand but I just asked her more about it, apparently the list she has to go through is an excel document with 43000 purchase orders with the above listed 3 pieces of information.

IfInString(), InStr() and RegExMatch() are ringing a slight bell, I believe one of those is what I'm after.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Text searching in a document

17 Oct 2017, 01:14

If this is an Excel sheet, Excel has a COM interface. Several tutorials to introduce using AHK for Excel are available.

However, I have a feeling that Excel should be able to do it itself. It's a really powerful program on its own.

You should be able to use something in the Sort and Filter to identify emails that had a $0.00 purchase. Then you can use that list to in turn search for any other entries by that email for any amount.

---

In Excel 2013, I'm able to use a feature called Filter. (Data->Filter). This will let you select a value for a column, such as $0, or $15, or $8, or multiple values if you want. Then only rows that have that value in that column are shown.

Actually, I crafted this with screenshots in an imgur album to demonstrate a small example with each step. I know it's not an AHK solution, but I imagine AHK isn't the best tool for this:

https://imgur.com/a/CufYn

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Google [Bot], mcd, ShatterCoder and 85 guests