Jump to content

Inventory using AutoHotKey


Recommended Posts

I wrote this AutoHotKey script to help me solve a need to create an inventory. Feel free to change this to fit your specific needs.

I needed the following:

  • A way to store the inventory data so I wouldn't have to worry about data loss.
  • Access to the data from my computer, phone, or a remote web site.
  • Availability of the data in other programs - like a spreadsheet - so I could perform calculations on the data or to have the ability to format a list of items.
  • The ability to enter data through use of a form - this forces the information saved to be more consistent and very quick to enter.
  • Fully customizable.

Using Evernote was the easy part. I have used it for a long time and it has never let me down. It just needs a little help to be more useful for this type of task.

In a nutshell, here is what I came up with.
I use an AutoHotKey script on my computer to launch a Windows form (AutoHotKey calls this a GUI). I enter all of the info for a given inventory item then click the "Enter" button. This will format the data and paste it into a new note in Evernote. After that, It will reformat the data into a comma delimited format, and append the data to a local backup text file. This automatically backs up the form data. It also allows the data to be opened in something like Excel so the data can be manipulated and looked at differently.

The Cancel button closes the form with no action being taken.

The Open File button opens the backup text file, which resides in the same location as the script.

As far as finding items in Evernote, I keep everything in a notebook named "Inventory". To narrow down the search, I preface my search with notebook:inventory . That limits the search to only those notes in that notebook.  

Before I show you my solution, understand I am not an AutoHotKey expert. I looked around the web and found bits and pieces that I threw together to get this script. I have used this script for about a year and it works very well for my purposes. Your mileage may vary. 

Here is the script:

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;     Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

;  Here's the basic hotkey syntax - reference.
;  #n::Run Notepad     ; this means the Win+n
;  !n::Run Notepad     ; this means Alt+n
;  ^n::Run Notepad     ; this means Ctrl+n
;  F6::Run Notepad     ; F6
;  ^F6::Run Notepad    ; Ctrl+F6
;  ^!n::Run Notepad    ; Ctrl+Alt+n
;  NumLock & n::       ; Numlock+n

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.


SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory. Backup file will be saved in the scripts location.

; the following line disables the numlock key - this makes it available as a hotkey modifier
SetNumlockState,Alwayson

;Inventory form to paste info into Evernote.

; Here's the hotkey used to launch the form - ALT I

!I::

;The following sets the default text in the "Location:" field of the form - Can leave blank.
DefaultLocation = Living Room

; The following variable defines the background color of the form - uses HTML color codes (must be all CAPS).
CustomColor = ADD8E6


; The following variable sets the font size (in points) the form text will use.
CustomFont = s12


BackupFile = invnote.txt ; Backup filename

FormatTime, RightNow

Gui, Color, %CustomColor%

Gui, font, %CustomFont%
Gui, Add, Text,, Description:
Gui, Add, Text,, Location:
Gui, Add, Text,, Item Barcode:
Gui, Add, Text,, Category:
Gui, Add, Text,, 
;Gui, Add, Text,, 
Gui, Add, Text,, Serial Number:
Gui, Add, Text,, UPC Barcode:
Gui, Add, Text,, Value:
Gui, Add, Text,, Weight:
Gui, Add, Text,, Where Purchased:
Gui, Add, Text,, Purchase Date:
Gui, Add, Text,, Warranty end date:
Gui, Add, Text,, Location of receipt:
Gui, Add, Text,, Sell?:
Gui, Add, Text,, Notes:

Gui, Add, Edit, vDescription w240 ym, ; The ym option starts a new column of controls.,
Gui, Add, Edit, vLocation w120, %DefaultLocation%
Gui, Add, Edit, vBarcode w120,
Gui, Add, ListBox, w400 h80 multi vcategoryList, Computer|Electronics|Music|Automotive|Photography|Office Supplies|Home Theatre|Game|Tools|Media|Misc
Gui, Add, Edit, vser w120,
Gui, Add, Edit, vupc w120,
Gui, Add, Edit, vValue w120,
Gui, Add, Edit, vweight w120,
Gui, Add, Edit, vpur w120,
Gui, Add, Edit, vpdate w120,
Gui, Add, Edit, vwar w120,
Gui, Add, Edit, vrec w120, N/A
Gui, Add, Edit, vsell w120, No
Gui, Add, Edit, vnotes r15 w500

Gui, Add, Button, h30 , Enter ; The label ButtonEnter will be run when the button is pressed.
Gui, Add, Button, h30 , Cancel ; The label ButtonCancel will cancel action and close gui but keep script running.
Gui, Add, Button, h30 , Open File ; The label ButtonOpenFile will be run when the button is pressed.


Gui, Show,, Evernote Inventory Item Input
return 

; The action performed when the "Open File" button is clicked.
ButtonOpenFile:
Run, %BackupFile%
return

;The following section is the action performed when the enter button is clicked. 
;The first part is to save all of the field variables to the clipboard formatted for Evernote. ;The second part is to check that Evernote is open - if not it will open the program.
;The third part the clipboard is pasted to Evernote.
;The fourth part the raw form data is appended to the backup text file to store locally.
;The last part destroys the gui form - this closes the form window.

ButtonEnter:
store := clipboard
Gui, Submit
Clipboard = Description: %Description%`r`nLocation: %Location%`r`nBarcode: %Barcode%`r`nCategory: %categorylist%`r`nSerialNumber: %ser%`r`nUPC Barcode: %upc%`r`nValue: %Value%`r`nWeight: %weight%`r`nWhere Purchased: %pur%`r`nPurchase Date: %pdate%`r`nWarranty end date: %war%`r`nLocation of receipt: %rec%`r`nSell?: %sell%`r`nNotes: %notes%

{
IfWinExist, ahk_class ENMainFrame
WinActivate
Else
Run Evernote.exe, %A_ProgramFiles%\Evernote\Evernote\
Sleep 5000
}

;The following line pastes the form fields in Evernote - you should have the inventory notebook open in Evernote

Send ^!v ;Paste clipboard into Evernote as a new note
Sleep 1000


;the following formats and pastes the form data to the backup text file.
FormatTime, EndNow,, M/d/yyyy h:mm tt
FileAppend, %Description%`,%Location%`,%Barcode%`,%categorylist%`,%ser%`,%upc%`,%Value%`,%weight%`,%pur%`,%pdate%`,%war%`,%rec%`,%sell%`,%notes%`,%EndNow%`n, %BackupFile%

;The following defines the action taken when the cancel button is clicked - it also closes the form after the data is pasted.

ButtonCancel:
Gui,Destroy

;End of script

To use, download and install autohotkey from https://autohotkey.com/

The above code needs to be in a file named to your liking but with a three letter extension of .ahk

Before using the script, you should have Evernote open and you should be in the notebook you use to store your inventory items (create one if you don't have one). I never found a way to paste data into a specific notebook.

After the script is running, by default, ALT-I will open the blank form anytime you want to create a new inventory entry.

It takes a few seconds to complete the script when you click the "Enter" button.

I use a Basic account so there has been no testing on a Premium or Business account.

Feel free to ask questions - I will answer to the best of my abilities (there are probably way easier ways to accomplish this).

If you make improvements, put your code up here for everyone to enjoy.

Link to comment
  • Level 5*
50 minutes ago, Comidi said:

Before using the script, you should have Evernote open and you should be in the notebook you use to store your inventory items (create one if you don't have one). I never found a way to paste data into a specific notebook.

For my personal use, I can't see the benefit in using this process 

- At this point, I would use a template to make sure my note is formatted correctly and is complete, or updating a table/spreadsheet

- I don't have a need for the inventory to be accessed externally; but that is a downside to Evernote; your information gets locked away

- You would now have your inventory details in two places; they may get out of sync

Link to comment
  • Level 5*

Nice use of AHK to generate and complete a template though,  and the additional copy element (or the generated file) could be disgarded..  Thanks!

Edit:  and don't worry about whether or not it's 'elegant'.  Like plane landings - anything you can walk away from...  ;)

Link to comment

Thanks for your feedback.

The text file backup feature can easily be disabled with a few semicolons - just a feature for me to access my original input data. Although it has never happened to me, if I ever lost data in Evernote, this original data might help me find the location of an item in a plastic storage tub somewhere. A text file is cheap.

I use a barcode scanner in my inventory process - It sends a TAB after it types the barcode text - this automatically moves the cursor to the next field in the form. One of the advantages I derive from using a form for input. If need be, you could also set up some input validation to make sure the data is complete or properly formatted.

Maybe there is something I don't know about Evernote templates that supports input fields. 

Autohotkey and Evernote are awesome programs and this is a way of quickly adding structured data to an otherwise freeform database. 

I have included images of the Autohotkey input form and the pasted Evernote data as a better explanation of the process.

AHK_form.PNG

EN.PNG

Link to comment
  • Level 5*
1 hour ago, Comidi said:

Maybe there is something I don't know about Evernote templates that supports input fields. 
Autohotkey and Evernote are awesome programs and this is a way of quickly adding structured data to an otherwise freeform database. 
I have included images of the Autohotkey input form and the pasted Evernote data as a better explanation of the process.

Thanks for posting the images.
It does show an awesome method of implementing an input template into Evernote.
I don't think we have an equivalent in the Mac world.
I could use applescript, but it wouldn't look as elegant.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...