[GNC] AutoHotKey: Date Arithmetic Example

Geoff cleanoutmyshed at gmail.com
Sun Aug 14 23:33:23 EDT 2022


Nice work Glenn!

(I still think AutoHotKey would have been a better choice than KeePass 
for your keystroke automation though.)

I wasn't aware of UI.Vision - looks interesting, thanks for sharing.

Regards

Geoff
=====

On 15/08/2022 1:00 pm, Glenn Fowler wrote:
> Hi,
> 
> Automating the GUI is certainly possible (basically it's just RPA). I did
> it using PowerShell:
> https://www.reddit.com/r/GnuCash/comments/mugurm/automatically_scan_ocr_receipts_invoices/
> 
> Just adding that if you are looking into Selenium I would recommend
> UI.Vision: https://ui.vision/  It runs all of the important selenium
> commands but is much easier to use and more powerful.
> 
> 
> 
> On Sun, Aug 14, 2022 at 9:44 PM Geoff <cleanoutmyshed at gmail.com> wrote:
> 
>> Hi Tom
>>
>> Yes, AutoHotKey is quite a powerful scripting language and has some
>> basic date handling functionality built in.  Here is a trivial example
>> as a demonstration, but note that it fails for cases where the day of
>> the month is greater than 28.  This is easy to fix, but I don't know the
>> specific rules imposed by your bank.
>>
>> See attached screenshot before reading any further.
>>
>> =====
>> Loop, 12 {
>>       start_date := 2022 . SubStr(0 . A_Index, -1, 2) . 15
>>
>>       month := SubStr(start_date, 5, 2) - 16
>>
>>       prior_date := SubStr(start_date, 1, 4)
>>           + floor((month - 1) / 12)
>>           . SubStr(0 . (month < 0
>>                   ? mod(month, 12) + 12
>>                   : mod(month - 1, 12) + 1)
>>               , -1 ,2)
>>           . SubStr(start_date, 7)
>>
>>       FormatTime, show_start, %start_date%, ddd dd-MMM-yyyy
>>       FormatTime, show_prior, %prior_date%, ddd dd-MMM-yyyy
>>       results := results
>>           . "Start: " . show_start
>>           . "`nPrior: " . show_prior
>>           . "`n`n"
>> }
>> MsgBox,, AutoHotKey: Subtract 16 Months Example for Tom, %results%
>> =====
>>
>> The syntax is a bit quirky at first, but the documentation is good and
>> if you can drive Raku you can certainly drive AHK ;--)
>>
>>
>> HOWEVER, as it seems that you are bank scraping, you should consider
>> Selenium which is a very useful and extremely powerful tool for web
>> browser automation: https://www.selenium.dev/, *plus* it can be driven
>> from a variety of languages including Python, Perl, and (according to
>> Google) Raku:
>> https://raku.land/github:azawawi/Selenium::WebDriver
>>
>>
>> Hope this helps.
>>
>> Regards
>>
>> Geoff
>> =====
>>
>> On 15/08/2022 12:50 am, Tom Browder wrote:
>>> On Sun, Aug 14, 2022 at 00:40 Geoff <cleanoutmyshed at gmail.com
>>> <mailto:cleanoutmyshed at gmail.com>> wrote:
>>>
>>>      Hi Jim
>>>
>>>      I don't have any experience manipulating GnuCash XML files, but in
>>>      principle what you want to do should work, although it does void your
>>>      GnuCash warranty.
>>>
>>>      However, if you are going to all this effort you may find it more
>>>      worthwhile to invest your time in learning how to use a general
>> purpose
>>>      automation tool.  This approach has two advantages over data
>>>      manipulation:
>>>      (1) Automation drives the GnuCash GUI and thus protects you from
>>>      accidental data corruption.
>>>      (2) You will be able to use your new automation skills to automate
>> any
>>>      subsequent GnuCash tasks, for example loading historical
>>>      transactions to
>>>      your 130 securities.
>>>
>>>      For Windows, check out:
>>>      AutoHotKey https://www.autohotkey.com/ <https://www.autohotkey.com/>
>>>
>>>
>>> Geoff, that looks very interesting, thanks for the link. I do most of my
>>> work on Linux, but I do have to do some things on Windows (TL;DR), so
>>> this is very useful.
>>>
>>> One of the things I'm not sure about is how powerful the script is. For
>>> instance, can it determine the date for 16 months before the current
>>> date? That's one of the requirements for one of my banks earliest date
>>> of data retrieval. And one has to start over again for each different
>>> account.
>>>
>>> If it can't, then I will use the power of Raku to regenerate the
>>> autohotkey script for the current date.
>>>
>>> Best regards,
>>>
>>> -Tom
>>>
>>> P.S. Is there a spot on the Wiki to list things like Geoff's suggestion
>>> and flycatcher's program? If not, I will be glad to start
>>> one--suggestions welcomed._______________________________________________
>> gnucash-user mailing list
>> gnucash-user at gnucash.org
>> To update your subscription preferences or to unsubscribe:
>> https://lists.gnucash.org/mailman/listinfo/gnucash-user
>> -----
>> Please remember to CC this list on all your replies.
>> You can do this by using Reply-To-List or Reply-All.
>>
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.


More information about the gnucash-user mailing list