[GNC] clip board paste across catagories

Geoff cleanoutmyshed at gmail.com
Wed Sep 30 02:02:32 EDT 2020


Todd / Margo

Since you are a programmer, if you are still keen to use the clipboard, 
here are some left field options for you to investigate:

Windows
-------
I have used AutoHotKey https://www.autohotkey.com/ for nearly a decade 
and it will eat a simple automation task like this for breakfast.

Attached is a sample script to scrape transactions from an Excel 
spreadsheet and insert them directly into a GnuCash ledger.  Seeing is 
believing: https://www.youtube.com/watch?v=wpO1SSJIgu4

Of course this can be done via CSV import, but that's not the point, 
this is to demonstrate automating keyboard interactions with GnuCash.

Linux
-----
I haven't tried these and have no idea if they will work:-

AutoKey https://github.com/autokey/autokey looks like it might do the 
job, at least if GnuCash is an X11 app. See:
https://linuxhint.com/autokey_automate_linux_games/
https://cafetran.freshdesk.com/support/discussions/topics/6000053073

xdotool https://manned.org/xdotool/95401223

Other suggestions here:
https://superuser.com/questions/44052/is-there-an-autohotkey-for-ubuntu

MacOS
This person talks about running GnuCash via X11:
https://github.com/mhitchens/docker-gnucash


Happy investigating!

Geoff
=====

On 30/09/2020 2:47 pm, John Ralls wrote:
> 
> 
>> On Sep 29, 2020, at 8:31 PM, ToddAndMargo via gnucash-user <gnucash-user at gnucash.org> wrote:
>>
>> On 2020-09-29 20:13, John Ralls wrote:
>>>> On Sep 29, 2020, at 5:58 PM, ToddAndMargo via gnucash-user <gnucash-user at gnucash.org> wrote:
>>>>
>>>> On 2020-09-29 13:29, David T. via gnucash-user wrote:
>>>>> I am not an expert, but perhaps if you're writing the format yourself, maybe you could adopt an existing standard (e.g., QIF, QFX, CSV) and import that into GnuCash?
>>>>> Also, Chapter 18 in the Guide is all about importing business data. Perhaps that might lead somewhere?
>>>>
>>>> I have not read chapter 18 yet.
>>>>
>>>> Do you know if there is a way to tell GnuCash to read
>>>> a CSV from the command line?
>>> Not yet, but ISTR that Geert has it planned. The issue will be when he has time to implement it.
>>> Regards,
>>> John Ralls
>>
>> Sounds promising.
>>
>> Be nice it it would work whilst GnuCash is already running too
>>
> 
> That's won't be possible until we have transitioned from an everything-in-memory model to a database model. The alternative, having the command line invocation connect to the running GnuCash, requires multithreading and would
> be even harder because of the several solar masses of static variables and non-reentrant functions.
> 
> Regards,
> John Ralls
> 
> _______________________________________________
> 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
> If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnc_autohotkey_excel_example.jpg
Type: image/jpeg
Size: 275074 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20200930/da98800b/attachment-0001.jpg>
-------------- next part --------------
SetTitleMatchMode, 2
if WinExist("Microsoft Excel")
	WinActivate
else {
	MsgBox, Please open the Excel spreadsheet
	Exit
}

if WinExist(" - Cheque Account - GnuCash")
	WinActivate
else {
	MsgBox, Please open the Gnucash Cheque Account
	Exit
}

Excel := ComObjActive("Excel.Application")

count := 0
total := 0
headings := {}
For r In Excel.ActiveSheet.UsedRange.rows {
	expense := {}
	For c In Excel.ActiveSheet.UsedRange.columns {
		If (r.row = 1) {
			headings[Excel.cells(r.row, c.column).value] := c.column
		}
		else {
			expense.Date := Excel.cells(r.row, headings["Date"]).value
			expense.Account := Excel.cells(r.row, headings["Account"]).value
			expense.Description := Excel.cells(r.row, headings["Description"]).value
			expense.Amount := Excel.cells(r.row, headings["Amount"]).value
		}
	}
	If (r.row > 1) {
		SetKeyDelay, 50
		Send, % expense.Date
		Send, {Tab 2}
		Send, % expense.Description
		Send, {Tab 5}
		Send, % expense.Amount
		Send, {Tab 3}Expenses:
		Send, % expense.Account
		Send, {Enter 4}
		
		count += 1
		total += expense.Amount
		summary .= expense.Account "`t" expense.Amount "`n"
	}
}

MsgBox,, % count . " Transactions $" total, % summary

Exit


More information about the gnucash-user mailing list